COBOL grammar and literacy

xiaoxiao2021-03-06  15

Redefines can describe the same memory with different variables. 01 PART_RECODE USAGE DISPLAY 03 PART-TYPE PICTURE ... 03 PART_TYPE_A. 05 PART_NUMBER PICTURE ... 05 PART_COST PICTURE ... 03 PART_TYPE_B REDEFINES PART_TYPE_A. 05 UPC_CODE PICTURE ... 03 PART_TYPE_C REDEFINES PART_TYPE_A. 05 ISBN PICTURE ... according to Part_type decided to use part_type_a or part_type_b or part_type_c. Rules: Part_type_b and part_type_c length cannot be greater than part_type_a. Data items cannot be Value. 01 layers cannot be used in redefines. Part_type_b and part_type_c do not have OCCURS.

Picture defines the specific length, format, and data type of the basic item. It can be short-written to the PIC. The format string can include the following characters: A letter AZ, AZ, space B inserts the space P scheduling character, and the decimal point s algebraic symbols not displayed in the field, the actual display depends on the project USAGE V Digital Point Position X Any character z suppressed 0 of the leader 0 and converted into empty characters 0 inserted 0 9 numbers 0 to 9 / insert /, inserted, (comma could not be used as the last bit of the string, the last comma is a separator). insert. * Inhibition of 0 and convert to * positive insert , negative value insert--Positive insert space, negatively insert-$ inserted into the US CR positive value inserted two spaces, negatively inserted Cr DB positive value inserted two Space, negative value insertion DB example: 03 VAR PIC AAAAA. VAR variable length is 5 characters, no numbers, equivalent to 03 State Pic A (5). Enter asdfg to display the ASDFG 03 VAR PIC XXXXX. VAR variable length is 5 arbitrary characters. Equivalent to 03 FILLER PIC X (5). Enter 123AS, display 123AS 03 VAR PIC 99 / XXX / 9999 length 11, input 05may2004, display 05 / May / 2004 03 VAR PIC 0ABXXX / 9999 length 11, input 05may2004, display 05 May / 2004 03 VAR PIC 9 (3) length 3, between 3, 0 ~ 999. 03 VAR PIC 9 (4) V99 length 6, 0.00 ~ 9999.99. 03 VAR PIC S9 (5) V99 length 7, between -99999.99 ~ 99999.99 between. 03 VAR PIC 9 (6) PPP length 6, can be 1000, 2000, ..., 999999000. Input 1234, display 1000. 03 VAR PIC PIC PPP999 length between 3,0.000001 ~ 0.000999. Input 123, display 0.000123.

03 VAR PIC ZZ.99, input 100.50, display 100.50; input -51.50, display 51.50; input 0, display .00. 03 var pic $ zz.zz-, enter 100.50, display $ 100.50; input -51.50, display $ 51.50-; Enter 0, display 03 VAR PIC $ ***, ***. 99CR, input 1000, display $ ** 1000.00; enter $ ** 1000.00cr; enter 0, display $ ***, *** .00; input 51.5, display $ ***, * 51.50 03 VAR PIC $$$, $$$. 99.50, display $ 100.50; input $ 100.50; enter 0.777, display $ .77; input 0 , Display $ .00 03 VAR PIC $. $$$, type 1.00, display $ .00; enter $ .65; enter 0, display $ .00; 03 var pic $ -, enter 17.7, display $ 17 Input -17.7, display $ -1; input -5, display $ -5 03 VAR PIC $ 999.99 , enter $ 100.50 ; input -100.50, display $ 100.50-; 03 VAR PIC 9 (3) b9 (3) , Input 55, display 000 055; input 1000.78, display 001 000; 03 FILLER PIC X (44), add 44 vacancy USAGE to represent the type of basic or group data. There are binary, computational (comp), display, index, packed-decimal.justified 03 var1 pic x (5) Justified Right. 03 var2 pic x (5). Enter XYZ, VAR1 display "XYZ", VAR2 display is "Xyz".

Blank When Zero 03 VAR PIC $ 999,999.99 Blank when Zero. When the field value is 0, this project is set to all spaces.

When Value is defined, it will be assigned. 03 VAR PIC X (5) Value "abcde". 01 var value all spaces. 03 var1 pic xx. 03 var2 pic xx.

The operation order of the operator in the arithmetic statement COBOL is: Take the positive ( ), the maximum, index operation (**) second, multiply (*), in addition to (/), plus ( ), reduce (-)At last. Rounded rounding operation. 77 A PIC 9V9 Value 9.1. 77 B PIC 9. Add 0.5 to a giving b on size error Go to proc1. Add 0.5 to a giving b Rounded on size error Go to proc2. End-add.on size error is when the statement appears Perform it when it is wrong. In this example, there is no error, so on size error does not perform Proc1. In the second sentence, when 0.5 plus 9.1 gets 9.6, because there is Rounded, the rounding operation is performed to obtain 10. And B is only 1 digit, so an error occurs, performs on size error operation, and performs Proc2. The Corresponding (CORR) data item is written in the same name. Add and Substract have this option. 01 a. 03 B. 05 B1 PIC 999V99. 05 B1 PIC 999V99. 03 C. 05 B1 PIC 999V99. 05 B1 PIC 999V99. 05 B1 PIC 999V99. The statement add corr b to C. Equivalent to execution The following three statements below. Add B1 of B TO B1 of C. Add B2 of B TO B2 of C. Add B3 of B TO B3 of C. Group items do not have to format. The content in a group project can not be in another group project, and the data item order is also insignificant. It is only necessary to correspond to the name of the data item. Add A, B Giving C. end-add. Add A and B to C. Subtract A, B from C. End-subtract. Subtract A, B. Multiply A by b giving c. end-multiply from C. End-multiply. Put a, b. Divid a INTO B GIVING C. End-Divide. Add B in the result of A. Divide a by b giving c. end-divide. Put A by the result of the B is placed in C. Divide A By B Giving C Remainder D. Put A in C, the remainder is placed in D = AB * C. 77 C Pic S99V9. 77 D PIC S99V9. Divide 3 INTO 7 GIVING C Remainder D. C is 2.3, D is 0.1. (D = 7-3 * 2.3) Compute In addition to the payment, other operations can be used in other operations. This statement evaluates an arithmetic expression and stores the results in one or more variables. Compute A Rounded, B = x * Y / (N M) Z. Store the results of X * Y / (N M) Z in B, and then put into A.

Move Move A to B. You can also use the CORR option. Move Corr A to B.

Accept data from the keyboard or other input device. Accept A from dev. Read data from DEV to A, or omitting from dev, represents from the keyboard. Accept a from date / day / day-of-week / time. The date is expressed as 6 characters, such as 990909 (September 9, 1999). Read the current date in the year (first 2) for the first few days (after 3), it is expressed as 6 characters, as shown on April 1, 1994. Read the current week, indicated as 1 character. 1 means Monday, 7 means Sunday. Read the current time, indicating as an 8-bit character. Accurate to milliseconds. As is 14410000, as shown at 2:41 pm. Display writes data to the output device. Such as monite, system output stream, and operator console. Display AAAA BBBB [UPON DEV] [with no advancing] If you use the UPON option, DEV is to be associated with the hardware name in the Special-Names segment. If you use the No Advancing option, the output device remains in place after the last character is output, so that the next Display statement is still displayed in this location. Otherwise it may be displayed next to the next line.

Initialize initialized data, numbers and digital editing data items are initialized to 0, and other initialization is spaced.

The number of times the string appears in the inspect tallying calculation project. Inspect aa tallying bb for all "ee". How many EE is found from the AA, write a number to BB. Inspect AA Tallying BB for Characters Before "E". How many characters are found from the front of the E E, write a number to BB. Inspect aa tallying bb for character "c" before "e". How many characters have to be found in front of the decs in the AA, write a number to BB. Inspect aa tallying bb for letting "e". How many E is found from the first character in the AA, if not ending the operation, there is no number to BB until no. Inspect aa tallying bb for letting "e" after "c". How many E is found from the AA C. If there is no operation, it will write a bit to BB until there is no. Combination example: 77 CS Pic x (9) Value "reelwheel". 77 count-0. 77 count-1. 77 count-2. Move 0 to count-0, count-1, count-2. Inspect cs tallying count- 0 for ALL "E", count-1 for letting "w" after "l", count-2 for character, the program first judges the character "R", execute count-0 for all "e" because the first The characters are not "e", so the program turns to perform count-1 for letting "w" after "L", and does not meet the requirements, so the program performs count-2 for character, count-2 = 1. Then string to the next bit, determine "e", execute count-0 for all "e", meet the requirements, then count-0 = 1. With the judgment of satisfying the conditions, the rest of the judgment is no longer executed, the string is again down, and "E" is determined, then count-0 = 2. Then, "L" is then determined, then count-2 = 2. With this, the final result is count-0 = 4, count-1 = 1, count-2 = 4. Inspect replan replaces this string with another string. Also use the above example.

Inspect CS Replacing All "E" by "y". Result "Ryylwhyyl" Inspect CS Replacing Characters by "z" after "L". Result "ReelZzz" Inspect CS Replacing Leading "E" by "y". Result constant Inspect CS Replacing Leading "E" by "z" after "h". Result "Reelwhzzl" Inspect CS Replacing First "e" by "I". Result "Rieelwheel" Inspect CS Replacing First "EE" by "00", All "WH" BY "TH", Characters by space. Result "00 th" Inspect Converting is an abbreviation for inspect replacing. Inspect CS Converting "EE" to "00". You can also add Before, After. String combines several strings into a string. String a Delimited by Space, "!" Delimited by size Into C. Suppose the contents A is "Hello", the result is "Hello!". DELIMITED by Space meaning to touch spaces, or at the end of A or C At the end, the merge A string ends. Delimited by size means the end of the end of "!" Or C, the incoming "!" String ends. String a INTO B POINTER C ON overflow proc1 NOT ON overflow proc2. Copy the A string to the address starting from C. If C is less than 1 or greater than the length of B, or the length of A is greater than the length of c to the tail in B, OVERFLOW overflow occurs, and proC1 is executed.

Unstring puts the characters in a string as required in multiple variables. Unstring aaa [Delimited by [all] b [or [all] c] ... {c [delimiter in d] [count in e]} ... [with pointer f] [Tallying in g] [on overflow Proc1] [NOT ON OVERFLOW PROC2] [end-unstring] puts the characters in the AAA into C, if there are other variables, such as C2, then add C2 after the C2 is filled. Delimited By and String the role. Referring to the character from the AAA to B. If there is OR, it is denoted by the characters from B or C characters. If there is all, if several identical b are together, it is considered to be a B. Delimiter IN puts B in D, know which character is separator. Count in actually copies the number of characters in C in E. WITH POINTER and STRIGN. Tallying in computing has several acceptings. Access a new accept term, G value plus 1. Example: 03 City Pic X (10). O3 ZIP PIC X (10). 77 Test Pic X (20). Move "New York, NY 10017" To Test. Unstring Test Delimited by "," INTO City, ZIP. Execution The value of the current value is the value of New York.zip is NY 10017. Logic and control statement IF (a [not]> b) equivalent to IF (a [not] Greater Than B) IF (A [Not] = b) equivalent to IF (a Greater Than or Equal TO B) IF (a <= b) equivalent IF (a Less Than Or Equal to B)

IF (a [not]> b and c) represents A [NOT] greater than B and A [NOT] greater than c if a is [not] numeric number and optional symbol IF a is [not] alphabetic a ~ z, a ~ Z Character and Space IF A IS [NOT] Alphabetic-Lower A ~ Z Character and Space IF A IS [NOT] Alphabetic-Upper A ~ Z Character and Space IF A IS [NOT] Class-Name Special-Names defined character set For example: Special-names. Class MyDefine IS "12345 ABCDE-".

The determination variable defines a value. This variable is 88 layers and is associated with a data item. 03 State Pic XX. 88 CON VALUES ARE "A", "B", "C". Ifcon ...

Judging the manufacturer defines the on / off state of the running switch. SPECIAL-NAMES. Switch-a on status is a-on, off status is a-OFF. If A-ON ... If the switch is open, IF A-ON returns True.

If a is [not] Positive determines if it is greater than 0 if a is [not] negative judgment is less than 0 if a is [not] ZERO determines if 0COBOL supports NOT, AND, OR operation.

Perform process call, but does not pass parameters. Perform proc1 [through proc2] Performed proc1 and executed Proc2. No through (thru) only executes proc1. Perform proc1 [thru proc2] n Times Execute Proc1 [or PROC2] N times. Perform proc1 [thru proc2] [with test before / after] Until a not euqal 0. Execute PROC1 [or also with proc2] until A is not equal to 0. WITH TEST BEFORE / AFTER Specifies that the conditions before or after the first execution. The default is Before, it is executed before execution. Perform proc1 [thru proc2] [with test before / after] Varying a from b by c until condition1 [after D from e by f Until condition2]. Equivalent to the FOR cycle, start from B, incremented by C Until Condition1. The AFTER statement is a nested for loop. Varying is a foreign cycle, and after the AFTER is an internal cycle. A, B can be an index.

The process can also be written directly into Perform. But Through is not easy to use. The syntax is as follows: Perform Process Statement End-Perform. Perform N Times Procedure Statement End-Perform. Perform [with Test Before / After] Until Condition Process Statement End-Perform. Perform [with test before / after] Varying a from b by c uncle CONDITION1 Process Statement End-Perform.

The if statement if condition thrse statements2 end-if / next sentence / Endif next SENTENCE will jump out of the IF operation statement to perform the next statement. Do not use in the IF statement. The end will end all if statements. To end a nested IF statement, you can use end-if or next senence. Such as if a if b end-if else c end-if. Or if a if b else next sentence else c end-if.

Evaluate is equivalent to the Switch Case statement. Evaluate A WHEN B ... WHEN 0 thru 100 ... (from 0 to 100) When Other ... [end-evata] First get the result of A, compare the parameters of the WHEN statement, if you are equal, The operation after B is completed, and the WHEN statement that is no longer executed. If you don't wait, you will perform the next WHEN statement. Execute the WHEN Other statement if it is not equal. Evaluate a Also B WHEN C Also D ... WHEN E Also f ... WHEN Other ... For multiple judgment conditions, multiple conditions are met. The WHEN statement is executed simultaneously if you want c = A above.

Continue continues to perform the following program.

Go to Go To Proc1 [Depending ON N] Depending ON N will jump to the nth proc.exit in the list is generally the last sentence.

STOP STOP RUN End Procedure.

Alter alter proc1 to proc2. Don't know what it means, anyway, this statement has been abolished from the standard.

ENTER enables statements in other programming languages ​​to place them in the current source program. Enter language-name [routine-name] Language is a manufacturer specified any language that can be entered into COBOL, which is the statement of other programming languages, and then use Entercobol to return to the COBOL language. If you cannot put them directly in other languages, you can use the Routine-name to reference the program written in other languages.

转载请注明原文地址:https://www.9cbs.com/read-49563.html

New Post(0)