CDS257

Read/Print/Import/Convert Window Text

Last Revised: 10/25/16

The purpose of this routine is to read, print, import, or convert window text.  Window text, also called Notepad by most applications, is created using CDS069 with a type of W, but it can also be created or appended to using this called program.

Window text may be stored in an SKY or MKY file.  The key structure is a text identifier followed by a U(1) record number starting at zero.  The characters per record can be any convenient size, typically 128, 256, 512, 1024, etc.  Since only 256 records can be stored per text id, the characters per record determine the maximum notepad size.  Note that the characters per record are not in any way related to the width of the entry window.

When this routine is called from application programs, it is usually used to print window text that has been previously entered.  This routine will optionally print the window border as well as the text contained within the border.

See also CDS261 Return Window Text, and CDS054 Window Text - Copy/Delete.

When used to print window text, the format is:

CALL "CDS257", Y$, TEXTID$, TITLE$, FILECHAN$, STS$, INDENT, 0, 0, 0, Y6$, Y5$, Y5A$, INDENT$

In its most complete form, CDS257 is called using the following variables:

CALL "CDS257", Y$, TEXTID$, TITLE$, FILECHAN$, STS$, COLS, ROWS, XPOS, YPOS, ATTRB$, ATTRW$, WT$, WA$, IMPORT$

CDS257
Y$ In/Out Session Control Variable
TEXTID$ In Text ID, such as a customer#, vendor#, item#, etc.
TITLE$ In title string to be used if the window is to be printed
FILECHAN$ In text file name or STR(channel#) if pre-opened by calling routine
STS$(1,1) In Action Code.  Only Action Codes P, T and W are typically needed by application programs.
DDisplay only (default value)
dDisplay only, but just exit and do not prompt operator if text is not on file
HDisplay Help text
MMaintain text
PPrint to printer.  See example.
TRead notepad text and return text only, no attributes in WT$.  Each line of text will be COLS characters long.  WT$ will be returned as null, and there will be no operator prompt if text is not on file.  See example below.
SImport text string, format, and write to disc
WConvert & write notepad text to disc.  See IMPORT$ and example below.
RRead notepad text
STS$(2,1) In Print window border.  This applies only when STS$(1,1)="P" and the target printer supports standard box drawing characters.
Wprint double line window border (default value)
Sprint single line window border
Ndo not print window border
STS$(3,1) In Print headings on new page after page break.  Only applies when STS$(1,1)="P".
Y (default value)Print standard new page headings as required, including Company Name centered on top line, Documentation Control Number and Y5$ (centered) on second line, and Date, Y5A$, and Page number on third line.
NDo not print headings at top of page
STS$(4,1) In Print in 8 lines per inch.  Only applies when STS$(1,1)="P".
Y Print notepad text using 8 lines per inch.   This is preferred when printing the window border with a proportional font so that the vertical lines are continuous and do not have breaks between the vertical border or line drawing characters.
N (default value)Print notepad text at the current lines per inch setting, typically 6.
COLS In/Out window width (data only, not border).  Defaults to 78 if passed as zero. When reading existing notepad text, and COLS is passed as non-zero, and COLS is passed as a value lower then when window text was originally saved, then COLS will be returned with the value used when the text was originally saved.
ROWS In window height (data only, not border).  If passed as zero, ROWS will be computed to the maximum size possible, excluding top two lines of display.


When STS$(1,1)="T", ROWS determines the size of the output string WT$.  To return the entire notepad text, even if it exceeds the window size, then pass ROWS as the total number of lines in the notepad text.  The total number of lines can be determined using CDS261.

XPOS In starting column position of the window. 
YPOS In starting row position of the window
ATTRB$ In Optional attributes containing mnemonics when displaying window border.  Typically includes text and cell background colors such as 'SF+'CYAN'+'BACKGR'+'BLACK'.  Default value is a 'WHITE' border on the current cell background color.
ATTRW$ In Optional attributes containing mnemonics when displaying the window text such as 'YELLOW'+'BACKGR'+'RED'.  Default value is 'WHITE' text on the current cell background color.
WT$ In/Out Window text.  Output when STS$(1,1)="T"WT$ consists of ROWS rows of COLS characters per row.  So if ROWS=3 and COLS=60, WT$ will be 180 characters long, with line 1 at WT$(1,60), line 2 at WT$(61,60) and line 3 at WT$(121,60).
WA$ In/Out Window text attributes.  Same length as WT$ with bbx attribute bits set for each character.  Not typically needed by application software.
IMPORT$ In Used when converting text to window text when STS$(1,1)="W"IMPORT$ can also contain the mnemonics 'LF' to advance to the next line, 'BU' & 'EU' to begin and end underlining, 'SF & 'SB' to make text bold and dim, 'BR' & 'ER' to begin and end reverse video, 'BB' & 'EB' to begin and end blinking text, column positioning expressions @(COL), and combination attributes using 'ATTR'.  See example below.
INDENT In number of positions to indent window from left edge. If set to -1, then the window text will be centered on the page
INDENT$ In When passing INDENT as a positive number, you may optionally pass INDENT$ which will be printed at the left edge of the page.  It can be up to INDENT-1 characters long and will print on the first line of notepad text.  It is typically used to print the notepad date or other segment in the notepad TEXTID$.
Y6$ In/Out the printer control variable returned from printer selection routine CDS084.

Note, that Y6$ contains the current line counter Y6.L and the current page number Y6.P, and the maximum lines per page Y6.MAXL. Y6.L and Y6.P are modified by this program as data is printed.

Earlier versions of this program passed L, P, and Y6 as arguments, which are no longer supported.

Y5$ In optional report heading to print centered under company name
Y5A$ In optional second line of report heading, printed under Y5$

When printing, note that CDS257 will not print anything if there is no text for the specified text ID.  No error message will be displayed.  This eliminates the need for the application program to test and see if there is any text on file before calling CDS257.  Only the number of lines with actual text will be printed, i.e., any trailing blank lines in the window will not be printed.

Printing example: used during Purchase Order printing to print the company Terms & Conditions stored in file XXPO43 with a message ID of "STANDARD_NOTEPAD".  PO00.STDNOTEPAD contains the total number of lines of notepad text.
1380 IF PO00.STDNOTEPAD THEN LET MSGID$="STANDARD_NOTEPAD",LINES=PO00.STDNOTEPAD, INDENT=0; GOSUB NOTEPAD


3500 NOTEPAD:
3510 IF Y6.L<LINES+2 THEN GOSUB NEWPAGE
3520 CALL "CDS257",Y$,MSGID$,"","XXPO43","P",INDENT,0,0,0,Y6$
3690 RETURN

When importing text, the user will be prompted when there are invalid characters in the text to be imported.  Notepad text can contain ASCII characters, bbx mnemonics and cursor positioning expressions, carriage return, and line feed characters.  Other characters including letters displayed with diacritical marks are considered invalid.  Invalid characters are replaced with blanks.  In these cases you may want to edit the notepad text using CDS069, replacing the invalid character that was replaced with a blank, with the plain letter.  You can suppress the operator prompt warning about invalid characters by setting global variable "SMS_CDS258_MSG" to "N".  Note that all invalid characters will be replaced with a blank, regardless of the prompt.

Importing text will replace any existing text with same Text ID. You can however, import text into a temporary file or Text ID, then use CDS054 to append imported text to end of existing text. Then you can use CDS054 to delete text from temporary location, or if imported into a temporary file, just erase the temporary file using CDS075.

 

Importing example: used to convert some plain text to notepad text
1000 EXAMPLE:
1010 LET NPK$="EXAMPLE_TEXTID"
1020 LET COLS=60; REM "Could be left zero for 78 column text
1030 CALL "CDS095",PO43,"XXPO43"; REM "Open notepad file
1040 LET NP$="Line 1 will be dim (background)"+'LF'
1050 LET NP$=NP$+'SF'+"Line 2 will be bold (foreground)"+'SB'+'LF'
1060 LET NP$=NP$+'BU'+"Line 3 will be underlined"+'EU'+'LF'+'LF'
1070 LET NP$=NP$+'BR'+"Line 5 will be in reverse video"+'ER'+'LF'
1080 LET NP$=NP$+@(10)+"Line 6 will start at column 10 of the window"+'LF'
1090 LET NP$=NP$+'BB'+"Line 7 will blink"+'EB'
1100 CALL "CDS257",Y$,NPK$,"",STR(PO43),"W",COLS,0,0,0,"","","","",NP$
1110 REM "The above lines saved NP$ in the Window Text file XXPO43
1120 REM "The following line could be used to display & modify the text
1130 CALL "CDS069",COLS,0,0,0,"Example","W{XXPO43,EXAMPLE_TEXTID}"
Text example: used to retrieve notepad text excluding all attributes.
1200 EXAMPLE:

1210 LET NPK$="EXAMPLE_TEXTID"
1220 CALL "CDS261",Y$,"XXPO43",NPK$,"",LINES
1230 CALL "CDS257",Y$,NPK$,"","XXPO43","T",COLS,LINES,0,0,"","",WT$
1240 PRINT LEN(WT$),LEN(WT$)/COLS
1250 FOR H=1 TO LEN(WT$) STEP COLS
1260 PRINT WT$(H,COLS)
1270 NEXT H