THE MOVE STATEMENT
MOVING DATA, PRINTING INFORMATION, AND DISPLAYING OUTPUT
INTERACTIVELY
. THE MOVE STATEMENT
. RULES FOR MOVING FIELDS AND LITERALS
. EDITING
. DESIGNING AND PRINTING REPORTS
START WITH THE WRITE...FROM STATEMENT
THEN, WILL RETURN TO FRONT OF CHAPTER...
THE ADVANCING OPTION FOR SPACING FORMS...
SYNTAX:
WRITE record-name-1 [ FROM identifier-1 ]
AFTERinteger-1 LINE
ADVANCING
BEFOREidentifier-2 LINES
. DISCUSS THE SYNTAX...
. DISCUSS ABEFORE@ ADVANCING AND AAFTER ADVANCING@
. DISCUSS OVERPRINTING
1
WRITE...AFTER ADVANCING AND
WRITE...BEFORE DVANCING SHOULD BE AVOIDED IN
PROGRAMS. (that is, both in same program)
CAUSES PROBLEMS AND CONFUSION AND, IN GENERAL,
ERRONEOUS PRINTING....
CAN AOVERPRINT@ WITH AN AUNDERLINE@ OR ABOLD@ VIA:
WRITE .... AFTER ADVANCING FOLLOWED BY
WRITE.... BEFORE ADVANCING.
ORWRITE ... AFTER ADVANCING .... FOLLOWED BY
WRITE...AFTER ADVANCING 0 LINES.
THIS IS PREFERRED.
DEFAULT: WRITE....BEFORE ADVANCING 1 LINE
IF SINGLE SPACING IS SUFFICIENT,
THEN NO AADVANCING@ IS NEEDED
WRITE PRINTREC
ADVANCING TO A NEW PAGE.
CONSIDER AN EXTENSION TO THE BASIC WRITE...
WRITE record-name-1 [ FROM identifier-1 ]
AFTERPAGE LINE
ADVANCING integer-1
BEFOREidentifier-2 LINES
CAN NOW SAY:
WRITE PRINT-REC FROM HEADER-1 AFTER ADVANCING PAGE.
1
TYPICALLY, IN A REPORT: WE WILL WRITE PAGE HEADERS ALL AT ONCE, AS IN A SPECIFIC PARAGRAPH:
WRITE PRINT-REC FROM HEADER-1 AFTER ADVANCING PAGE.
WRITE PRINT-REC FROM HEADER-2 AFTER ADVANCING 2 LINES
<and more....>
OTHER WAYS: OLDER PROGRAMS
ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
SOURCE-COMPUTER.
OBJECT-COMPUTER.
SPECIAL-NAMES. C01 IS PAGE-TOP.
<mnemonic-name>
EQUATES CHANNEL 1 (C01) TO APAGE-TOP@
EXPLAIN CHANNELS ON CONTINUOUS LINE PRINTER FORMS....
WRITE PRINT-REC FROM HEADER-1 AFTER ADVANCING PAGE-TOP.
<other channels?: CH 9 = SECURITY; CH12 FOR PAGE BOTTOM...>
1
PROGRAMMED LINE COUNTER.
. OBJECTIVE: KEEP TRACK OF WHERE THE PRINTING IS ON THE PAGE...
. LINE PRINTER: 11 IN; 6 LINES/INCH => 66 LINES PER PAGE.
.. ALLOWING FOR TOP/BOTTOM, => 54 LINES OF PRINT.
.. MUST ALLOW FOR
... HEADERS (MAY BE SEVERAL)
... TRAILERS
... SPECIAL LINES SUCH AS FOR REPORT STATS.
.. AND THEN DETAIL LINES....
LASER PRINTERS / INK-JET – LEARN WHAT YOU CAN PRINT ON
EACH PAGE – GIVEN FONTS / FONT FACES, ETC….
ESTABLISH A LINE COUNTER IN WORKING STORAGE.
GENERIC PROCEDURE:
WRITE A LINE
INCREMENT THE LINE COUNTER (AND TEST IT)
IF LINE COUNTER > LIMIT (~50 OR SO....)
PERFORM TRAILER ROUTINE
PERFORM HEADER ROUTINE
ELSE
PRESS ON
MOST REPORTS HAVE AFOOTERS@ OR ATRAILERS@ AT THE BOTTOM OF PAGES CONTAINING PAGE NUMBERS.
CONSIDER THE FOLLOWING CODE:
IN THE APRINT RECORDS@ PART OF WORKING-STORAGE
(SEE STANDARDS...)
01P-FOOTER.
05PIC X( ) VALUE SPACES.
05PF-END-INDICATORPIC X(3) VALUE SPACES.
05PIC X(2) VALUE SPACES.
05PIC X(8) VALUE APAGE NO A.
05PF-PAGE-CNTRPIC ZZ9.
05PIC X(… ) VALUE SPACES.
<will improve this format a few pages ahead....>
IN ACOUNTERS AND FLAGS@
05C-LINE-CNTRPIC 99VALUE 0.
0FF-EOFPIC 9VALUE 0.
05C-PAGE-CNTRPIC 99VALUE 0.
WOULD ALSO HAVE
. HEADER RECORD(S) (NORMALLY AT LEAST TWO....)
SHOULD BE IN WORKING STORAGE ALL SET UP.
. DETAIL LINES(COULD BE IN THE FILE SECTION)
CODE:
0000-MAIN-MODULE.
PERFORM 1000-INITIALIZATION <open files, set flags, accept date, etc....>
PERFORM 2000-READ-RECORD <not shown ahead>
IF F-EOF NOT EQUAL 1
PERFORM 3000-WRITE-HEADERS
END-IF
PERFORM 4000-CALCULATE-WORLD
UNTIL F-EOF=1
PERFORM 5000-TERMINATE
STOP RUN.
1
3000-WRITE-HEADERS.
WRITE PF-PRINT FROM P-HEADER1
AFTER ADVANCING PAGE
WRITE PF-PRINT FROM P-HEADER2
AFTER ADVANCING 2 LINES
MOVE SPACES TO PF-PRINT
MOVE 4 TO C-LINE-CNTR.<maybe MOVE 0 TO ....>
4000-CALCULATE-WORLD.
{ DO DETAIL LEVEL PROCESSING }
WRITE PF-PRINT FROM P-DETAIL-REC
AFTER ADVANCING 2 LINES<double spaces output...>
ADD 2 TO C-LINE-CNTR
IF C-LINE-CNTR > 50 <must experiment for number>
PERFORM 4200-WRITE-FOOTER
PERFORM 3000-WRITE-HEADERS
END-IF.
PERFORM 2000-READ-RECORD.
4200-WRITE-FOOTER.
ADD 1 TO C-PAGE-CNTR
MOVE C-PAGE-CNTR TO PF-PAGE-CNTR
IF F-EOF = 1
MOVE AEND@ TO PF-END-INDICATOR
END-IF
WRITE PF-PRINT FROM P-FOOTER AFTER ADVANCING 2 LINES.
5000-TERMINATE.
PERFORM 4200-WRITE-FOOTER
CLOSE { files }
MANY VARIATIONS ON THIS TYPE OF CODING...
. MAY USE ALINE-LIMIT@ VICE HARD-CODED A50" (BETTER....@
. MAY DOUBLE SPACE AND TEST C-LINE-CNTR FOR A25" VICE 50.
. MAY INCLUDE THE ADATE@ FROM MACHINE IN HEADER....
<DISCUSSED AHEAD>
1
MOVING DATA AND PRINTING INFORMATION
BASIC FORMAT:MOVE sending-field TO receiving-field
(verb)
. ACOPIES@ DOESN=T AMOVE@
. SENDING FIELD UNCHANGED ALWAYS!!
. HERE, MOVING ELEMENTARY ITEMS.
. RULE: PIC CLAUSE OF THE RECEIVING FIELD DETERMINES AHOW@ THE DATA IS MOVED AND AHOW MUCH@ DATA IS MOVED.
. VERY NICE WHEN SENDING AND RECEIVING FIELD SIZES ARE EQUAL. SIMPLE.
EXAMPLE:
MOVE TAX-INTO TAX-OUT
TAX-IN TAX-OUT
BEFORE: PIC 999 CONTENTS: 123 PIC 999 CONT: 444
AFTER: PIC 999 CONTENTS: 123 PIC 999 CONT: 123
1
GENERAL FORMATS:
identifier-1
MOVEliteral-1TO identifier-2
fig constant-1
. literal-1 CAN BE A NUMERIC LITERAL OR NON-NUMERIC LITERAL
. RECEIVING FIELD SHOULD BE OF SAME TYPE.
RECALL:
NUMERIC LITERALS: 1-18 DIGITS
MAY INCLUDE DECIMAL POINT
MAY INCLUDE OPTIONAL SIGN
NON-NUMERIC LITERALS: 1-160 CHARACTERS
ANY CHARACTERS EXCEPT A
EXAMPLES:
CONSIDER:01 SAMPLE-FIELDS
05 FIELD-1 PIC 999 VALUE 789.
05 FIELD-2 PIC XXX VALUE AXYZ@.
MOVE 123 TO FIELD-1=> FIELD-1 = 123
MOVE AABC@ TO FIELD-2=> FIELD-2 = ABC
HOW ABOUT:MOVE ABC TO FIELD-2
MOVE A123@ TO FIELD-2
MOVE AABC@ TO FIELD-1
MOVE 123 TO FIELD-2
1
RECEIVING FIELD ALWAYS NEEDS TO BE AN IDENTIFIER
DETERMINES TYPE OF MOVE:
ALPHANUMERIC
NUMERIC.
HOW MUCH IS MOVED - SIZE OF RECEIVING FIELDY
CAN ALSO MOVE FIGURATIVE CONSTANTS
SPACES, ZEROES, OTHERSY..
ZEROES IS A VALID NUMERIC AND ALPHANUMERIC CHARACTER.
THUS, CAN MOVE ZEROES TO EITHER TYPE FIELD.
SPACES IS AN INVALID NUMERIC CHARACTER.
THUS CANNOT SAY
MOVE SPACES TO FIELD-1 IF FIELD-1 IS NUMERIC
NUMERIC MOVE
. BASICALLY TWO KINDS OF MOVES:
. NUMERIC AND ALPHANUMERIC.
. FIELDS SAME SIZE? MOVE IS TRIVIAL.
RULES FOR NUMERIC MOVE:
CHARACTERS ARE MOVED FORM THE SENDING FIELD TO THE RECEIVING FIELD RIGHT TO LEFT, RIGHT JUSTIFIED, ZERO FILLED OR TRUNCATED TO THE LEFT.
CONSIDER: GIVEN: FIELD1 IS PIC 999.
MOVE 123 TO FIELD-1. FIELD-1 AFTER: 123
MOVE 1 TO FIELD-1 FIELD-1 AFTER: 001
MOVE 14 TO FIELD-1 FIELD-1 AFTER: 014
MOVE 1234 TO FIELD-1 FIELD-1 AFTER: 234.
REMEMBER: SENDING FIELD IS NEVER AFFECTED BY MOVE
1
MOVING DECIMAL PORTIONS OF NUMERIC FIELDY
RULE: MOVEMENT OF CHARACTERS IS FROM LEFT TO RIGHT, ZERO-FILLED ON THE RIGHT OR TRUNCATED ON THE RIGHT.
GIVEN:
F1 PIC V999VALUE .456.
F2 PICV99VALUE .12.
F3 PICV99999VALUE .84629.
F4PICV999VALUE .567.
MOVE F4 TO F1CONTENTS: ______
MOVE F2 TO F1CONTENTS: ______
MOVE F3 TO F1CONTENTS: ______
MOVE F2 TO F3 CONTENTS: ______
IF BOTH INTEGER AND DECIMAL PORTIONS ARE INVOLVED, MOVE EACH AS A SEPARATE MOVE:
SO, MOVING 99V99 VALUE 12.34 TO:
999V999 YIELDS: ______
9V9YIELDS: ______
9V999YIELDS: ______
NUMERIC LITERALS ARE EXACTLY THE SAMEY
MOVE 12.34 TO FIELD-2, WHERE FIELD-2 IS PIC 9V9 =>
FIELD-2 = 999V9YIELDS ______
FIELD-2 = 99YIELDS ______
FIELD-2 = V999YIELDS ______
THESE MOVES ARE NOT ILLEGAL.
NO COMPILER MESSAGES.
1
NON-NUMERIC (OR ALPHANUMERIC) MOVE
RECALL: PIC CLAUSE OF RECEIVING FIELD DETERMINES TYPE OF MOVEY AND HOW MUCH IS MOVEDY.
ALPHANUMERIC MOVES, THEN, HAVE PIC XXX RECEIVING CLAUSES.
CAN MOVE ANYTHING TO A PIC XXX FIELD.
RULE: MOVEMENT IS LEFT TO RIGHT, LEFT JUSTIFIED, SPACE-FILLED OR TRUNCATION ON THE RIGHT.
CAN SEND:
. NUMERIC FIELDS
. NUMERIC LITERALS
. NON-NUMERIC LITERALS
. ALPHANUMERIC FIELDS
. ALPHABETIC FIELDS
. FIGURATIVE CONSTANTSY.TO ALPHANUMERIC FIELDS.
EX: 01 ALPHANUMERIC-FIELDS.
05 F1PIC X VALUE AA@.
05 F2PIC XXX VALUE ABC@.
05 F3PIC XXX VALUE ADEF@.
05 F4PIC XXXX VALUE AGHIJ@.
05 F5.
10F51PIC 99 VALUE 0.
10 F52PIC 9V9 VALUE 12.
10F53PIC 99V99 VALUE 4.256.
FIRST: CHECK OUT RESULTS OF PIC CLAUSESYY.
EXAMPLES:
MOVE F1 TO F2______
MOVE F2 TO F1 ______
MOVE F4 TO F2 ______
MOVE AABC@ TO F2______
MOVE AABC@ TO F4 ______
MOVE F51 TO F2______
MOVE F52 TO F3______
MOVE F1 TO F51______
MOVE 123 TO F4______
MOVE A123@ TO F4______
MOVE 0 TO F5______
MOVE SPACES TO F5______
MOVE SPACES TO F51______
1
AGROUP@ MOVES
RECALL: PIC CLAUSE OF RECEIVING FIELD DETERMINES ALLY.
GROUP MOVE => RECEIVING FIELD IS A GROUP ITEM - NOT AN ELEMENTARY ITEM.
MOVE IS AALPHANUMERIC@ REGARDLESS
OF SUBORDINATE FIELDS AND
THEIR TYPES!!
MOVE F3 TO F5
F3 IS: PIC XXX VALUE ADEF@.
F5 IS A GROUP ITEM AND CONTAINS:
0 0 2 0 0 4 2 5 FROM ITS ELEMENTARY ITEMS
AFTER THE MOVE:
D E F b b b b b
NOW, ONTO EDITING….
1
EDITING
and ALTERNATIVE FORMS OF THE MOVE
MOVE ATOM CRUISE@ TO NAME-IN.
01NAME-INPIC X(10) VALUE SPACE.
01NAME-0UTPIC X(6)VALUE SPACE.
MOVE NAME-IN (5:6) TO NAME-OUT
MOVES CHARACTERS ASTARTING@ AT POSITION 5
FOR A LENGTH OF 6 TO RECEIVING FIELD.
MANY EXTENSIONS OF THIS LATER...
EDITING / PRINTING OUTPUT
. WANT TO BE ABLE TO EDIT SYMBOLS:
PIC 999V99 WITH 306 40
BUT TREATED AS 306.40
DESIRE TO PRINT OUT AS $306.40
EDITING HAS MANY FORMS.
PRINCIPLE: EDITING TAKES PLACE AS THE SENDING FIELD=S CONTENTS ARE MOVED INTO THE RECEIVING FIELD.
IT IS THE PICTURE CLAUSE OF THE RECEIVING FIELD THAT DETERMINES HOW THE EDITING TAKES PLACE.
CALL RECEIVING FIELDS AREPORT-ITEM@ FIELDS.
NOT NUMERIC FIELDS!!
IT IS, THUS, THE MOVEMENT OF DATA INTO AN EDITED RECEIVING FIELD THAT CAUSES THE EDITING TO TAKE PLACE.
1
TYPICALLY:
MOVE A NUMERIC FIELD (SENDING FIELD) TO
A REPORT-ITEM FIELD(RECEIVING FIELD).
. RECEIVING FIELD WILL HAVE SPECIAL CHARACTERS
.. $ CR . + - Z * etc.
. AS USUAL, SENDING FIELD IS UNCHANGED.
. TYPICALLY, RECEIVING FIELDS ARE IN WORKING-STORAGE IN PRINT LINE FORMATS.
(could be in File Section, but rarely seen here....)
THE AGIVING@ OPTION OF MANY INSTRUCTIONS IS THE SAME THING (FUNCTIONALLY) AS A AMOVE.@
E.G., ADD FIELD-A TO FIELD-B GIVING FIELD-C.
. TWO FIELDS ARE ADDED TOGETHER
. RESULT IS MOVED INTO FIELD-C.
. IF FIELD-C IS A REPORT-ITEM FIELD, EDITING WILL TAKE PLACE.
GENERALLY, MOVEMENT INTO REPORT ITEM FIELDS TAKES PLACE JUST PRIOR TO PRINTING....
IF MORE COMPUTATIONS ARE TO TAKE PLACE, THEN EDITING FIELDS ARE NOT USED, SINCE THEY ARE NOT NUMERIC.
BUT WHEN THE RESULTS ARE COMPUTED AND ARE TO BE PRINTED, EDITING TAKES PLACE VIA A AMOVE@ OR VIA A AGIVING.@
1
PRINTING DECIMAL POINTS.
SENDING FIELD: 99V99 = 4 POSITIONS
C(FIELD) = 12 34 AND WE PRINTED THIS, WE=D GET 1234 OUT!
WE WANT 99.99= 5 POSITION FIELD.
NOTE: THIS IS NOT A NUMERIC FIELD ANY MORE
IS A AREPORT ITEM@ FIELD AND IS ALPHANUMERIC...
DATA IS AMOVED@INTO THE RECEIVING FIELD USING THE RULES OF THE NUMERIC MOVE.
99V99 --> 99.99WITH TRUNCATION OR ZERO FILLED
4 pos 5 pos
MOVE 45 65 INTO RECEIVED FIELD YIELDS 45.65 (FIVE POS)
99V99 CON = 12 45INTO 999.9 YIELDS 012.4
INTO 9.999 YIELDS 2.450
1
SUPPRESSING LEADING ZEROES
ZERO SUPPRESSION SUPPRESSES LEADING, NON-SIGNIFICANT ZEROES.
PIC 999VALUE 123.--->PIC 99999 = 00123
PIC Z(5) = bb123
Z IS THE SYMBOL FOR ZERO SUPPRESSION
NOTE: THE NUMBER SENT WILL BE PRINTED IF SIGNIFICANT.
ONCE SIGNIFICANCE IS ATURNED ON@ ALL OTHER Z=s WILL BE REPLACED BY SIGNIFICANT DIGITS.
Zs REPLACE SENDING, NON-SIGNIFICANT ZEROES WITH
A SPACE.
999V99WITH 120 45--->Z(4).99YIELDSb120.45
WITH 001 03--->YIELDSbbb1.03
WITH 000 00 --->YIELDSbbb.00
NOTE: TOTAL SUPPRESSION OF LEADING ZEROES IS UNWISE, HENCE: ZZ9 OR ZZZ.99, ETC.
DON=T USE: ZZZZ BY ITSELF.
EXAMPLES OF ZERO SUPPRESSION
SENDING FIELDRECEIVING FIELD
PICCONPICCON
999109ZZZ109
999007ZZZbb7
9(3)000Z(3)bbb
9(4)0082Z999b082
999007Z99b07
1
COMBINING DECIMAL POINT INSERTION WITH ZERO SUPPRESSION
EXAMPLES OF ZERO SUPPRESSION AND POINT INSERTION
SENDING FIELDRECEIVING FIELD
PICCONPICCON
99V9902 38ZZ.99b2.38
99V9900 03ZZ.99bb.03
99V9900 05Z9.99b0.05
BE CAREFUL OF DIFFERENT SIZE FIELDS:
JUST THINK OF THE MOVE AS A NUMERIC MOVE!!
EXAMPLES OF ZERO SUPPRESSION AND POINT INSERTION
SENDING FIELDRECEIVING FIELD
PICCONPICCON
999V99008 27ZZZbb8
999027ZZZ.99b27.00
999018ZZZ.ZZb18.00
999000ZZZ.ZZbbbbbb
(6 spaces)
1
PRINTING DOLLAR SIGNS AND COMMAS
RULE: PUT THEM WHERE YOU WANT THEM TO APPEAR.
DOLLAR SIGN WILL ALWAYS PRINT IN THE POSITION INDICATED
(UNLESS FLOATING - LATER....)
COMMAS WILL PRINT, IF SIGNIFICANCE IS TURNED ON.
EXAMPLES OF DOLLAR SIGNS AND COMMAS
SENDING FIELDRECEIVING FIELD
PICCONPICCON
9999V993812 34$9,999.99$3,812.34
(note number of positions of sending and receiving fields!!!)
99V9905 00$ZZ.99$b5.00
999V99000 05$ZZZ.99$bbb.05
9999V990003 82$Z,ZZZ.99$bbbb3.82
(again: note number of positions of sending and receiving fields!!!)
AS USUAL, DIFFERENT NUMBERS OF INTEGERS AND DECIMAL PLACES IN THE REPORT-ITEM FIELDS ARE PERMISSIBLE.
REMEMBER: CHECK OUT THE VALUE CLAUSES, IF PRESENT FIRST!
999VALUE 20ZZ.9920.00
V99VALUE .45Z9.99b0.45
1
PRINTING ASTERISKS FOR CHECK PROTECTION
SOMETIMES WE DON=T WANT BLANKS TO APPEAR IN FROM OF NUMERIC DATA.
WE HAVE CAPABILITY TO PRINT ASTERISKS IN LIEU OF LEADING SPACES.
CALLED ACHECK PROTECT@ FEATURE
Zs ARE REPLACED WITH ASTERISKS.
EXAMPLES OF CHECK PROTECT FEATURE
SENDING FIELDRECEIVING FIELD
PICCONPICCON
999V99123 45$***.99$123.45
(NOTE: SIZE OF SENDING / RECEIVING FIELDS....)
999V99012 34$***.99$b12.34
99999V9900234 56$**,***.99$***234.56
9(5)V9904567 00$**,***.99$*4,567.00
9(5)04567$**,***.99$*4,567.00
1
PRINTING PLUS OR MINUS SIGNS IN OUTPUT FIELDS
CAN PRINT PLUSES OR MINUSES IN FRONT OF OR AFTER OTHER CHARACTERS IN REPORT--ITEM FIELD.
SO FAR, WE HAVE ONLY HAD UNSIGNED NUMERIC FIELDS.
NUMERIC FIELDS: S99 = TWO POSITION, SIGNED-NUMERIC FIELD
COULD NOT STORE -120 SO FAR. WOULD GET 120 (UNSIGNED)
PRINTING THE MINUS SIGN:
MINUS SIGN CAN BE PRINTED EITHER SIDE
ONLY IF SENDING FIELD IS NEGATIVE....!!!
PRINTING THE PLUS SIGN
PLUS SIGN CAN BE PRINTED EITHER SIDEREGARDLESS OF PRESENCE OR ABSENCE OF SIGN IN SENDING FIELD
IF SENDING FIELD IS PLUS OR UNSIGNED, + WILL PRINT
IF SENDING FIELD IS MINUS, - WILL PRINT.
THE + EDITING SYMBOL WILL RESULT IN A SIGN PRINTED.
1
EXAMPLES OF SIGNED NUMERIC FIELDS AND THEIR EDITING
SENDING FIELDRECEIVING FIELD
PICCONPICCON
S999123-999-123
S999123999-123-
999123-999b123
S999123-999b123
S99V9902 34ZZ.99-b2.34-
S999123+999+123
S999123999+123+
S999123+999-123
S999V99387 25+Z,ZZZ.99-bb387.25
HOW ABOUT:
S999V99123 45$ZZ,ZZZ.99+ $bbb123.45-
5 positions moving into 11 positions.....quite common.
S999V99014 00$ZZ,ZZZ.99+ $bbbb14.00+
1
PRINTING DEBIT/CREDIT SYMBOLS - ACCOUNTING APPLICATIONS
WANT TO PRINT DB OR CR WHERE APPROPRIATE.
CAN ONLY APPEAR AT THE END OF THE PIC CLAUSE.
WILL ONLY PRINT IF SENDING FIELD IS NEGATIVE.
EXAMPLES OF CREDIT AND DEBIT INDICATORS
SENDING FIELDRECEIVING FIELD
PICCONPICCON
S999123999CR123CR
S999123999DB123DB
S999123999CR123bb
S999123999DB123bb
S999V99123 00999.99DB123.00bb
1
PRINTING SPACES OR ZEROES AS SEPARATORS WITHIN FIELDS
B = SPACE FOR ANY TYPE OF SENDING FIELD
0 = ZERO. USED FOR 0 INSERT
NEVER LOSE ANY SENDING CHARACTERS....
EXAMPLES OF CREDIT AND DEBIT INDICATORS
SENDING FIELDRECEIVING FIELD
PICCONPICCON
9(9)123456789999B99B9999 123b45b6789
X(10)JFKENNEDY XBXBXXXXXXXX J F KENNEDYb
999143999000143000
999065ZZ900 b6500
NOTE: EXCEPT FOR Bs AND 0s ALL SENDING FIELDS HAD TO BE NUMERIC.
ALSO, ONLY ELEMENTARY ITEMS (HAVING PIC CLAUSES) COULD BE SENT.
REMEMBER: CAN EDIT IN TWO WAYS:
. MOVING A SENDING FIELD EXPLICITLY TO A REPORT FIELD
. RESULT OF AGIVING@ OPTION IN ARITHMETIC STATEMENTS.
TO BE SHOWN: RECEIVING FIELD OF A GIVING CLAUSE NEED NOT BE A REPORT ITEM. CAN BE NUMERIC AND FREQUENTLY IS.
1
SUMMARY QUIZ
1. 9(6)123456$ZZZ,ZZZ.99$123,456.00
2.9999V990012 34$Z,Z(3).99$bbb12.34
3. 9(5)V9900001 23$**,***.99$*****1.23
4. S9(6)012345+Z(6)-b12345
5. S9(6)123456-Z(6)b123456
6.S9(4)V991234 56+Z(4).99+1234.56
7.S999123ZZZ-123-
8.9(6)12345699BBBB999912bbbb3456
9.S9905$ZZ.99DB$b5.00DB
10.999123999000123000
11.S99V9912 34$ZZ.99CR$12.34CR
REMEMBER: IF GIVEN SOME WITH AVALUE@ CLAUSES, BE SURE THAT YOU KNOW THE CONTENTS OF THE SENDING FIELD PRIOR TOSENDING THE DATA.
1
EDITING USING FLOATING STRINGS
CAN AFLOAT@ THREE CHARACTERS IN FROM THE LEFT....
BUT ONLY ONE AT A TIME
$+-THAT=S IT.
TO FLOAT: FLOATING CHARACTER MUST BE FIRST CHARACTER OF PIC CLAUSE.
AFLOATING@ IS INFERRED IF THE CHARACTER IS AREPEATED.@
E.G., PIC +(4) OR $(4).99OR ---99.00
EXAMPLES OF FLOATING CHARACTERS
SENDING FIELDRECEIVING FIELD
PICCONPICCON
999123$$$$$.99b$123.00
999003$$$$$.99bbb$3.00
999034$(4).99+b$34.00+
BLANK WHEN ZERO
05QTY-OUTPIC +(5).
MOVE 0 TO QTY-OUTPRINTS: bbbb+
BETTER:
05QTY-OUT PIC +(5) BLANK WHEN ZERO.
WOULD PRINT:bbbbb
1
DE-EDITING....
LET=S YOU TAKE A FIELD THAT IS A REPORT-ITEM FIELD AND MOVE IT BACK INTO A NUMERIC FIELD AND RECOVER THE ANUMERIC PROPERTIES.@
IN COBOL 85.
MOVE A FIELD SUCH AS 999.999 WITH CONTENTS 123.456
INTO A FIELD SUCH AS 999V999 AND GET 123 456.
OFTEN USED WITH INTERACTIVE SESSIONS, TO ALLOW USER TO INPUT DOLLAR AMOUNTS, ESPECIALLY DECIMAL POINTS AND ALLOW PROGRAM TO RECOVER NUMERIC VALUES FOR SUBSEQUENT PROCESSING.
READ ... INTO STATEMENT
ALLOWS YOU TO READ A RECORD INTO A WORKING STORAGE AREA (SEE TEXTBOOK).
RECOGNIZE THAT THE RECORD DOES GO THRU THE PROCESS AREA FIRST.
YOU MAY WANT TO HOLD ON TO THE FIRST RECORD, WHICH MAY HAVE SOME SPECIALIZED PARAMETERS ON IT FOR FURTHER PROCESSING....
1
INITIALIZE VERB
SIMPLY INITIALIZES NUMERIC FIELDS TO ZEROES AND ALPHANUMERIC FIELDS TO SPACES.
PARTICULARLY GOOD FOR INITIALIZING A GROUP ITEM THAT HAS SEVERAL FIELDS (PERHAPS BOTH NUMERIC AND ALPHANUMERIC) SUBORDINATE TO IT AS ELEMENTARY ITEMS.
E.G.01ACCUMULATOR-REC.
05NAMEPIC X(20).
05PIC X(5)
05SSANPIC 9(9)
05PIC X(5).
05AGEPIC 999.
05PIC X(5).
05ADDRESSPIC X(20).
05PIC XXX.
05PHONE-NBRPIC 9(7).
05PIC X(20).
INITIALIZE ACCUMULATOR-REC
WILL INITIALIZE ALL FIELDS INCLUDING ONES THAT MIGHT HAVE A VALUE CLAUSE.
1