This program shows how to display a format text field from 3GL code. It builds the screen and format tables with 8OPENS, shows each record with 8PRINT and calls the 8TEXTF API to show the text field in a scrolling window.

* This program is and example of how to print a text field from a file from
* 3GL code using the API 8TEXTF.
* Example of calling 8TEXTF directly
00200 OPEN(1)"UTCUST"; ! Open data file on channel
! for text processing by
! 8TEXTF.
OPEN(2)"UTCUST"; ! Open same data file on
! channel for reading text
! keys.
DIM SCREEN$[24], ! Dim screen array,
FORMAT$[17]; ! format array.
LET SCREEN$[0]="UTCUST", ! Set screen name,
FORMAT$[0]="UTCUST", ! format name.
DATA$=""; ! Clear record data area.
CALL "8OPENS","S",SCREEN$[ALL], ! Call 8OPENS to build screen
FORMAT$[ALL],DATA$,]SYSV$; ! and format tables.
SCREEN$[10](9,1)=CHR(11), ! Set text field format entry
! number.
SCREEN$[22]=PAD(SCREEN$[22],17), ! Dim text field table.
SCREEN$[22](1,2)=BIN(1,2), ! Set channel for text record
! processing.
SCREEN$[22](3,1)="N", ! Set 'No' flag to not use the
! valid value list in format
! definition of the text field
SCREEN$[22](4,1)="G", ! Graphic border
SCREEN$[22](5,1)="A", ! text field A
SCREEN$[22](6,1)=CHR(8), ! # of lines in window
SCREEN$[22](7,1)=CHR(60), ! # of characters per line
SCREEN$[22](8,1)=CHR(1), ! line 1 of window
SCREEN$[22](9,1)=CHR(1) ! column 1 of window
00210 SCREEN$[17]=KEY(2,END=290); ! Get the next key.
IF SCREEN$[17](1,1)<>$FF$ ! If not a text record
READ RECORD(2,KEY=SCREEN$[17])DATA$; ! Read the data record.
CALL "8PRINT","CB",SCREEN$[ALL], ! Call 8PRINT to display
FORMAT$[ALL],DATA$,]SYSV$; ! data record.
CALL "8TEXTF","D",SCREEN$[ALL], ! Call 8TEXTF to display,
FORMAT$[ALL],C,]SYSV$; ! scroll, exit.
GOTO 210 ! Get next key.
FI ! Endif.
00290 END ! End.

Notes

  • The data file is opened twice: channel 1 is used by 8TEXTF for the text records and channel 2 is used to read the keys.
  • SCREEN$[22] holds the text field table: channel, valid value flag, border, text ID, window size and position.
  • Text record keys start with $FF$ and sort after the data records, so the program ends when it reaches the first one.

Search tbred.com