IBM - VisualAge Cobol for Windows Programming Guide
634 pág.

IBM - VisualAge Cobol for Windows Programming Guide


DisciplinaCobol25 materiais168 seguidores
Pré-visualização50 páginas
. . . . 86
Example: intrinsic functions as reference
modifiers . . . . . . . . . . . . . . 86
Tallying and replacing data items (INSPECT) . . . 87
Examples: INSPECT statement . . . . . . . 87
Converting data items (intrinsic functions) . . . . 88
Converting to uppercase or lowercase
(UPPER-CASE, LOWER-CASE) . . . . . . . 88
Converting to reverse order (REVERSE) . . . . 89
Converting to numbers (NUMVAL, NUMVAL-C) 89
Evaluating data items (intrinsic functions) . . . . 90
Evaluating single characters for collating
sequence . . . . . . . . . . . . . . 90
Finding the largest or smallest data item . . . 90
Finding the length of data items . . . . . . 92
Finding the date of compilation . . . . . . 93
Chapter 7. Processing files . . . . . . 95
Identifying files . . . . . . . . . . . . . 95
Identifying Btrieve files . . . . . . . . . 96
Identifying STL files . . . . . . . . . . 96
Identifying remote files . . . . . . . . . 96
File system . . . . . . . . . . . . . 97
STL file system . . . . . . . . . . . . 97
Protecting against errors when opening files . . . 100
Specifying a file organization and access mode . . 100
File organization and access mode . . . . . 100
Setting up a field for file status . . . . . . . 104
Describing the structure of a file in detail . . . . 104
Coding input and output statements for files . . . 104
Example: COBOL coding for files. . . . . . 105
File position indicator . . . . . . . . . 106
Opening a file . . . . . . . . . . . . 107
Reading records from a file . . . . . . . . 109
Adding records to a file . . . . . . . . . 110
Replacing records in a file . . . . . . . . 111
Deleting records from a file. . . . . . . . 112
PROCEDURE DIVISION statements used to
update files . . . . . . . . . . . . . 112
Chapter 8. Sorting and merging files 115
Sort and merge process . . . . . . . . . . 115
Describing the sort or merge file . . . . . . . 116
Describing the input to sorting or merging . . . 116
Example: describing sort and input files for
SORT . . . . . . . . . . . . . . . 117
Coding the input procedure . . . . . . . 118
Describing the output from sorting or merging . . 118
Coding the output procedure . . . . . . . 119
Restrictions on input and output procedures . . . 119
Requesting the sort or merge . . . . . . . . 120
Setting sort or merge criteria . . . . . . . 121
Choosing alternate collating sequences . . . . 121
Example: sorting with input and output
procedures . . . . . . . . . . . . . 121
Determining whether the sort or merge was
successful . . . . . . . . . . . . . . 122
Stopping a sort or merge operation prematurely 123
Chapter 9. Handling errors. . . . . . 125
Handling errors in joining and splitting strings . . 125
Handling errors in arithmetic operations . . . . 126
Example: checking for division by zero . . . . 126
Handling errors in input and output operations 127
Using the end-of-file condition (AT END) . . . 128
Coding ERROR declaratives . . . . . . . 129
Using file status keys . . . . . . . . . . 129
Using file system return codes. . . . . . . 131
Coding INVALID KEY phrases . . . . . . 132
Handling errors when calling programs . . . . 133
Part 2. Compiling, linking, running
and debugging your program . . . 135
Chapter 10. Compiling, linking, and
running programs . . . . . . . . . 137
Setting environment variables . . . . . . . . 137
Setting environment variables temporarily. . . 137
Setting environment variables persistently . . . 138
Precedence of environment variables . . . . 138
Compiler environment variables . . . . . . 138
Run-time environment variables . . . . . . 140
Compiling programs . . . . . . . . . . . 144
Compiling from the command line . . . . . 144
Compiling using batch files or command files 148
Specifying compiler options with the PROCESS
(CBL) statement . . . . . . . . . . . 148
Correcting errors in your source program . . . . 149
Severity codes for compiler error messages . . 149
Generating a list of compiler error messages . . 150
iv Programming Guide
Linking programs . . . . . . . . . . . . 152
Specifying linker options . . . . . . . . 153
Linking within a project environment . . . . 153
Linking through the compiler . . . . . . . 153
Linking from a make file . . . . . . . . 154
Linking from the command line . . . . . . 154
Linker input and output files . . . . . . . 155
File name defaults . . . . . . . . . . . 156
Correcting errors in linking. . . . . . . . . 156
Linker return codes . . . . . . . . . . 157
Linker errors in program names . . . . . . 157
Running programs . . . . . . . . . . . 158
Chapter 11. Compiler options . . . . 159
ADATA . . . . . . . . . . . . . . . 160
ANALYZE . . . . . . . . . . . . . . 161
BINARY . . . . . . . . . . . . . . . 161
CALLINT . . . . . . . . . . . . . . 162
CHAR. . . . . . . . . . . . . . . . 163
COLLSEQ . . . . . . . . . . . . . . 165
COMPILE . . . . . . . . . . . . . . 166
CURRENCY. . . . . . . . . . . . . . 166
DATEPROC . . . . . . . . . . . . . . 167
DYNAM . . . . . . . . . . . . . . . 168
ENTRYINT . . . . . . . . . . . . . . 168
EXIT . . . . . . . . . . . . . . . . 169
Character string formats . . . . . . . . . 170
User-exit work area . . . . . . . . . . 170
Linkage conventions . . . . . . . . . . 171
Parameter list for exit modules . . . . . . 171
Using INEXIT . . . . . . . . . . . . 171
Using LIBEXIT . . . . . . . . . . . . 172
Using PRTEXIT. . . . . . . . . . . . 173
Using ADEXIT . . . . . . . . . . . . 173
FLAG . . . . . . . . . . . . . . . . 174
FLAGSTD . . . . . . . . . . . . . . 175
FLOAT . . . . . . . . . . . . . . . 176
IDLGEN . . . . . . . . . . . . . . . 177
LIB . . . . . . . . . . . . . . . . . 178
LINECOUNT . . . . . . . . . . . . . 179
LIST . . . . . . . . . . . . . . . . 179
MAP . . . . . . . . . . . . . . . . 180
NUMBER . . . . . . . . . . . . . . 181
OPTIMIZE . . . . . . . . . . . . . . 181
PGMNAME . . . . . . . . . . . . . . 182
PGMNAME(UPPER) . . . . . . . . . . 183
PGMNAME(MIXED) . . . . . . . . . . 183
PROBE . . . . . . . . . . . . . . . 183
PROFILE . . . . . . . . . . . . . . . 184
QUOTE/APOST . . . . . . . . . . . . 184
SEPOBJ . . . . . . . . . . . . . . . 185
Batch compilation . . . . . . . . . . . 185
SEQUENCE . . . . . . . . . . . . . . 186
SIZE . . . . . . . . . . . . . . . . 187
SOSI . . . . . . . . . . . . . . . . 187
SOURCE . . . . . . . . . . . . . . . 188
SPACE . . . . . . . . . . . . . . . 189
SQL . . . . . . . . . . . . . . . . 189
SSRANGE . . . . . . . . . . . . . . 189
TERMINAL . . . . . . . . . . . . . . 190
TEST . . . . . . . . . . . . . . . . 190
THREAD . . . . . . . . . . . . . . . 191
TRUNC . . . . . . . . . . . . . . . 192
TRUNC example 1 . . . . . . . . . . 193
TRUNC example 2 . . . . . . . . . . 193
TYPECHK . . . . . . . . . . . . . . 194
VBREF . . . . . . . . . . . . . . . 195
WSCLEAR . . . . . . . . . . . . . . 195
XREF . . . . . . . . . . . . . . . . 196
YEARWINDOW . . . . . . . . . . . . 197
ZWB . . . . . . . . . . . . . . . . 197
Compiler-directing statements . . . . . . . . 198
Chapter 12. Linker options. . . . . . 203
/? . . . . . . . . . . . . . . . . . 204
/ALIGNADDR . . . . . . . . . . . . . 204
/ALIGNFILE . . . . . . . . . . . . . 204
/BASE . . . . . . . . . . . . . . . 205
/CODE . . . . . . . . . . . . . . . 205
/DATA . . . . . . . . . . . . . . . 206
/DBGPACK, /NODBGPACK . . . . . . . . 206
/DEBUG, /NODEBUG . . . . . . . . . . 206
/DEFAULTLIBRARYSEARCH,
/NODEFAULTLIBRARYSEARCH . . . . . . 207
/DLL . . . . . . . . . . . . . . . . 207
/ENTRY . . . . . . . . . . . . . . . 208
/EXECUTABLE . . . . . . . . . . . . 208
/EXTDICTIONARY, /NOEXTDICTIONARY . . . 208
/FIXED, /NOFIXED . . . . . . . . . . . 209
/FORCE . . . . . . . . . . . . . . . 209
/HEAP . . . . . . . . . . . . . . . 209
/HELP . . . . . . . . . . . . . . . 210
/INCLUDE . . . . . . . . . . . . . . 210
/INFORMATION, /NOINFORMATION . . . . 210