Non-standard extensions

SELECT ASSIGN TO

A file may be assigned to a literal file, a file in a variable, or a file in an environment variable.

Literal file.

Assign to a literal file.

Select <file> assign to "/tmp/myfile.txt".

<variable>

Assign to a file which name is read from a variable.

Select <file> assign to my-file.

01  my-file            pic x(512).

Move "/tmp/myfile.txt" to my-file.
Open output <file>.

<environment variable>

Assign to a file in an environment variable.

export myfile=/tmp/myfile.txt

Select <file> assign to external myfile.

Indexed file packages

<This section is in progress.>

Extended ACCEPT statement

Extended ACCEPT statements allow for full control of items accepted from the screen. Items accept by line and column positioning.

All commands following WITH are optional.

ACCEPT <variable-1>
   LINE <variable-2> | <literal-1> COLUMN <variable-3> | <literal-2>
   WITH
      AUTO-SKIP | AUTO
      BACKGROUND-COLOR <variable-4 >| <literal-3>
      BELL | BEEP
      BLINK
      FOREGROUND-COLOR <variable-5> | <literal-4>
      LOWLIGHT | HIGHLIGHT
      PROMPT
      PROTECTED
      SIZE [IS] <variable-6> | <literal-5>
      UPDATE
   ON EXCEPTION
      <exception processing>
   NOT ON EXCEPTION
      <normal processing>
END-ACCEPT.

LINE

The line number of <variable-2> or <literal-1> to accept the field.

COLUMN

The column number of <variable-3> or <literal-2> to accept the field.

AUTO-SKIP

The word AUTO may be used for AUTO-SKIP.

With this option the ACCEPT statement returns after the last character is typed at the end of the field. This is the same as if the Enter key were pressed.

Without this option the cursor remains at the end of the field and waits for the user to press Enter.

The Right-Arrow key returns from the end of the field. The Left-Arrow key returns from the beginning. ACCEPT special.

The Alt-Right-Arrow and Alt-Left-Arrow keys never AUTO-SKIP.

BACKGROUND-COLOR

The background color is the color used behind the characters.

<Variable-4> or <literal-3> must be numeric. See file screenio.cpy for the color assignments to <variable-4> or <literal-3>.

BELL

The word BEEP may be used for BELL.

The system beeps when the cursor moves to accept from this field. On some systems, there is no sound. Some other method may indicate a beep, such a flashing screen or pop up window.

FOREGROUND-COLOR

The foreground color is the color used for the characters.

<Variable-5> or <literal-4> must be numeric. See file screenio.cpy for the color assignments to <variable-5> or <literal-4>.

LOWLIGHT

The LOWLIGHT and HIGHLIGHT phrases vary the intensity of the field.

LOWLIGHT displays with lower intensity and HIGHLIGHT displays with higher intensity. Having neither LOWLIGHT nor HIGHLIGHT displays at normal intensity.

These may have different levels of intensity, if at all, depending on the make and model of the screens.

PROMPT

Display the field with prompt characters as the cursor moves to accept from this field.

PROTECTED

PROTECTED is ignored.

SIZE

The size of <variable-1> to accept from the screen.

<Variable-6> or <literal-5> must be numeric.

  • SIZE <greater than zero>

    If <variable-6> or <literal-5> is less than the length of <variable-1> then only the SIZE number of characters accept into the field. <Variable-1> pads with spaces after SIZE to the end of the field.

    If <variable-6> or <literal-5> is greater than <variable-1>, then the screen pads with spaces after <variable-1> to the SIZE length.

  • SIZE ZERO

  • <SIZE option not specified>

    The <variable-1> accepts to its field length.

UPDATE

The contents of variable-1 displays on the screen as the ACCEPT begins. This allows the user to update the field without having to type it all again.

Without this option, the ACCEPT field is always blank.

ON EXCEPTION

Check the special register cob-crt-status for the special key that was pressed. This includes Escape, Tab, Back-Tab, F-keys, arrows, etc… See screenio.cpy for the values.

NOT ON EXCEPTION

Reset any F-key indicator because no special key was pressed.

ACCEPT special keys

Special keys are available for extended ACCEPT statements.

The COB-CRT-STATUS values are in the screenio.cpy copy file.

Arrow keys

The Left-Arrow key moves the cursor to the left. Without AUTO-SKIP the cursor stops at the beginning of the field. With AUTO-SKIP it returns with the COB-SCR-KEY-LEFT value of 2009. Extended ACCEPT.

The Alt-Left-Arrow key is the same as Left-Arrow except that it never returns, even for AUTO-SKIP.

The Right-Arrow key moves the cursor to the right. Without AUTO-SKIP the cursor stops at the end of the field. With AUTO-SKIP it returns with the COB-SCR-KEY-RIGHT value of 2010. Extended ACCEPT.

The Alt-Right-Arrow key is the same as Right-Arrow except that it never returns, even for AUTO-SKIP.

Backspace key

The Backspace key moves the cursor, and the remainder of the text, to the left.

Delete keys

The Delete key deletes the cursor’s character and moves the remainder of the text to the left. The cursor does not move.

The Alt-Delete key deletes all text from the cursor to the end of the field.

End key

The End key moves the cursor after the last non-space character. Pressing the End key again moves the cursor to the end of the field. Repeated pressing moves the cursor back and forth.

Home key

The Home key moves the cursor to the first non-space character. Pressing the Home key again moves the cursor to the beginning of the field. Repeated pressing moves the cursor back and forth.

Insert key

The Insert key changes the insert mode.

The value of the insert mode is used in all following ACCEPTstatements while the program is running.

When the insert mode is on, typed characters move the existing characters to the right until field is full. When it is off, typed characters type over existing characters.

Note: The insert mode is ignored for fields with a size of 1.

The insert mode can also be changed by the COB_INSERT_MODE setting at any time, Appendix I.

Tab keys

The Tab key returns from the ACCEPT with the COB-SCR-TAB value of 2007.

The Shift-Tab key returns with the COB-SCR-BACK-TAB value of 2008.

Extended DISPLAY statement

Extended DISPLAY statements allow for full control of items that display on the screen. Items display by line and column positioning.

DISPLAY <variable-1> | <literal-1> | <figurative constant>
   LINE <line> COLUMN <column>
   WITH BELL
        BLANK LINE | SCREEN
        ERASE EOL | EOS
        SIZE [IS] <variable-2> | <literal-2>
END-DISPLAY.

BELL

Ring the bell. It is optional.

BLANK

Clear the whole line or screen. It is optional.

  • BLANK LINE

    Clear the line from the beginning of the line to the end of the line.

  • BLANK SCREEN

    Clear the whole screen.

ERASE

Clear the line or screen from LINE and COLUMN. It is optional.

  • ERASE EOL

    Clear the line from LINE and COLUMN to the end of the line.

  • ERASE EOS

    Clear the screen from LINE and COLUMN to the end of the screen.

SIZE

The size of <variable-1>, <literal-1>, or <figurative-constant> to display onto the screen. It is optional.

  • SIZE <positive-integer>

    If SIZE is less than the length of <variable-1> or <literal-1> then only the SIZE number of characters display.

    If SIZE is greater than the length of <variable-1> or <literal-1>, then the screen pads with spaces after the field to the SIZE length.

    Figurative constants display repeatedly the number of times in SIZE. Except that LOW-VALUES always positions the cursor (see SIZE ZERO below).

  • SIZE ZERO

  • <SIZE option not specified>

    <Variable-1> or <literal-1> displays with the field length.

Figurative Constants

Certain figurative constants and values have special functions. All other figurative constants display as a single character.

  • SPACE

    Display spaces from LINE and COLUMN to the end of the screen. This is the same as WITH ERASE EOS.

  • LOW-VALUE

    Position the cursor to LINE and COLUMN. The next DISPLAY statement does not need a LINE or COLUMN to display at that position.

  • ALL X"01"

    Display spaces from LINE and COLUMN to the end of the line. This is the same as WITH ERASE EOL.

  • ALL X"02"

    Clear the whole screen. This is the same as WITH BLANK SCREEN.

  • ALL X"07"

    Ring the bell. This is the same as WITH BELL.

CONTENT-LENGTH

FUNCTION CONTENT-LENGTH returns the length of NUL byte terminated data given a pointer:

 identification division.
 program-id. zlen.
 data division.
 working-storage section.
 01 ptr   usage pointer.
 01 str   pic x(4) value z"abc".

*> Testing CONTENT-LENGTH
 procedure division.

 set ptr to address of str
 display content-length(ptr)

 goback.
 end program hosted.

CONTENT-OF

FUNCTION CONTENT-OF returns an alphanumeric field given a pointer and optional length:

Data from pointer is returned as a COBOL field either by scanning for a NUL byte or using the optional length. Reference modification of result allowed.

 identification division.
 program-id. contents.
 data division.
 working-storage section.
 01 ptr   usage pointer.
 01 str   pic x(4) value z"abc".

*> Testing CONTENT-OF
 procedure division.

 set ptr to address of str
 display content-of(ptr)
 display content-of(ptr, 2)
 display content-of(ptr)(2:2)

 goback.
 end program hosted.