This document covers the following topics:
For an explanation of the symbols used in the syntax diagrams below, see Syntax Symbols.
Related Statements: ADD | COMPRESS | COMPUTE | DIVIDE | EXAMINE | MULTIPLY | RESET | SEPARATE | SUBTRACT
Belongs to Function Group: Arithmetic and Data Movement Operations
The MOVE statement is used to move the value of an operand to one or more
operands (field or array).
A Natural system function may be used only if the MOVE statement is
specified in conjunction with an AT
BREAK, AT END OF
DATA or AT END OF
PAGE statement.
See also the section Rules for Arithmetic Assignment in the Programming Guide.
MOVE
[ROUNDED] operand1 [(parameter)]
TO
operand2
|
For an explanation of the symbols used in the syntax diagrams below, see Syntax Symbols.
Operand Definition Table:
| Operand | Possible Structure | Possible Formats | Referencing Permitted | Dynamic Definition | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
operand1
|
C | S | A | N | A | U | N | P | I | F | B | D | T | L | C | G | O | yes | no | |
operand2
|
S | A | M | A | U | N | P | I | F | B | D | T | L | C | G | O | yes | yes | ||
Syntax Element Description:
| Syntax Element | Description | ||||||||
|---|---|---|---|---|---|---|---|---|---|
MOVE ROUNDED
|
MOVE ROUNDED Option:
This option causes
See also Example 1 - Various Samples of MOVE Statement Usage. |
||||||||
|
|
For the rules for data transfer and information on data conversion and transfer compatibility, see the section Data Transfer in the Programming Guide. If A MOVE #SOURCE TO #TARGET1 #TARGET2 is identical to MOVE #SOURCE TO #TARGET1 MOVE #SOURCE TO #TARGET2 |
||||||||
parameter |
|
||||||||
MOVE |
|
operand1 |
|
[(parameter)] | |||
TO |
|
operand2 |
|
||||
|
|
|||||||
This syntax only applies if you want to move only part of the field contents (a substring) of a source and/or target operand. Otherwise, Syntax 1 applies.
For an explanation of the symbols used in the syntax diagrams below, see Syntax Symbols.
Operand Definition Table:
| Operand | Possible Structure | Possible Formats | Referencing Permitted | Dynamic Definition | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
operand1
|
C | S | A | A | U | B | yes | no | ||||||||||||
operand2
|
S | A | A | U | B | yes | no | |||||||||||||
operand3
|
C | S | N | P | I | B* | yes | no | ||||||||||||
operand4
|
C | S | N | P | I | B* | yes | no | ||||||||||||
operand5
|
C | S | N | P | I | B* | yes | no | ||||||||||||
operand6
|
C | S | N | P | I | B* | yes | no | ||||||||||||
* See text.
Syntax Element Description:
| Syntax Element | Description |
|---|---|
MOVE SUBSTRING
|
MOVE SUBSTRING:
Without the The If the underlying field format of
For example, to move the 5th to 12th position inclusive of the value in a field
MOVE SUBSTRING(#A,5,8) TO #B If Also, you can move a value of an alphanumeric/Unicode or binary field into a
certain part of the target field. After the field name
( If the underlying field format of
For example, to move the value of a field MOVE #A TO SUBSTRING(#B,3,4) If If
If you omit
If Note |
parameter |
Parameter Option: See parameter in Syntax
1.
|
MOVE
|
BY
|
|
[NAME]
|
|
operand1
TO
operand2
|
POSITION
|
Operand Definition Table:
| Operand | Possible Structure | Possible Formats | Referencing Permitted | Dynamic Definition | |||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
operand1
|
G | yes | no | ||||||||||||||||
operand2
|
G | yes | no | ||||||||||||||||
Syntax Element Description:
| Syntax Element | Description |
|---|---|
MOVE BY NAME operand1 TO
operand2
|
MOVE BY NAME Option:
This option is used to move individual fields contained in a data structure to another data structure, independent of their position in the structure. A field is moved only if its name appears in both structures (this includes
Note See also Example 2 - MOVE BY NAME Statement. MOVE BY NAME with Arrays:
If the data structures contain arrays, these will internally be assigned the
index See also Example 3 - MOVE BY NAME with Arrays. |
MOVE BY POSITION
operand1 TO
operand2
|
MOVE BY POSITION Option:
This option allows you to move the contents of fields in a group to another group, regardless of the field names. The values are moved field by field from one group to the other in the order in which the fields are defined (this does not include fields resulting from a redefinition). The individual fields may be of any format. The number of fields in each group must be the same; also, the level structure and array dimensions of the fields must match. Format conversion is done according to the rules for arithmetic assignment; see the section Rules for Arithmetic Assignments in the Programming Guide. The operands can also be views. See also Example 4 - MOVE BY POSITION. |
MOVE
EDITED
operand1
TO
operand2
|
|
(EM=value)
|
|
|
(EMU=value)
|
||||
Operand Definition Table:
| Operand | Possible Structure | Possible Formats | Referencing Permitted | Dynamic Definition | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
operand1
|
C | S | A | A | U | B | yes | no | ||||||||||||
operand2
|
S | A | A | U | N | P | I | F | B | D | T | L | yes | yes | ||||||
Syntax Element Description:
| Syntax Element | Description |
|---|---|
MOVE EDITED
|
MOVE EDITED Option:
If an edit mask is specified for
The edit mask can be considered as an input edit mask for
If the edit mask refers more characters or digits than existent in
Under the pre-condition not to have an
MOVE EDITED operand1 TO operand2 (EM=value) operation like the execution of STACK TOP DATA operand1
INPUT operand2 (EM=value)
See also Example 1 - Various Samples of MOVE Statement Usage. If Alternatively, you can use the wildcard character ' |
EM
|
Edit Mask:
For details on edit masks, see the session parameter |
EMU
|
Unicode Edit Mask:
For details on Unicode edit masks, see the session parameter |
MOVE
EDITED
operand1
|
|
(EM=value)
|
|
TO
operand2 |
|
(EMU=value)
|
|||||
Operand Definition Table:
| Operand | Possible Structure | Possible Formats | Referencing Permitted | Dynamic Definition | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
operand1
|
C | S | A | N | A | U | N | P | I | F | B | D | T | L | yes | no | ||||
operand2
|
S | A | A | U | B | yes | yes | |||||||||||||
Syntax Element Description:
| Syntax Element | Description |
|---|---|
MOVE EDITED
|
MOVE EDITED Option:
If an edit mask is specified for
The edit mask can be considered as an output edit mask for
If the edit mask refers more characters or digits than existent in
Under the pre-condition not to have an
MOVE EDITED operand1 (EM=value) TO operand2 operation like a WRITE operand1 (EM=value) that does not write the output to the screen, but fills it into variable
See also Example 1 - Various Samples of MOVE Statement Usage. |
EM
|
Edit Mask:
For details on edit masks, see the session parameter |
EMU
|
Unicode Edit Mask:
For details on Unicode edit masks, see the session parameter |
MOVE
|
|
LEFT
|
|
[JUSTIFIED]
operand1
[(parameter)]
TO
operand2
|
RIGHT
|
Operand Definition Table:
| Operand | Possible Structure | Possible Formats | Referencing Permitted | Dynamic Definition | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
operand1
|
C | S | A | N | A | U | N | P | I | F | B | D | T | L | yes | no | ||||
operand2
|
S | A | A | U | yes | yes | ||||||||||||||
Syntax Element Description:
| Syntax Element | Description |
|---|---|
MOVE LEFT / RIGHT
JUSTIFIED
|
MOVE LEFT / RIGHT JUSTIFIED Options:
This option is used to cause the values to be moved to be left- or
right-justified in
|
MOVE LEFT JUSTIFIED |
MOVE LEFT Option:
With |
MOVE RIGHT JUSTIFIED |
RIGHT JUSTIFIED Option:
With See also Example 1 - Various Samples of MOVE Statement Usage. |
parameter
|
Parameter:
When you use
|
The MOVE NORMALIZED statement converts a Unicode string into the
"Unicode Normalization Form C" (NFC). The resulting Unicode string does no
longer contain combining sequences for characters which are available as pre-composed
characters.
If the format of the target operand is not Unicode itself, an implicit conversion from
Unicode into the target operand takes place - during this conversion the default code page
(see system variable *CODEPAGE) will be used.
For further information on the MOVE NORMALIZED statement, see the section
Statements in the Unicode and Code Page
Support documentation.
Syntax Diagram:
MOVE
NORMALIZED
operand1
TO
operand2
|
Operand Definition Table:
| Operand | Possible Structure | Possible Formats | Referencing Permitted | Dynamic Definition | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
operand1
|
C | S | A | U | yes | no | ||||||||||||||
operand2
|
S | A | A | U | yes | yes | ||||||||||||||
Syntax Element Description:
| Syntax Element | Description |
|---|---|
MOVE NORMALIZED |
MOVE NORMALIZED Option:
This option is used to convert Unicode fields with potentially unnormalized content into the "Unicode Normalization Form C" (NFC). This composite form of a Unicode string does not contain combining sequences for characters which are available as pre-composed characters. See also: http://www.unicode.org/reports/tr15/#Canonical_Composition_Examples ("Normalization Forms D and C Examples"). Example: MOVE NORMALIZED #SCR TO #TGT |
operand1
|
Source Operand:
|
operand2
|
Target Operand:
|
Example:
Some code points have different representations in Unicode. For example, the German
letter 'Ä': the decomposed representation in Unicode is U+0041
followed by U+0308 and uses a combining character (U+0308);
another representation is the pre-composed character U+00C4. The MOVE
NORMALIZED statement converts the Unicode representation with combining
characters into a normalized Unicode representation using pre-composed characters, where
possible.
This section explains the syntax of the MOVE ENCODED statement. For
information on the purpose of this statement, see the section Statements in the Unicode and Code Page
Support documentation.
Syntax Diagram:
MOVE
ENCODED
|
operand1 [[IN] CODEPAGE
operand2] TO |
operand3 [[IN] CODEPAGE
operand4]
|
[GIVING
operand5]
|
Operand Definition Table:
| Operand | Possible Structure | Possible Formats | Referencing Permitted | Dynamic Definition | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
operand1
|
C | S | A | A | U | B | yes | no | ||||||||||||
operand2
|
S | A | U | yes | no | |||||||||||||||
operand3
|
S | A | U | B | yes | yes | ||||||||||||||
operand4
|
S | A | A | U | yes | no | ||||||||||||||
operand5 |
S | I4 | yes | yes | ||||||||||||||||
Syntax Element Description:
| Syntax Element | Description |
|---|---|
MOVE
ENCODED |
MOVE ENCODED Option:
This option converts a character string, encoded in one code page, into the equivalent character string of another code page. Note |
operand1
|
Source Operand:
|
CODEPAGE
operand2
|
Code Page of Source Operand:
As Can only be supplied if |
TO
operand3
|
Target Operand:
If the conversion result does not fit into the target field, the result is padded or truncated, respectively, and as padding character the blank of the resulting code page is used. If the target field is defined as a dynamic variable, no padding or truncation is needed, since the length of the dynamic variable is automatically adjusted to the length of the conversion result. |
CODEPAGE
operand4
|
Code Page of Target Operand:
As Can only be supplied if |
GIVING
operand5 |
GIVING Clause:
If you omit this clause, a Natural error message is returned if an error occurs. If you specify the keyword If the target gets truncated, no Natural error message is given, but when the
keyword |
Notes:
*CODEPAGE) is used.
CPCVERR in the statement SET GLOBALS or in the system command
GLOBALS is set to ON, an error is
output if at least one character of the source field could not be converted properly
into the destination code page, but was replaced in the target field by a substitution
character.
NTCPAGE in the source module NATCONFG can be used. Other code page names are rejected
with a corresponding runtime error.
MOVE ENCODED A-FIELD1 TO A-FIELD2
Invalid: This results in a syntax error, since the code page names are taken by default
and are the same for operand1 and
operand3.
MOVE ENCODED A-FIELD1 CODEPAGE 'IBM01140' TO A-FIELD2 CODEPAGE 'IBM01140'
Invalid: This results in an error, since the coded code page names are the same for
operand1 and
operand3.
MOVE ENCODED A-FIELD1 CODEPAGE 'IBM01140' TO A-FIELD2 CODEPAGE 'IBM037'
Valid: The string in A-FIELD1 which is coded in IBM01140 is converted into
A-FIELD2 which is coded in IBM037.
MOVE ENCODED U-FIELD TO U-FIELD
Invalid: This results in an error, since at least one operand must be of format A or B.
MOVE ENCODED U-FIELD TO A-FIELD
Valid: The Unicode string in U-FIELD which, considered to be encoded in
UTF-16, is converted into the alphanumeric A-FIELD in the default code page
(*CODEPAGE).
MOVE ENCODED A-FIELD TO U-FIELD
Valid: The string in A-FIELD which, considered to be encoded in the default
code page (*CODEPAGE), is converted into the Unicode
field U-FIELD.
MOVE ENCODED A100-FIELD CODEPAGE 'IBM1140' TO A50-FIELD CODEPAGE 'IBM037'
Valid: Conversion is done from A100-FIELD (format/length: A100) to
A50-FIELD (format/length: A50), using the relevant code pages. The target
is truncated. No Natural error message is returned.
MOVE ENCODED A100-FIELD CODEPAGE 'IBM1140' TO A50-FIELD CODEPAGE 'IBM037' GIVING RC-FIELD
Valid: Conversion is done from A100-FIELD (format/length: A100) to
A50-FIELD (format/length: A50), using the relevant code pages. The target
is truncated. Since a GIVING clause is supplied, the RC-FIELD
receives an error code, indicating that a value truncation has taken place.
The MOVE ALL statement enables you to move repeatedly the content of
operand1 to
operand2 until the complete target field is
full or the UNTIL value (operand7)
is reached.
Using a SUBSTRING
Clause, you may limit the MOVE ALL operation to just segments
of the source and target field.
Syntax Diagram:
MOVE |
ALL |
|
|
|||
TO |
|
|
||||
[UNTIL
operand7]
|
||||||
Operand Definition Table:
| Operand | Possible Structure | Possible Formats | Referencing Permitted | Dynamic Definition | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
operand1
|
C | S | A | A | U | N1 | B | yes | no | |||||||||||
operand2
|
S | A | A | U | B | yes | yes | |||||||||||||
operand3
|
C | S | N | P | I | B2 | yes | no | ||||||||||||
operand4
|
C | S | N | P | I | B2 | yes | no | ||||||||||||
operand5
|
C | S | N | P | I | B2 | yes | no | ||||||||||||
operand6
|
C | S | N | P | I | B2 | yes | no | ||||||||||||
operand7
|
C | S | N | P | I | yes | no | |||||||||||||
1 A numeric format (N) for operand1
is permitted only when used without the SUBSTRING clause.
2 If
operand3/operand5
or
operand4/operand6
is a binary variable, it may be used only with a length of less than or equal to 4.
Syntax Element Description:
| Syntax Element | Description | ||
|---|---|---|---|
operand1
|
Source Operand:
The source operand contains the value to be moved. All digits of a numeric operand including leading zeros are moved. |
||
TO
operand2
|
Target Operand:
The target operand is not reset before the execution of the |
||
UNTIL
operand7
|
UNTIL Option:
The If The For general information on dynamic variables, see Usage of Dynamic Variables. Note |
||
SUBSTRING |
SUBSTRING Clause:
The
If If
See also Examples of SUBSTRING Clause Usage below. |
||
DEFINE DATA LOCAL 1 ALFA (A10) INIT <'AAAAAAAAAA'> 1 DYN (A) DYNAMIC INIT <'1234567890'> 1 #VAL (A4) INIT <'1234'> END-DEFINE
|
Statement
|
Result
|
|
|
Before
|
After
|
|
MOVE ALL SUBSTRING (#VAL,1,2) TO ALFA |
AAAAAAAAAA |
1212121212 |
MOVE ALL '123' TO SUBSTRING (ALFA,3,5) |
AAAAAAAAAA |
AA12312AAA |
MOVE ALL 'x' TO SUBSTRING (DYN,7,3) |
1234567890
(*LENGTH=10)
|
123456xxx0
(*LENGTH=10)
|
MOVE ALL 'xyz' TO SUBSTRING (DYN,7,6) |
1234567890
(*LENGTH=10)
|
123456xyzxyz
(*LENGTH=12)
|
MOVE ALL 'xyz' TO SUBSTRING (DYN,11,4) |
1234567890
(*LENGTH=10)
|
1234567890xyzx
(*LENGTH=14)
|
** Example 'MOVEX1': MOVE ************************************************************************ DEFINE DATA LOCAL 1 #A (N3) 1 #B (A5) 1 #C (A2) 1 #D (A7) 1 #E (N1.0) 1 #F (A5) 1 #G (N3.2) 1 #H (A6) END-DEFINE * MOVE 5 TO #A WRITE NOTITLE 'MOVE 5 TO #A' 30X '=' #A * MOVE 'ABCDE' TO #B #C #D WRITE 'MOVE ABCDE TO #B #C #D' 20X '=' #B '=' #C '=' #D * MOVE -1 TO #E WRITE 'MOVE -1 TO #E' 28X '=' #E * MOVE ROUNDED 1.995 TO #E WRITE 'MOVE ROUNDED 1.995 TO #E' 18X '=' #E * * MOVE RIGHT JUSTIFIED 'ABC' TO #F WRITE 'MOVE RIGHT JUSTIFIED ''ABC'' TO #F' 10X '=' #F * MOVE EDITED '003.45' TO #G (EM=999.99) WRITE 'MOVE EDITED ''003.45'' TO #G (EM=999.99)' 4X '=' #G * MOVE EDITED 123.45 (EM=999.99) TO #H WRITE 'MOVE EDITED 123.45 (EM=999.99) TO #H' 6X '=' #H * END
MOVE 5 TO #A #A: 5 MOVE ABCDE TO #B #C #D #B: ABCDE #C: AB #D: ABCDE MOVE -1 TO #E #E: -1 MOVE ROUNDED 1.995 TO #E #E: 2 MOVE RIGHT JUSTIFIED 'ABC' TO #F #F: ABC MOVE EDITED '003.45' TO #G (EM=999.99) #G: 3.45 MOVE EDITED 123.45 (EM=999.99) TO #H #H: 123.45
** Example 'MOVEX2': MOVE BY NAME
************************************************************************
DEFINE DATA LOCAL
1 #SBLOCK
2 #FIELDA (A10) INIT <'AAAAAAAAAA'>
2 #FIELDB (A10) INIT <'BBBBBBBBBB'>
2 #FIELDC (A10) INIT <'CCCCCCCCCC'>
2 #FIELDD (A10) INIT <'DDDDDDDDDD'>
1 #TBLOCK
2 #FIELD1 (A15) INIT <' '>
2 #FIELDA (A10) INIT <' '>
2 #FIELD2 (A10) INIT <' '>
2 #FIELDB (A10) INIT <' '>
2 #FIELD3 (A20) INIT <' '>
2 #FIELDC (A10) INIT <' '>
END-DEFINE
*
MOVE BY NAME #SBLOCK TO #TBLOCK
*
WRITE NOTITLE 'CONTENTS OF #TBLOCK AFTER MOVE BY NAME:'
// '=' #TBLOCK.#FIELD1
/ '=' #TBLOCK.#FIELDA
/ '=' #TBLOCK.#FIELD2
/ '=' #TBLOCK.#FIELDB
/ '=' #TBLOCK.#FIELD3
/ '=' #TBLOCK.#FIELDC
*
END
CONTENTS OF #TBLOCK AFTER MOVE BY NAME:
#FIELD1:
#FIELDA: AAAAAAAAAA
#FIELD2:
#FIELDB: BBBBBBBBBB
#FIELD3:
#FIELDC: CCCCCCCCCC
DEFINE DATA LOCAL
1 #GROUP1
2 #FIELD (A10/1:10)
1 #GROUP2
2 #FIELD (A10/1:10)
END-DEFINE
...
MOVE BY NAME #GROUP1 TO #GROUP2
...
In this example, the MOVE statement would internally be resolved as:
MOVE #GROUP1.#FIELD (*) TO #GROUP2.#FIELD (*)
If part of an indexed group is moved to another part of the same group, this may lead to unexpected results as shown in the example below.
DEFINE DATA LOCAL
1 #GROUP1 (1:5)
2 #FIELDA (N1) INIT <1,2,3,4,5>
2 REDEFINE #FIELDA
3 #FIELDB (N1)
END-DEFINE
...
MOVE BY NAME #GROUP1 (2:4) TO #GROUP1 (1:3)
...
In this example, the MOVE statement would internally be resolved as:
MOVE #FIELDA (2:4) TO #FIELDA (1:3) MOVE #FIELDB (2:4) TO #FIELDB (1:3)
First, the contents of the occurrences 2 to 4 of #FIELDA are moved to the
occurrences 1 to 3 of #FIELDA; that is, the occurrences receive the
following values:
| Occurrence: | 1. | 2. | 3. | 4. | 5. |
| Value before: | 1 | 2 | 3 | 4 | 5 |
| Value after: | 2 | 3 | 4 | 4 | 5 |
Then the contents of the occurrences 2 to 4 of #FIELDB are moved to the
occurrences 1 to 3 of #FIELDB; that is, the occurrences receive the
following values:
| Occurrence: | 1. | 2. | 3. | 4. | 5. |
| Value before: | 2 | 3 | 4 | 4 | 5 |
| Value after: | 3 | 4 | 4 | 4 | 5 |
DEFINE DATA LOCAL
1 #GROUP1
2 #FIELD1A (N5)
2 #FIELD1B (A3/1:3)
2 REDEFINE #FIELD1B
3 #FIELD1BR (A9)
1 #GROUP2
2 #FIELD2A (N5)
2 #FIELD2B (A3/1:3)
2 REDEFINE #FIELD2B
3 #FIELD2BR (A9)
END-DEFINE
...
MOVE BY POSITION #GROUP1 TO #GROUP2
...
In this example, the content of #FIELD1A is moved to
#FIELD2A, and the content of #FIELD1B to
#FIELD2B; the fields #FIELD1BR and #FIELD2BR are
not affected.
** Example 'MOAEX1': MOVE ALL
************************************************************************
DEFINE DATA LOCAL
1 EMPLOY-VIEW VIEW OF EMPLOYEES
2 PERSONNEL-ID
2 FIRST-NAME
2 NAME
2 CITY
1 VEH-VIEW VIEW OF VEHICLES
2 PERSONNEL-ID
2 MAKE
END-DEFINE
*
LIMIT 4
RD. READ EMPLOY-VIEW BY NAME
SUSPEND IDENTICAL SUPPRESS
/*
FD. FIND VEH-VIEW WITH PERSONNEL-ID = PERSONNEL-ID (RD.)
IF NO RECORDS FOUND
MOVE ALL '*' TO FIRST-NAME (RD.)
MOVE ALL '*' TO CITY (RD.)
MOVE ALL '*' TO MAKE (FD.)
END-NOREC
/*
DISPLAY NOTITLE (ES=OFF IS=ON ZP=ON AL=15)
NAME (RD.) FIRST-NAME (RD.)
CITY (RD.)
MAKE (FD.) (IS=OFF)
/*
END-FIND
END-READ
END
NAME FIRST-NAME CITY MAKE
--------------- --------------- --------------- ---------------
ABELLAN *************** *************** ***************
ACHIESON ROBERT DERBY FORD
ADAM *************** *************** ***************
ADKINSON JEFF BROOKLYN GENERAL MOTORS
** Example 'MOVEX3': MOVE EDITED with EM and extra characters
************************************************************************
DEFINE DATA LOCAL
1 #NUM (N3.2)
1 #A5 (A5)
1 #A8 (A8)
1 #A10 (A10)
1 #A12 (A12)
END-DEFINE
*
* MOVE EDITED operand1 (EM=value) TO operand2
*
* The Edit mask will be applied for operand1 and the result is moved
* to operand2. The created string is described by the edit mask
* where also extra characters can be included.
*
* This is similar to the statement 'WRITE operand (EM=value)'.
*
*
#NUM := 23.45
MOVE EDITED #NUM (EM=Z99.99+) TO #A8
WRITE 'MOVE 23.45 TO #NUM'
WRITE 'MOVE EDITED #NUM (EM=Z99.99+) TO #A8' 15X '=' #A8 /
*
* Show leading zero with filler 'x' defined as first character in EM.
*
#NUM := -78.15
MOVE EDITED #NUM (EM=xFULL-Z99.99) TO #A12
WRITE 'MOVE -78.15 TO #NUM'
WRITE 'MOVE EDITED #NUM (EM=xFULL-Z99.99) TO #A12' 9X '=' #A12 //
*
* Show leading blank with filler '.' defined as first character in EM.
* If extra character is equal to edit mask characters, then enclose
* it within apostrophes.
*
MOVE ' AB ' TO #A5
MOVE EDITED #A5 (EM=.GOXXXXXE'X'TRA) TO #A12
WRITE 'MOVE '' AB '' TO #A5'
WRITE 'MOVE EDITED #A5 (EM=.GOXXXXXE''X''TRA) TO #A12' 7X '=' #A12 /
*
* Similar handling for WRITE statement with edit mask.
*
WRITE 'WRITE #A5 (EM=.GOXXXXXNATURAL)' 21X '#A5: '
#A5 (EM=.GOXXXXXNATURAL) //
*
*
* MOVE EDITED operand1 TO operand2 (EM=value)
*
* The value of operand1 will be placed into operand2 using the
* edit mask. The edit mask specifies at which positions the contents
* of operand1 should be used for operand2.
* Extra characters in operand1 must be specified in the edit mask
* to be ignored (in operand2).
*
*
#A8 := '+12.40'
MOVE EDITED #A8 TO #NUM (EM=SZ9.99)
WRITE 'MOVE EDITED ''+12.40'' TO #NUM (EM=SZ9.99)' 6X '=' #NUM
*
* Ignore extra characters of operand1.
*
#A10:= '-12.40EUR'
MOVE EDITED #A10 TO #NUM (EM=-Z9.99EUR)
WRITE 'MOVE EDITED ''-12.40EUR'' TO #NUM (EM=-Z9.99EUR)' 3X '=' #NUM
*
* Use filler '*' for leading zero and define the filler as first
* character in EM.
*
#A10 := 'EUR*12.40-'
MOVE EDITED #A10 TO #NUM (EM=*EURZZ9.99-)
WRITE 'MOVE EDITED ''EUR*12.40-'' TO #NUM (EM=*EURZZ9.99-)'
'=' #NUM /
*
* Ignore extra characters of operand1 and, if needed, enclose them
* within apostrophes.
*
MOVE EDITED 'HE4711L-ALOX WO5R-7LD' TO
#A12 (EM=XX4711X-AXX'X'XXX5X-7XX)
WRITE 'MOVE EDITED ''HE4711L-ALOX WO5R-7LD'' TO'
'#A12 (EM=XX4711X-AXX''X''XXX5X-7XX)'
WRITE 51X '=' #A12 /
*
*
END
MOVE 23.45 TO #NUM
MOVE EDITED #NUM (EM=Z99.99+) TO #A8 #A8: 23.45+
MOVE -78.15 TO #NUM
MOVE EDITED #NUM (EM=xFULL-Z99.99) TO #A12 #A12: FULL-x78.15
MOVE ' AB ' TO #A5
MOVE EDITED #A5 (EM=.GOXXXXXE'X'TRA) TO #A12 #A12: GO..AB EXTRA
WRITE #A5 (EM=.GOXXXXXNATURAL) #A5: GO..AB NATURAL
MOVE EDITED '+12.40' TO #NUM (EM=SZ9.99) #NUM: 12.40
MOVE EDITED '-12.40EUR' TO #NUM (EM=-Z9.99EUR) #NUM: -12.40
MOVE EDITED 'EUR*12.40-' TO #NUM (EM=*EURZZ9.99-) #NUM: -12.40
MOVE EDITED 'HE4711L-ALOX WO5R-7LD' TO #A12 (EM=XX4711X-AXX'X'XXX5X-7XX)
#A12: HELLO WORLD
** Example 'MOVEX4': MOVE EDITED with EM and wildcard character '?'
************************************************************************
DEFINE DATA LOCAL
1 #NUM (N3.2)
1 #NUM2 (N5)
1 #A10 (A10)
1 #A14 (A14)
1 #B4 (B4)
1 #DATE (D)
1 #TIME (T)
END-DEFINE
*
* MOVE EDITED operand1 TO operand2 (EM=value)
*
* The value of operand1 will be placed into operand2 using the
* edit mask. The edit mask specifies at which positions the contents
* of operand1 should be used for operand2.
* Extra characters in operand1 must be specified in the edit mask
* to be ignored (in operand2).
* Or use the wildcard character '?' instead of any extra character
* which fits all values and much easier to define.
*
*
* Numeric edit mask with extra characters or wildcard character
*
#A10 := '-12.40EUR'
MOVE EDITED #A10 TO #NUM (EM=-Z9.99EUR)
WRITE 'MOVE EDITED ''-12.40EUR'' TO #NUM (EM=-Z9.99EUR)' 9X '=' #NUM
*
#A10 := '-12.40EUR'
MOVE EDITED #A10 TO #NUM (EM=-Z9.99???)
WRITE 'MOVE EDITED ''-12.40EUR'' TO #NUM (EM=-Z9.99???)' 9X '=' #NUM //
*
* Filler '*' is required if started with extra or wildcard character
*
#A10 := 'EUR*5.33-'
MOVE EDITED #A10 TO #NUM (EM=*EURZZ9.99-)
WRITE 'MOVE EDITED ''EUR*5.33-'' TO #NUM (EM=*EURZZ9.99-)' 8X
'=' #NUM
*
#A10 := 'EUR*5.33-'
MOVE EDITED #A10 TO #NUM (EM=*???ZZ9.99-)
WRITE 'MOVE EDITED ''EUR*5.33-'' TO #NUM (EM=*???ZZ9.99-)' 8X
'=' #NUM //
*
*
#A10 := 'ABC987CDEF'
MOVE EDITED #A10 TO #NUM2 (EM=*'ABC'999'CDEF')
WRITE 'MOVE EDITED ''ABC987CDEF'' TO #NUM2 (EM=*''ABC''999''CDEF'')' 2X
'=' #NUM2
*
#A10 := 'ABC987CDEF'
MOVE EDITED #A10 TO #NUM2 (EM=*???999????)
WRITE 'MOVE EDITED ''ABC987CDEF'' TO #NUM2 (EM=*???999????)' 6X
'=' #NUM2 //
*
*
* Alphanumeric edit mask with extra characters or wildcard character
*
MOVE EDITED 'NATURAL-VERSION-9.2' TO
#A10 (EM=XXXURAL-XXXXION-X.X)
WRITE 'MOVE EDITED ''NATURAL-VERSION-9.2'' TO '-
'#A10 (EM=XXXURAL-XXXXION-X.X)'
WRITE 56X '=' #A10
*
MOVE EDITED 'NATURAL-VERSION-9.2' TO
#A10 (EM=XXX?????XXXX????X?X)
WRITE 'MOVE EDITED ''NATURAL-VERSION-9.2'' TO '-
'#A10 (EM=XXX?????XXXX????X?X)'
WRITE 56X '=' #A10 /
*
* Filler '*' is required if started with extra or wildcard character
*
MOVE EDITED 'VENUS-SATURN-GALAXY 2050+' TO
#A14 (EM=*VEXUS-SXXXXN-GXXA'X'YXXXXXX)
WRITE 'MOVE EDITED ''VENUS-SATURN-GALAXY 2050+'' TO'
WRITE 3X '#A14 (EM=*VEXUS-SXXXXN-GXXA''X''YXXXXXX)'
15X '=' #A14
*
MOVE EDITED 'VENUS-SATURN-GALAXY 2050+' TO
#A14 (EM=*??X????XXXX???XX???XXXXXX)
WRITE 'MOVE EDITED ''VENUS-SATURN-GALAXY 2050+'' TO '
WRITE 3X '#A14 (EM=*??X????XXXX???XX???XXXXXX)'
17X '=' #A14
*
*
NEWPAGE
*
*
* Hexadecimal edit mask with extra characters or wildcard character
*
MOVE EDITED 'C1/C2 C3-C4' TO #B4 (EM=H/H' 'H-H)
WRITE 'MOVE EDITED ''C1/C2 C3-C4'' TO '-
'#B4 (EM=H/H'' ''H-H)' 8X '=' #B4
*
MOVE EDITED 'C1/C2 C3-C4' TO #B4 (EM=H?H?H?H)
WRITE 'MOVE EDITED ''C1/C2 C3-C4'' TO '-
'#B4 (EM=H?H?H?H)' 10X '=' #B4 //
*
* Date and time edit mask with extra characters or wildcard character
*
MOVE EDITED 'DATE-07/10/2026-CREATED' TO
#DATE (EM='DATE-'DD/MM/YYYY'-CREATED')
WRITE 'MOVE EDITED ''DATE-07/10/2026-CREATED'' TO '-
'#DATE (EM=''DATE-''DD/MM/YYYY''-CREATED'')'
WRITE '=' #DATE (EM=YYYY-LLL-DD)
6X '/* date shown with EM=(YYYY-LLL-DD)'/
*
MOVE EDITED 'DATE-07/10/2026-CREATED' TO
#DATE (EM=?????DD/MM/YYYY????????)
WRITE 'MOVE EDITED ''DATE-07/10/2026-CREATED'' TO '-
'#DATE (EM=?????DD/MM/YYYY????????)'
WRITE '=' #DATE (EM=YYYY-LLL-DD)
6X '/* date shown with EM=(YYYY-LLL-DD)'//
*
*
MOVE EDITED 'RUN-TIME-17.37.45' TO #TIME (EM='RUN-TIME-'HH.II.SS)
WRITE 'MOVE EDITED ''RUN-TIME-17.37.45'' TO '-
'#TIME (EM=''RUN-TIME-''HH.II.SS)'
WRITE '=' #TIME (EM=HH:II:SS)
9X '/* time shown with EM=(HH:II:SS)'/
*
MOVE EDITED 'RUN-TIME-17.37.45' TO #TIME (EM=?????????HH.II.SS)
WRITE 'MOVE EDITED ''RUN-TIME-17.37.45'' TO '-
'#TIME (EM=?????????HH.II.SS)'
WRITE '=' #TIME (EM=HH:II:SS)
9X '/* time shown with EM=(HH:II:SS)'//
*
*
END
MOVE EDITED '-12.40EUR' TO #NUM (EM=-Z9.99EUR) #NUM: -12.40
MOVE EDITED '-12.40EUR' TO #NUM (EM=-Z9.99???) #NUM: -12.40
MOVE EDITED 'EUR*5.33-' TO #NUM (EM=*EURZZ9.99-) #NUM: -5.33
MOVE EDITED 'EUR*5.33-' TO #NUM (EM=*???ZZ9.99-) #NUM: -5.33
MOVE EDITED 'ABC987CDEF' TO #NUM2 (EM=*'ABC'999'CDEF') #NUM2: 987
MOVE EDITED 'ABC987CDEF' TO #NUM2 (EM=*???999????) #NUM2: 987
MOVE EDITED 'NATURAL-VERSION-9.2' TO #A10 (EM=XXXURAL-XXXXION-X.X)
#A10: NATVERS92
MOVE EDITED 'NATURAL-VERSION-9.2' TO #A10 (EM=XXX?????XXXX????X?X)
#A10: NATVERS92
MOVE EDITED 'VENUS-SATURN-GALAXY 2050+' TO
#A14 (EM=*VEXUS-SXXXXN-GXXA'X'YXXXXXX) #A14: NATURAL 2050+
MOVE EDITED 'VENUS-SATURN-GALAXY 2050+' TO
#A14 (EM=*??X????XXXX???XX???XXXXXX) #A14: NATURAL 2050+
MOVE EDITED 'C1/C2 C3-C4' TO #B4 (EM=H/H' 'H-H) #B4: C1C2C3C4
MOVE EDITED 'C1/C2 C3-C4' TO #B4 (EM=H?H?H?H) #B4: C1C2C3C4
MOVE EDITED 'DATE-07/10/2026-CREATED' TO #DATE (EM='DATE-'DD/MM/YYYY'-CREATED')
#DATE: 2026-Oct-07 /* date shown with EM=(YYYY-LLL-DD)
MOVE EDITED 'DATE-07/10/2026-CREATED' TO #DATE (EM=?????DD/MM/YYYY????????)
#DATE: 2026-Oct-07 /* date shown with EM=(YYYY-LLL-DD)
MOVE EDITED 'RUN-TIME-17.37.45' TO #TIME (EM='RUN-TIME-'HH.II.SS)
#TIME: 17:37:45 /* time shown with EM=(HH:II:SS)
MOVE EDITED 'RUN-TIME-17.37.45' TO #TIME (EM=?????????HH.II.SS)
#TIME: 17:37:45 /* time shown with EM=(HH:II:SS)