HP 3000 Manuals

MOVE [ HP Transact Reference Manual ] MPE/iX 5.0 Documentation


HP Transact Reference Manual

MOVE 

Places data into a specified data register space. 

Syntax 

MOVE (destination-variable) = source-expression;

MOVE places data into the data register location specified by
destination-variable.  You should use MOVE particularly when you want to
move a character string into a data register location.  Unlike LET, MOVE
does not check data types during the operation.  If it is necessary to
convert data types between the source and the destination, you must use
the LET verb to do so.  Since MOVE does not check data types during the
operation, a destination-variable of type U could contain lowercase
alphanumeric characters.

When moving items of different lengths, values are truncated or filled on
the right.  Numeric data types I, J, Z, P, K, R, E, and 9 are filled with
nulls, and alphanumeric data types X and U are filled with blanks.


NOTE In Transact/iX the fill character for data type 9 is blank.
The display length of the source data item is used to determine the number of characters moved for data types U and X. Storage length is used for all data types when using justification of a literal. For unsubscripted arrays using justification, storage length is used for all data types.
NOTE The destination-variable is used to hold any intermediate results when processing the source-expression. See "Special Considerations" later in this verb for potential side effects.
Statement Parts destination-variable can be the following: (item-name Specifies that you want the data moved into the data [(subscript)]) register location identified by item-name. The item-name can be subscripted if an array item is being referenced. (See "Array Subscripting" in Chapter 3.) source-expression is defined below with detailed explanations following: {[-](item-name[(subscript)]) } {[-]"character-string" } {[-]string-function } {format-function } {source1 [operator source2]...} {STATUS(parm) } [-](item-name The value in the data register location for item-name. [(subscript)]) If you include the minus sign (-), then the source value is placed in the destination field with opposite justification. That is, source data that is right-justified is left-justified in the destination field and vice versa. The item-name can be subscripted if an array item is being referenced. (See "Array Subscripting" in Chapter 3.) [-]"character- A programmer-defined character string. If you include string" the minus sign (-), then the source field is right-justified in the destination field. If character-string is null, as in "", then the receiving field is filled with binary zeros. To fill the field with blanks, use a space, " ", for the character string. [-]string- Any of the functions listed below, each of which has a function character string as its result. If you include the minus sign (-), then the source value is placed in the destination field with opposite justification. That is, source data that is right-justified is left-justified in the destination field and vice versa. (See "Functions" later in the description of this verb for a description of each function and its parameters.) CHAR LOWER PROPER STRING UPPER format-function Either of the two functions listed below, each of which operates on the destination field. A minus sign is not allowed before a format-function. (See "Functions" later in the description of this verb for a description of each function and its parameters.) COL SPACE source1 The source can be an (item-name[(subscript)]), a operator "character-string", a string-function, or a source2 ... format-function. The operator can be +, -, and both operator operators can be used in the same expression (a minus sourcen sign is not allowed before a format-function). The plus sign concatenates the items and strips trailing blanks. The minus sign removes the next item. Items and strings to be combined are specified in the order of their intended concatenation or removal. Leading blanks in the strings to be concatenated are not stripped before concatenation. STATUS(parm) Moves a value to the destination field, depending on the value of parm. If parm is: DB Moves status block used in last database call to the data register location specified by destination-variable. BASE Moves the database name referenced in the last database call to the data register location specified by destination-variable. FILE Moves the name of the data set or file referenced by the last database, KSAM, or MPE call to the data register location specified by destination-variable. Special Considerations The destination-variable on the left of the "=" sign will be used as a temporary variable to hold intermediate values necessary when calculating the result of the source-expression on the right of the "=" sign. Some important points should be noted: * The operands in the source-expression are processed in the order referenced (i.e. left to right). * If the source-expression contains multiple operators, the destination-variable must be defined large enough to hold any intermediate values or truncation will occur. For example, MOVE (A) = (B) + (C) - (D); (A) must be large enough to hold the result of (B) + (C). Failure to do so will cause the intermediate result to be truncated before removing the value of (D). A detailed example follows: MOVE (NAME) = (FNAME) + (LNAME) - "SON"; Before After FNAME X(05) DAVID DAVID LNAME X(06) BENSON BENSON NAME X(10) JEFFBENNER DAVIDBENSO * If the source-expression used on the right of the "=" sign also contains the destination-variable, the value of the destination-variable may have changed which could cause unexpected results. For example, MOVE (A) = (B) + (C) + (A); the reference to (A) on the right will have the result of (B) + (C) in it when it is used in the calculation. The best strategy is to avoid using (A) on the right after two operators. A detailed example follows: MOVE (NAME) = (FNAME) + (LNAME) + (NAME); Before After FNAME X(08) John____ John____ LNAME X(08) Paul____ Paul____ NAME X(16) Jones___________ JohnPaulJohnPaul * If the source-expression contains a child item and the destination-variable is an overlapping child item of the same parent, the destination variable may contain unexpected results. For example: DEFINE(ITEM) PARENT X(5): CHILD1 X(3) = PARENT(1): CHILD2 X(3) = PARENT(3); LIST PARENT,INIT; MOVE (PARENT) = "AABBB"; MOVE (CHILD2) = (CHILD1); After the move, CHILD2 contains "AAA", not "AAB", because the move is done as follows: 1. The first A is moved from position 1 to position 3. 2. The second A is moved from position 2 to position 4. 3. The third character has already been replaced by step 1, and is now A; the third step is therefore to move A from position 3 to position 5. * When a MOVE contains more than two operands, the Transact compiler will split the MOVE into multiple MOVE statements of two operands each. The following statement: MOVE (A) = (B) + (C) - (D); will be split into the following: MOVE (A) = (B) + (C); MOVE (A) = (A) - (D); * When a function is the first operand in a MOVE statement, the MOVE will be split into multiple MOVE statements. Consider the following statement: MOVE (A) = UPPER(B) + (C) - (D); The Transact compiler will split the MOVE into the following statements: MOVE (A) = UPPER(B); MOVE (A) = (A) + (C); MOVE (A) = (A) - (D); Functions The following sections describe the string functions (CHAR, LOWER, PROPER, STRING, and UPPER) and format functions (COL and SPACE) that are only available within the MOVE verb, including parameters and examples. The string functions return values based on the operation performed on the source-variable. The format functions operate on the destination-variable. A leading minus sign (-) is not allowed with a format function. A compiler error will be generated when a minus sign immediately precedes a format function. CHAR The CHAR function returns the character equivalent of a numerical ASCII code. The argument is a number between 0 and 255 inclusive. Arguments outside the range of 0 to 255 will return a blank. Syntax CHAR({(item-name[(subscript)])}) {numeric-constant } Examples MOVE (STRING) = CHAR((NUM)); Before After NUM I(4) 65 65 STRING X(4) XYZ_ A___ MOVE (STRING(2)) = CHAR(97); Before After STRING(2) U(4) XYZ_ a___ MOVE (STRING(2)) = -CHAR(97); Before After STRING(2) U(4) XYZ_ ___a COL The COL function moves a string into the destination beginning at the specified column position. The first column position is 1. Any bytes in the destination to the left of the column position will be unchanged. Syntax COL({(item-name[(subscript)])},position) {"character-string" } where position is either a data item name in parentheses or a numeric constant. The position parameter indicates the byte in the destination where the string will begin. If position is greater than the number of bytes in the destination, nothing is moved. Examples MOVE (ADDRESS) = (NUMBER) + COL((STREET),(POS)); Before After ADDRESS X(16) abcdefghijklmnop 125__Hardwick___ POS I(4) 6 6 NUMBER X(4) 125_ 125_ STREET X(10) Hardwick__ Hardwick__ MOVE (ADDRESS) = COL((STREET),(POS)); Before After ADDRESS X(16) abcdefghijklmnop abcdeHardwick___ POS I(4) 6 6 STREET X(10) Hardwick__ Hardwick__ Errors A position value less than 0 is the only error specific to the COL function. If an error is encountered while processing the COL function, the string will be moved to the destination using the default position value of 1. A message describing the error condition is also displayed. Processing continues if Transact is running online, but will stop if Transact is running in batch mode. LOWER The LOWER function returns a string in which all letters are converted to lowercase. Any non-alphabetic characters remain unchanged. Syntax LOWER({(item-name[(subscript)])}) {"character-string" } Examples MOVE (NAME) = LOWER((NAME)); Before After NAME X(8) BROWN_J_ brown_j_ MOVE (LNAME) = LOWER("SMITH"); Before After LNAME U(4) ABCD smit MOVE (ACTION(2)) = LOWER((VERB((I)))) + "ed"; Before After I I(5) 4 4 VERB(4) X(4) JUMP JUMP ACTION(2) X(6) TURNS_ jumped PROPER The PROPER function returns a string in which a letter in the first character position and each letter immediately following a special character are converted to uppercase. All other characters remain unchanged. The default set of special characters as used by PROPER are !"#$%&'()*+,-./:;<=>?@[\]^_`{|}~ and the blank character. To change the set of characters that cause the next letter to be upshifted, see the SET and RESET verbs later in this chapter. Syntax PROPER({(item-name[(subscript)])}) {"character-string" } Examples MOVE (NAME) = PROPER((NAME)); Before After NAME X(8) brown_j_ Brown_J_ MOVE (LNAME) = PROPER("smith,j"); Before After LNAME U(7) ABCD___ Smith,J MOVE (LNAME) = PROPER("SMITH,J"); Before After LNAME U(7) ABCD___ SMITH,J MOVE (LNAME) = PROPER((NAME)); Before After NAME X(5) smith smith LNAME X(6) ABCD__ Smith_ MOVE (LNAME) = PROPER("mr.john smith (hp)"); Before After LNAME X(18) ABCD_..._ Mr.John_Smith_(Hp) MOVE (LNAME) = PROPER((NAME)); Before After NAME X(7) a_and_b a_and_b LNAME X(7) ABCDE__ A_And_B MOVE (ACTION(2)) = PROPER((VERB((I)))) + "ed"; Before After I I(5) 3 3 VERB(3) X(4) JUMP JUMP ACTION(2) X(6) TURNS_ JUMPed MOVE (LNAME) = PROPER("a1b,c.d!e&f g(h]i;"); Before After LNAME X(18) ABCD_..._ A1b,C.D!E&F_G(H]I; SPACE The SPACE function moves the specified number of spaces into the destination before moving the string. Syntax SPACE({(item-name[(subscript)])},space-size) {"character-string" } where space-size is either a data item name in parentheses or a numeric constant. The space-size parameter indicates the number of spaces to be moved to the destination before moving the string. Examples MOVE (NAME) = (LNAME) + SPACE(FNAME,1) + SPACE(INITIAL,1); Before After LNAME X(6) Doe___ Doe___ FNAME X(6) John__ John__ INITIAL X(2) Q_ Q_ NAME X(14) abcdefghijklmn Doe_John_Q____ Errors A space-size value less than 0 is the only error specific to the SPACE function. If an error is encountered while processing the SPACE function, the string will be moved to the destination using the default space-size value of 0. A message is also displayed describing the error condition. Processing continues if Transact is running online, but will stop if Transact is running in batch mode. STRING The STRING function returns a string that is taken from another string beginning at a given position for a given length. Syntax STRING({(item-name[(subscript)])},position,length) {"character-string" } where position and length are either data item names in parentheses or numeric constants. The position parameter indicates the byte at which the substring begins. The length parameter indicates the number of bytes to move. If length + position would extend beyond the end of the source string, the substring returned will be padded a corresponding number of trailing spaces. Examples MOVE (NAME) = STRING((NAME),1,3); Before After NAME X(8) BROWN_J_ BRO_____ MOVE (LNAME) = STRING("SMITH",(POS),(LEN)); Before After POS I(4) 3 3 LEN I(4) 2 2 LNAME X(6) ABCD__ IT____ MOVE (LNAME) = STRING((NAME),(POS),4); Before After POS I(5) 2 2 NAME X(5) SMITH SMITH LNAME X(6) ABCD__ MITH__ MOVE (ACTION(2)) = STRING((VERB((I))),(POS(3)),(LEN((I)))) + " "; Before After I I(5) 4 4 VERB(4) X(4) JUMP JUMP POS(3) I(4) 1 1 LEN(4) I(4) 3 3 ACTION(2) X(6) TURNS_ JUM__ The next two examples demonstrate the use of functions with concatenation. Removal can produce different results: MOVE (X10) = "Rapid Team" - ("a",20,1) - "p"; Before After X10 X(10) ABC_______ Raid_Team_ The string function returns a null, therefore nothing is removed. MOVE (X5) = STRING ("a",20,1); MOVE (X10) = "Rapid Team" - (X5) - "p"; Before After X5 X(5) ABCDE _____ X10 X(10) XYZ_______ RaidTeam__ The string function returns a null, however when a null is moved to an X type item, it is converted to blanks. A blank is then removed in the second MOVE statement. Errors If an error is encountered while processing the STRING function, an appropriate default string is returned by the function depending on the destination's data type (spaces for X and U types and nulls for all other types). A message is also displayed describing the error condition. Processing continues if Transact is running online but will stop if Transact is running in batch mode. The only errors specific to the STRING function are: * Position parameter <0 * Length parameter <0 UPPER The UPPER function returns a string in which all letters are converted to uppercase. Non-alphabetic characters remain unchanged. Syntax UPPER({(item-name[(subscript)])}) {"character-string" } Examples MOVE (NAME) = UPPER((NAME)); Before After NAME X(8) brown_j_ BROWN_J_ MOVE (LNAME) = UPPER("smith"); Before After LNAME U(6) abcd__ SMITH_ MOVE (LNAME) = UPPER((NAME)); Before After NAME X(5) smith smith LNAME X(6) abcdef SMITH_ MOVE (ADDRESS) = UPPER("123_Main"); Before After ADDRESS X(8) abcdefgh 123_MAIN MOVE (ACTION(2)) = UPPER((VERB((I)))) + "ed"; Before After I I(5) 1 1 VERB(1) X(4) jump jump ACTION(2) X(6) turns_ JUMPed MOVE (LNAME) = UPPER((NAME)); Before After NAME X(7,,7) abcdefg abcdefg LNAME X(6,,7) JOHN_J_ ABCDEFG In the preceding example using a storage length of 7, the item LNAME will contain ABCDEFG in the data register, but when displayed, LNAME will only display the first 6 characters, ABCDEF. Examples The first example copies the values for FIELD-A into FIELD-B. MOVE (FIELD-B) = (FIELD-A); Before After FIELD-A X(4) SAM_ SAM_ <<no change>> FIELD-B X(5) CHUCK SAM__ The next example moves the first two characters of DATE into MONTH. MOVE (MONTH) = (DATE); Before After DATE X(6) 100770 100770 <<no change>> MONTH X(2) 12 10 The next example shows concatenation. Note that the trailing blanks in FIELD1 are stripped when the two fields are concatenated. MOVE (NEWFIELD) = (FIELD1) + (FIELD2); Before After FIELD1 X(4) AB__ AB__ <<no change>> FIELD2 X(3) CDE CDE <<no change>> NEWFIELD X(6) 123456 ABCDE_ The following example shows the removal of internal characters: MOVE (DATE) = (FDATE) - (SLASH); Before After FDATE X(8) 01/31/82 01/31/82 <<no change>> SLASH X(1) / / <<no change>> DATE X(6) ______ 013182 The next example shows justification: MOVE (FIELDY) = -(FIELDX); Before After FIELDX X(4) ABC_ ABC_ <<no change>> FIELDY X(4) 1234 _ABC The next examples show justifications using fields of different lengths. MOVE (FIELDB) = -(FIELDA); Before After FIELDA X(4) XYZ_ XYZ_ FIELDB X(8) 12345678 _____XYZ MOVE (FIELDA) = -(FIELDB); Before After FIELDA X(4) XYZ_ 1234 FIELDB X(8) 123456__ 123456__ MOVE (FIELDA) = -(FIELDB); Before After FIELDA X(4) XYZ_ _123 FIELDB X(8) 123_____ 123_____ The following example demonstrates the use of MOVE with numeric data items of different lengths. SYSTEM T6121; DEFINE(ITEM) INTARRAY 10 I(4): INT I(4); LIST INTARRAY: INT; LET (INT) = 65; MOVE (INTARRAY) = (INT); DISPLAY INTARRAY; EXIT; The result in INTARRAY is the first element has 65 and all others have 0 because MOVE fills numeric type items with zeros when the source length is smaller than the destination. Be sure that the definitions of the source and destinations are the same, since no type conversion is performed by MOVE. When assigning a value to an array, the MOVE verb treats the array as a simple compound item and moves each byte one at a time until the end of the value or the end of the array, whichever comes first. The remaining elements are filled with blanks (if 9, X, or U data types) or filled with null characters (if numeric data types). If a subscript is specified, only that element is assigned the value and all other subscripts remain unchanged. For example, if ARRAY-X is defined as 6X(2) and ARRAY-I is defined as 4I(5,,2). MOVE (ARRAY-X) = "abcdefgh"; <<Sets 1st element to ab; 2nd to cd, etc.>> MOVE (ARRAY-X(2)) = "ZZ"; <<Sets 2nd element to ZZ.>> LET (TEMP-I) = 67; MOVE (ARRAY-I) = (TEMP-I); <<Sets 1st element to 67 and rest >> <<to nulls (binary 0).>> LET (TEMP-I) = 78; MOVE (ARRAY-I(4)) = (TEMP-I); <<Sets only 4th element to 78.>> See chapter 3 for more information on handling arrays.


MPE/iX 5.0 Documentation