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.

Chapter 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) . . . . . . . . . . . . . . 77Initializing each table item individually . . . 77Initializing a table at the group level . . . . 78Initializing all occurrences of a given tableelement. . . . . . . . . . . . . . 78Example: 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) . . . . . . 84Example: serial search . . . . . . . . . 84Doing a binary search (SEARCH ALL) . . . . 85Example: binary search . . . . . . . . 86Processing table items using intrinsic functions . . 86Example: processing tables using intrinsicfunctions . . . . . . . . . . . . . . 87Chapter 5. Selecting and repeating programactions . . . . . . . . . . . . . . . 89Selecting program actions . . . . . . . . . 89Coding a choice of actions . . . . . . . . 89Using nested IF statements . . . . . . . 90Using the EVALUATE statement . . . . . 91Coding conditional expressions . . . . . . . 94Switches and flags . . . . . . . . . . 95Defining switches and flags . . . . . . . 95Example: switches . . . . . . . . . . 95Example: flags . . . . . . . . . . . 96Resetting switches and flags . . . . . . . 96Example: set switch on . . . . . . . . 96Example: set switch off . . . . . . . . 97Repeating program actions . . . . . . . . . 97Choosing inline or out-of-line PERFORM . . . 98Example: inline PERFORM statement. . . . 98Coding a loop . . . . . . . . . . . . 99Looping through a table . . . . . . . . . 100Executing multiple paragraphs or sections. . . 100Chapter 6. Handling strings . . . . . . . . 101Joining data items (STRING) . . . . . . . . 101Example: STRING statement . . . . . . . 102STRING results. . . . . . . . . . . 103Splitting data items (UNSTRING) . . . . . . 103Example: UNSTRING statement . . . . . . 104UNSTRING results . . . . . . . . . 105Manipulating 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 . . . 116Returning variable-length results withalphanumeric or national functions . . . . 117Finding the length of data items . . . . . . 118Finding the date of compilation . . . . . . 119Chapter 7. Processing data in an internationalenvironment . . . . . . . . . . . . . 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 . . . . . . . . . 130Using national groups as elementary items 131Using national groups as group items . . . 132Storage 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 . . . . . . . . . . . . . . 1402 <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!