bdfs1m1i | Structured Programming Macros |
Use this macro to assign values to symbols declared with the DCL macro. Symbols can be assigned arithmetic, string, or bit values. These symbols can be used in other structured programming macro (SPM) or in mainline code.
Format
|
LET NUM,=,4
LET PART1,=,C'ABC' LET PART2,=,C'123' LET WHOLE,=,PART1,||,PART2
In this example, WHOLE will have the value C'ABC123'.
C'12345',OFFSET,3
resolves to a substring of C'45'.
See the restrictions listed in the programming considerations.
C'12345',LENGTH,4
resolves to a substring of C'1234'.
See the restrictions listed in the programming considerations.
See the restrictions listed in the programming considerations.
LET SYMB,=,C'ABC' LET SYMB,MASK,B'00101000',=,1
In this example, the symbol SYMB will contain the value ZBC. This is determined as follows:
EBCDIC A: B'1100 0001' mask on: B'0010 1000' set to ones: ------------ results in: B'1110 1001' or EBCDIC Z
Entry Requirements
None.
Return Conditions
Programming Considerations
* Declare a full word, signed integer called TEST TEST EQU EBW000,4 Reentrant for TEST DS F DCL TEST,SIGNED,4 * * Assign variable TEST the decimal value 255 LET TEST,=,255
* Declare a several arithmetic variables * SUMM EQU EBW000,4 Reentrant for SUMM DS F DCL SUMM,SIGNED,4 MULT EQU EBW004,4 Reentrant for MULT DS F DCL MULT,SIGNED,4 ANSWER EQU EBW008,4 Reentrant for ANSWER DS F DCL ANSWER,SIGNED,4 : * Assign arithmetic values LET SUMM,=,2,+,4,+,6 LET MULT,=,4,*,3 * LET ANSWER,=,SUMM,/,MULT
* Declare a string 80 bytes long called OUT OUT EQU EBW000,80 Reentrant for OUT DS CL80 DCL OUT,CHARACTER,80 : * Declare a string 20 bytes long called NAME NAME EQU EBX000,20 Reentrant for NAME DS CL20 DCL NAME,CHARACTER,20 : * Declare a string 40 bytes long called ADDRESS ADDRESS EQU EBX020,40 Reentrant for ADDRESS DS CL40 DCL ADDRESS,CHARACTER,40 : * Declare a string 20 bytes long called PHONE PHONE EQU EBX060,20 Reentrant for PHONE DS CL20 DCL PHONE,CHARACTER,20 : * Assign variable NAME a constant string value LET NAME,=,C'Robert Cohen',PAD,' ' : * Assign variable ADDRESS a constant string value LET ADDRESS,=,C'40 Apple Ridge Road $ Danbury, Ct 06810' : * Assign variable PHONE a constant string value LET PHONE,=,C' (203) 790-2000',PAD,' ' : * Assign variable OUT the concatenations of NAME, ADDRESS, and PHONE LET OUT,=,NAME,||,ADDRESS,||,PHONE
* Declare some strings PART1 EQU EBW000,5 Reentrant for PART1 DS CL5 PART2 EQU EBW005,5 Reentrant for PART2 DS CL5 MIDL EQU EBW010,20 Reentrant for MIDL DS CL20 WHOLE EQU EBX000,40 Reentrant for WHOLE DS CL40 : DCL PART1,CHARACTER,5 DCL PART2,CHARACTER,5 DCL MIDL,CHARACTER,20 DCL WHOLE,CHARACTER,40 : * Assign variable WHOLE a constant string of 40 characters LET WHOLE,=,C'ABCDEFGHIJ1234567890KLMNOPQRST0987654321' : * Assign variable PART1 the first five characters of WHOLE LET PART1,=,WHOLE,LENGTH,5 * PART1 is 'ABCDE' : * Assign variable PART2 the last five characters of WHOLE LET PART2,=,WHOLE,OFFSET,35 * PART2 is '54321' : * Assign variable MIDL 10 characters from WHOLE starting 15 characters * from the beginning of WHOLE. Pad MIDL with blanks LET MIDL,=,WHOLE,OFFSET,15,LENGTH,10,PAD,' ' * MIDL is '67890KLMNObbbbbbbbbb' where 'b' represents a 'blank'
TEST DS B DCL TEST,CHARACTER,1 LET TEST,MASK,B'11110000',=,1
In this example, the symbol INDX is declared as an unsigned variable and the string variable STR is initialed as THIS IS A TEST with a length of 14. The DO loop initializes the value of INDX to be 1. The LET assignment in the DO loop is coded in an IF structure to ensure that the byte specified by the value of INDX is not blank. When not blank, the LET assignment takes the value of string STR, offsets the byte specified by the value of INDX, and casts a mask over that byte. The mask isolates the high-order bit of the byte that is being specified. The bit is assigned value 0. The remaining bits of the byte are unaffected (because the mask has zeros in their places). The original value of string STR is changed by this byte change. The value of INDX is incremented by 1 at the top of the DO loop, and the loop proceeds with INDX being 2, 3, until 14. Each value of INDX specifies a different byte in string STR.
DCL INDX,UNSIGNED DCL STR,CHARACTER,14 : LET STR,=,C'THIS IS A TEST' DO INDX,=,1,TO,14 IF STR,OFFSET,INDX,NE,C' ' THEN LET STR,OFFSET,INDX,MASK,B'10000000',=,0 ENDIF ENDDO
Related Macros