10.07.2015 Views

Enterprise COBOL for z/OS V4.2 Programming Guide

Enterprise COBOL for z/OS V4.2 Programming Guide

Enterprise COBOL for z/OS V4.2 Programming Guide

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Arithmetic comparisons (relation conditions) . . 65Examples: fixed-point and floating-pointevaluations . . . . . . . . . . . . . 66Using currency signs . . . . . . . . . . . 67Example: multiple currency signs . . . . . . 68Chapter 4. Handling tables . . . . . . 69Defining a table (OCCURS) . . . . . . . . . 69Nesting tables . . . . . . . . . . . . . 71Example: subscripting . . . . . . . . . . 72Example: indexing . . . . . . . . . . . 72Referring to an item in a table . . . . . . . . 72Subscripting . . . . . . . . . . . . . 73Indexing . . . . . . . . . . . . . . 74Putting values into a table . . . . . . . . . 75Loading a table dynamically. . . . . . . . 75Initializing a table (INITIALIZE) . . . . . . 76Assigning values when you define a table(VALUE) . . . . . . . . . . . . . . 77Example: PERFORM and subscripting . . . . 79Example: PERFORM and indexing. . . . . . 80Creating variable-length tables (DEPENDING ON) 81Loading a variable-length table . . . . . . . 82Assigning values to a variable-length table . . . 83Searching a table . . . . . . . . . . . . 84Doing a serial search (SEARCH) . . . . . . 84Doing a binary search (SEARCH ALL) . . . . 85Processing table items using intrinsic functions . . 86Example: processing tables using intrinsicfunctions . . . . . . . . . . . . . . 87Chapter 5. Selecting and repeatingprogram actions . . . . . . . . . . 89Selecting program actions . . . . . . . . . 89Coding a choice of actions . . . . . . . . 89Coding conditional expressions . . . . . . . 94Repeating program actions . . . . . . . . . 97Choosing inline or out-of-line PERFORM . . . 98Coding a loop . . . . . . . . . . . . 99Looping through a table . . . . . . . . . 100Executing multiple paragraphs or sections. . . 100Chapter 6. Handling strings . . . . . 101Joining data items (STRING) . . . . . . . . 101Example: STRING statement . . . . . . . 102Splitting data items (UNSTRING) . . . . . . 103Example: UNSTRING statement . . . . . . 104Manipulating null-terminated strings . . . . . 106Example: null-terminated strings . . . . . . 107Referring to substrings of data items . . . . . 107Reference modifiers . . . . . . . . . . 109Example: arithmetic expressions as referencemodifiers . . . . . . . . . . . . . . 110Example: intrinsic functions as referencemodifiers . . . . . . . . . . . . . . 110Tallying and replacing data items (INSPECT) . . . 111Examples: INSPECT statement. . . . . . . 111Converting data items (intrinsic functions). . . . 112Converting to uppercase or lowercase(UPPER-CASE, LOWER-CASE) . . . . . . 113Trans<strong>for</strong>ming to reverse order (REVERSE) . . . 113Converting to numbers (NUMVAL,NUMVAL-C) . . . . . . . . . . . . 113Converting from one code page to another . . 115Evaluating data items (intrinsic functions) . . . . 115Evaluating single characters <strong>for</strong> collatingsequence . . . . . . . . . . . . . . 115Finding the largest or smallest data item . . . 116Finding the length of data items . . . . . . 118Finding the date of compilation . . . . . . 119Chapter 7. Processing data in aninternational environment . . . . . . 121<strong>COBOL</strong> statements and national data . . . . . 122Intrinsic functions and national data. . . . . . 124Unicode and the encoding of language characters 125Using national data (Unicode) in <strong>COBOL</strong> . . . . 126Defining national data items . . . . . . . 127Using national literals . . . . . . . . . 127Using national-character figurative constants 128Defining national numeric data items . . . . 129National groups . . . . . . . . . . . 129Using national groups . . . . . . . . . 130Storage of character data . . . . . . . . 133Converting to or from national (Unicode)representation . . . . . . . . . . . . . 134Converting alphanumeric, DBCS, and integer tonational (MOVE) . . . . . . . . . . . 134Converting alphanumeric or DBCS to national(NATIONAL-OF) . . . . . . . . . . . 135Converting national to alphanumeric(DISPLAY-OF) . . . . . . . . . . . . 136Overriding the default code page. . . . . . 136Conversion exceptions . . . . . . . . . 136Example: converting to and from national data 137Processing UTF-8 data . . . . . . . . . . 137Processing Chinese GB 18030 data . . . . . . 138Comparing national (UTF-16) data . . . . . . 139Comparing two class national operands . . . 139Comparing class national and class numericoperands . . . . . . . . . . . . . . 140Comparing national numeric and other numericoperands . . . . . . . . . . . . . . 140Comparing national and other character-stringoperands . . . . . . . . . . . . . . 140Comparing national data andalphanumeric-group operands. . . . . . . 141Coding <strong>for</strong> use of DBCS support . . . . . . . 141Declaring DBCS data . . . . . . . . . . 142Using DBCS literals . . . . . . . . . . 142Testing <strong>for</strong> valid DBCS characters . . . . . 143Processing alphanumeric data items that containDBCS data . . . . . . . . . . . . . 143Chapter 8. Processing files . . . . . 145File organization and input-output devices . . . 145Choosing file organization and access mode . . . 147Format <strong>for</strong> coding input and output . . . . . 148Allocating files . . . . . . . . . . . . . 149Checking <strong>for</strong> input or output errors . . . . . . 150iv<strong>Enterprise</strong> <strong>COBOL</strong> <strong>for</strong> z/<strong>OS</strong> <strong>V4.2</strong> <strong>Programming</strong> <strong>Guide</strong>

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!