MV
Copies data between the input buffer, output buffers, file buffers and select registers.
Syntax
MV destination source{,source}...{,*{n}}{,_}
or
MV destination source{*source}...
Syntax Elements
destination is a direct or indirect reference to a buffer or select register that you want the data copied to. If the destination is a select register, the source can only be a direct or indirect reference to a file buffer.
source is the data you want to copy. The source can be:
- A direct or indirect reference to a buffer or select register that contains the data you want to copy.
- A direct or indirect reference to a buffer followed by ;inputConversion; or :outputConversion:. See English Conversions for details.
- A string of zero or more characters enclosed in single or double quotes. An uneven number of quotes gives a syntax error.
- A SYSTEM function that returns system/database information.
A single character expressed in one of two ways:
Xxwhere x is a hexadecimal number in the range 00 to FF. Thus, XFD is a value mark.
Inwhere n is a decimal number in the range 0 to 255. Thus, I253 is a value mark.
,* copies all source parameters starting with the specified parameter. If * is the last operand in the source field, the destination buffer or select register is truncated after the last parameter is copied.
,*ncopies n further source parameters following (and in addition to) the specified parameter.
,_ specifies that the destination is truncated after the source is copied.
*sourceconcatenates the source values into one attribute in the destination.
Select Register Destination
If you use a select register as the destination, then the only valid source is a direct or indirect reference to a file buffer. For example:
MV !1 &5.9
or
MV !3 &3.%1
Creating Null Attributes or Parameters
If the attribute or parameter number in destination is larger than the current number of attributes or parameters, the Proc processor automatically creates null values to space out to the requested location.
If the source is a literal string containing just two double quotes, then the destination is nulled.
Input Buffer Pointer
If you reference the primary input buffer as the destination, that buffer is selected as active and the buffer pointer is positioned at the beginning of the moved string.
Copying a Series of Values
If you give a series of values as the source, the first value is copied into the destination, and each subsequent source value is copied to a successive location in the destination buffer. For example:
MV %2 &2.7,"ABC",!2
copies attribute 7 of file buffer 2, the string "ABC", and the next value from select register 2 into the 2nd, 3rd, and 4th parameters of the primary input buffer.
Preserving Parameters/Attributes
If you want to change more than one attribute or parameter without changing the attributes or parameters in between, you must use commas in the source field to preserve those attributes or parameters.
For example, if the primary input buffer contains ABC^DEF^GHI^JKL, and you issue the following command,
MV %1 "XX",,,"9999"
the result is XX^DEF^GHI^9999. The command replaces the 1st and 4th parameters with new values, leaving the 2nd and 3rd parameters unaltered.
Concatenation
If you separate a series of source values with asterisks (*) instead of commas, the source values are concatenated into one attribute in the destination. For example:
MV %2 &1.7*"TEXT"*%4
concatenates the 4th attribute of the primary input buffer to the string "TEXT", then concatenates that result to attribute 7 of file buffer 1, then copies the result as a single parameter into the 2nd parameter of the primary input buffer.
Truncation
If you specify an underline (_) as the last item in the source field, the specified destination is truncated after the last source is copied.
Copying the Entire Contents of a Buffer
If you specify an asterisk (*) as the last item in a source field, all attributes or parameters starting with the specified attribute or parameter are copied. For example:
MV &2.1 %10,*
copies the 10th parameter of the primary input buffer to attribute 1 of file buffer 2. It also copies parameter 11 of the primary input buffer to attribute 2 of file buffer 2, and so on. The remainder of file buffer 2 is truncated after the last parameter of the primary input buffer is copied.
Copying a Series of Attributes
If you specify an asterisk followed by an integer (*n) as a source field element, the number of attributes or parameters specified by n are copied in addition to the specified attribute or parameter. For example:
MV &2.3 %4,*3
copies the 4th, 5th, 6th and 7th parameters of the primary input buffer to attributes 3, 4, 5 and 6 of file buffer 2. The remainder of file buffer 2 is not truncated.
English Conversions
The MV syntax supports English conversion of direct or indirect references in source operands, provided that the destination is not a select register. The format is similar to that used with IBH or IH:
reference;inputConversion;
reference:outputConversion:
For example, MV %3
%3;T1,3;
extracts the first three characters of %3 from %3 and replaces
the original %3 with just these three characters. An advantage of using MV to
perform conversions (rather than
IH or
IBH) is that MV uses an extensible buffer that is only limited by
your OS workspace area.
Note that not all conversions are supported by Proc.
Example 1
Command |
PIB Before |
PIB After |
---|---|---|
|
|
|
Example 2
Command |
PIB Before |
PIB After |
---|---|---|
|
|
|
Example 3
Command |
PIB Before |
PIB After |
---|---|---|
|
|
|
Example 4
Command |
File Buffer 4 Before |
File Buffer 4 After |
---|---|---|
|
|
|
Command |
File Buffer 2 Before |
File Buffer 2 After |
---|---|---|
|
|
|
This example moves attributes from file buffer 2 to file buffer 4 using the (*) to move the entire contents of file buffer two. Note the truncation of the fourth attribute of file buffer 4.
Example 5
MV %1 "ONE","TWO","THREE" MV %1 %2,%3
The first MV command copies "ONE" into the 1st parameter, "TWO" into the 2nd parameter, and "THREE" into the third parameter of the primary input buffer.
The second MV command copies the contents of the 2nd parameter (TWO) into the 1st parameter, and the contents of the 3rd parameter (THREE) into the 2nd parameter of the primary input buffer.
Example 6
Command |
PIB Before and After |
---|---|
|
|
POB Before |
POB After |
|
---|---|---|
|
|
Example 7
Command |
PIB Before and After |
---|---|
|
|
|
File Buffer 4 Before |
File Buffer 4 After |
---|---|---|
|
|
|
Example 8
Command |
PIB Before and After |
---|---|
|
|
Command |
File Buffer 3 Before |
File Buffer 3 After |
---|---|---|
|
|
|