<<< Back Home >>>

SCAN$ 2R2D -- Package For Scanning Images


Go to Table of Contents


1. Introduction

SCAN$ is a set of reentrant assembly language subroutines for scanning ASCII or Fieldata images. Available functions include the translation and copying of characters, the decoding of integer and real numbers, and the extraction of one or more characters under programmer control. Certain SCAN$ functions parallel or complement those of EDIT$; however, the two routines will not conflict, since SCAN$ uses a different set of pointer registers (X4-X6 vs. EDIT$'s X1-X3).

There are four relocatable elements in the SCAN$ package: SCAN$ (194 words), for scan mode initiation and termination, column pointer maintenance, and single character extraction; SCAN$XL (144 words, including an external reference to TABLE$ in SYSLIB), for translating between ASCII and Fieldata; SCAN$C (313 words), containing the functions for multiple character extraction and integer decoding; and SCAN$F (171 words), for decoding real numbers. There is also a MASM procedure element, SCAN$P, with procs for generating calls to the various SCAN$ functions.

The SCAN$ relocatables and any user character type tables (to be discussed later) must be collected at addresses under 65K (0177777), since SCAN$ employs indirect addressing in several key functions.

Registers used: X11, A0-A3, R1. The first call to SCAN$ must be to the function SCAN$, in order to initiate scan mode. The pointer registers X4-X6 are saved at initiation and restored at termination (SCANX$ function), and should not be altered while scan mode is open. During scan mode, X4 will contain the packet address and may be used for accessing the various cells described below.


2. SCAN$ Packet
[Top][Contents]

2.1. Description
[Top][Contents]

SCAN$ requires a 13-word packet whose format is as follows:

   *****  THE SCAN$ PACKET  *****
   :                H1                 :                H2                 :
   :          T1           :          T2           :          T3           :
   :       Q1        :       Q2        :       Q3        :       Q4        :
   :    S1     :    S2     :    S3     :    S4     :    S5     :    S6     :
   :======================================================================*:
 0 :  TSCELL   :   MODE    :  LENGTH   :              IMGADR               :
   :======================================================================*:
 1 :    QWM    :   FSTP    :  CPYCIX   :              CPYWIX               :
   :======================================================================*:
   :_ _ _ _ _ _ _ _ _ _ _ _:_->_* _ _ _ _ _ _ _ CLDRTN_ _ _ _ _ _ _ _ _ _ _:
   :_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _:_+_ _ _ _ _ _ CLADWX_ _ _ _ _ _ _ _:
 2 :   FSPC    :   FDPC    :  SFPTST   :              CLDADR               :
   :======================================================================*:
   :_ _ _ _ _ _ _ _ _ _ _ _:_->_* _ _ _ _ _ _ _ CXLRTN_ _ _ _ _ _ _ _ _ _ _:
   :_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ WORK1X_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _:
   :_ _ _ _ _ _ _ WRKWDS_ _ _ _ _ _ _ _:_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _:
   :_ _WORK1_ _:_ _WORK2_ _:_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _:
   :_ OVFLOW_ _:_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _:
 3 :  CHARIX   :  WORDIX   :  MAXTST   :              CXLADR               :
   :======================================================================*:
 4 :              X11MOD               :               X4MOD               :
   :======================================================================*:
 5 :                                X5SAVE                                 :
   :======================================================================*:
 6 :                                X6SAVE                                 :
   :======================================================================*:
   :_ _ _ _ _ _ _ _ _ _ _ _:_->_* _ _ _ _ _ _ _ TYPTBL_ _ _ _ _ _ _ _ _ _ _:
 7 :      ASTP       :     :  TYPTST   :              TPTBAD               :
   :======================================================================*:
 8 :      ASPC       :      ADPC       :  SKIPBL   :        FSEPCH         :
   :======================================================================*:
   :_ _ _ _ _ _ _ MAXVAL_ _ _ _ _ _ _ _:_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _:
 9 :  DIGITS   :   LEFT    :   RIGHT   :   SIGN    :        STOPCH         :
   :======================================================================*:
10 :   PLUS    :   MINUS   :  PERIOD   :   SPACE   :  CHRSWD   :  XLCHWD   :
   :======================================================================*:
   :_ _ _ _ _ _ _ _ _ _ _ _:_->_* _ _ _ _ _ _ _ LODCHR_ _ _ _ _ _ _ _ _ _ _:
11 :  MDBEFR   :  MDAFTR   :  LDCHXR   :              LDCHAD               :
   :======================================================================*:
   :_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ TPTBLS_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _:
12 :               FDTBL               :              ASCTBL               :
   :======================================================================*:

The following items are supplied by the user and are optional except for length, imgadr, and mode.
0,X4,S1 - TS - May be used as a test-and-set cell. 0,X4,S2 - MODE - Scanning mode. Denotes mode of image being scanned and whether translation to the opposite mode is to occur. Possible values: 0 - ASCII-ASCII. Image is ASCII, will stay ASCII. 1 - ASCII-Fieldata. Image is ASCII; translate to Fieldata. 2 - Fieldata-ASCII. Image is Fieldata; translate to ASCII. 3 - Fieldata-Fieldata. Image is Fieldata, will stay Fieldata. Note: Only modes 0 or 3 may be preset; modes 1 and 2 must be invoked through the SCANM$ function. 0,X4,S3 - LENGTH - Image length in words. Range is 1-63 -- up to 252 ASCII or 378 Fieldata characters. 0,X4,H2 - IMGADR - Starting address of image to be scanned. 1,X4,S2 - FSTP - Fieldata stop character for SCAN$ functions in modes 1 and 3. If other than a space, will function as a stop character in addition to a space. 2,X4,S1 - FSPC - If non-zero, contains the Fieldata separator character expected between mantissa and exponent when decoding single precision floating point numbers in modes 1 and 3. If zero, the exponent, if any, preceded by a + or - Sign, must immediately follow the mantissa. 2,X4,S2 - FDPC - Same as fspc for double precision floating point numbers. 7,X4,Q1 - ASTP - ASCII stop character--same as fstp in modes 0 and 2. 7,X4,H2 - TPTBAD - Address of current character type table (see next section for explanation). 8,X4,Q1 - ASPC - ASCII single precision separator character--same as fspc in modes 0 and 2 8,X4,Q2 - ADPC - ASCII double precision separator character--same as fdpc in modes 0 and 2 12,X4,H1 - FDTBL - Address of Fieldata character type table. 12,X4,H2 - ASCTBL - Address of ASCII character type table.
The following items are set by SCAN$ after certain functions:
3,X4,S1 - OVFLOW - If non-zero after decoding a number, indicates that an overflow or underflow occurred. 3,X4,S1/S2 - WORK1/WORK2 - Used as working storage. May also be set to certain values on return, depending on the function. 3,X4,S3 - MAXTST - If the post-scan error return is taken, and this cell is set after one of the numeric scanning functions (SDEC$, SINTV$, etc.), then the maximum value supplied in the upper half of A0 was exceeded. 9,X4,S1/S2/S3 - DIGITS/LEFT/RIGHT - After a normal return from SSFP$ and SDFP$ contain respectively the total number of digits in the mantissa of the floating point number just decoded, and the number of digits left and right of the decimal point (if any). 9,X4,S4 - SIGN - If non-zero, contains the leading sign ('+' or '-') that preceded the number just decoded (set after SOCT$, SDEC$, SINTV$, SSFP$, and SDFP$).
The remaining items in the packet are used internally by SCAN$.


2.2. S$PKT Procedure
[Top][Contents]

The MASM proc S$PKT may be used to generate a SCAN$ packet:

Label S$PKT[,mode] length,imgadr [F1 F2 ...]

where mode may be 0 or 3 or the strings 'ASCII' or 'FDATA'. If omitted, the current system character set will be assumed.

The optional fields F1, F2, ... May be used to supply additional packet items and may occur in any order. Any character strings supplied in these fields will be converted to the appropriate mode. Each field consists of a 3- or 4-letter identifier subfield, followed by a second subfield containing the character or value desired for that item. Omitted fields default to 0 except for the stop character fields, which default to blank.

Below are listed the possible fields. Use the three-character fields when you plan to use the packet in only one mode. Use the four-character fields when you expect to switch between modes.

'STP','CHAR' - Stop character for packet mode (equivalent to 'astp' for mode 0, 'fstp' for mode 3)

'SPC','CHAR' - Single precision separator character for packet mode

'DPC','CHAR' - Double precision separator character for packet mode

[*]'TBL'[,ADDR] - Address of character type table for packet mode. If the 2nd subfield is omitted, a default table will be generated for the packet mode (see next section for discussion). A leading asterisk will suppress this table's octal listing.

'FSTP','CHAR' - Fieldata stop character

'FSPC','CHAR' - Fieldata single precision separator character

'FDPC','CHAR' - Fieldata double precision separator character

[*]'FTBL'[,ADDR] - Address of Fieldata character type table. The asterisk has the same meaning as for the 'TBL' field. If the address is omitted, a default Fieldata table will be generated.

'ASTP','CHAR' - ASCII stop character

'ASPC','CHAR' - ASCII single precision separator character

'ADPC','CHAR' - ASCII double precision separator character

[*]'ATBL'[,ADDR] - Address of ASCII character type table. Handled the same as the 'FTBL' field.

Examples:   

SCNPK1  S$PKT     14,card 'stp',','

SCNPK2  S$PKT,0   20,input 'stp',';' 'aspc','e' 'adpc','d' .


3. Character Type Table Generation And Usage
[Top][Contents]

3.1. Description
[Top][Contents]

The SCAN$ user may specify that the characters being extracted by a function be of a certain type. The function will stop scanning if it encounters a character not belonging to that type. Up to 36 different character sets may be defined they are identified by the characters 'A'-'Z' and '0'-'9'.

When character sets are used, a character type table must be built. The length of this table is 129 words for modes 0 and 2 and 64 words for modes 1 and 3, since type testing is performed only after any mode translation has taken place. Each word n of the table corresponds to the octal value of the respective ASCII or Fieldata character, and appropriate bits are set in each word to indicate which set or sets that character belongs to: bits 0-25 for 'A' thru 'Z' (right to left), and bits 26-35 For '0' thru '9'.

The last word in an ASCII table (word 128) is used to specify "folding" for each character set: if the bit for a particular set is 1, it means that lower-case letters are to be folded to upper-case if the upper-case letter is a member of the set but the lower-case is not. Conversely, upper-case letters will be converted to lower-case if the lower-case letter is in the set but the upper-case is not. This bit is also used for allowing characters beyond the normal ASCII range; i.e., 0-0177. If the bit is set and the DEL character (0177) is a member of a set, then such out-of-range characters will be allowed.

If the user is not defining any special character sets, then the simplest way to generate a character type table is to include the 'TBL' field in the S$PKT proc call, but without a second subfield. This will generate a table immediately following the SCAN$ packet, in the same mode as the packet, and containing the following predefined character sets:

'A' - Alphanumeric (A-Z, a-z [ASCII], 0-9)

*'C' - COBOL name (A-Z, 0-9, -)

'H' - Any character ("Hollerith"). Does not include ASCII control characters in ASCII tables. Note that this type will allow embedded blanks.

'I' - ASCII control characters 0 thru 037 & 0177 (nul, etx, DC1, etc.). Defined only for ASCII tables.

*'K' - Read/write key (any character except period, comma, semicolon, slash, or blank)

'L' - Letter (A-Z, a-z [ASCII])

'M' - Mathematical operator (+, -, *, /)

'N' - Number (decimal digit) (0-9)

'O' - Octal digit (0-7)

'P' - Prime-enclosed string (any character except a ')

*'Q' - Qualifier (A-Z, 0-9, $, -)

'S' - String enclosed by double quotes (any character except ")

'T' - Test or comparison symbol (<, =, >)

*'U' - Userid or account number (A-Z, 0-9, -, .)

*'V' - Variable name (A-Z, 0-9, $)

*'X' - Hexadecimal digit (0-9, A-F)

*'Y' - Yes or no (y or n)

* ---- These will be "folding" types if generated in an ASCII table.

To suppress the octal listing of the table, flag 'TBL' with an asterisk.

To define your own character sets, you must 1) generate a type table separately from the SCAN$ packet and 2) inform SCAN$ of the table's location. The table must be for the mode in which you will be scanning when you specify the 'type' parameter in a SCAN$ function call.


3.2. S$TYPE Procedure
[Top][Contents]

To generate the table the MASM proc S$TYPE is available:

Label S$TYPE[,*mode,1] [T1 T2 ...]

where mode may be 0, 3, 'ASCII', or 'FDATA'. If 1 is coded after mode, the octal listing of the table will be suppressed, except for the first and last words.

Unless mode is preceded by an asterisk, S$TYPE will first generate the predefined character sets described above; and any user-defined sets will be added to them. If the user redefines a predefined set, that definition will completely replace the preset one.

Each of the fields T1, T2, ... Defines a different character set and may have several subfields, the first of which is always the character set identifier. If an ASCII table is being generated and this identifier is preceded by an asterisk, the character set will be designated as a folding type.

The remaining subfields list the valid characters for that set in any combination of several ways:

1. Specific characters -- individually, in strings, or as octal values: 'ABC+-', or 'A','B','C','+','-', or 06,07,010,042,041. Any of these formats may be preceded by a minus sign to denote exclusion rather than inclusion: -'A', -032, -'I-N'. Multi-character strings must not exceed 8 ASCII or 12 Fieldata characters, based on the mode when S$TYPE is called.

2. Inclusive ranges of characters: 'A-Z' or 'A','THRU','Z' [3 subfields]. Also 'A'+040,'THRU','Z'+040 (lower case).

3. Characters from any previously defined sets: *'M',*'T' (equivalent to '+-*/<=>'). May include a minus sign for exclusion: *-'L'

4. The string 'ALL', meaning all text characters (040 thru 0176 for ASCII, 0 thru 077 for Fieldata) -- same as predefined set 'H'.

5. The string 'EXCEPT', followed by any characters, ranges, or sets to be excluded: 'EXCEPT','A',032,'I-I',*'N'

The following example shows how the predefined character sets 'Q' and 'K' might have been defined using S$TYPE in ASCII mode:

Label  S$TYPE,'ASCII'  *'Q', 'A','thru','Z', '0-9', '$', '-' ;
                       *'K',  041,'THRU',0137,  'EXCEPT', '.,;/' .

Once you have generated your own character set table, you may inform SCAN$ of its location via the SCANM$ function, or through the S$PKT proc, by coding the address of the table as the second subfield of the 'TBL' field. If you are creating both ASCII and Fieldata tables, use the 'ATBL' and 'FTBL' fields. Examples:

SCNPKT S$PKT 14,CARD 'TBL',TBLADR 'SPC','E' .

SCNPKT S$PKT 20,CARD 'ATBL',ASCTBL 'FTBL',FDTBL


4. Basics Of Using SCAN$
[Top][Contents]

Most SCAN$ functions require one or more arguments in A0. Perhaps the most frequently recurring argument is one that is supplied to all functions able to extract more than one character. It takes the form MAXCHR*/6+'type', in which two items are compressed into the lower half of A0 by shifting the first one 6 bits to the left.

MAXCHR is the maximum number of characters to be scanned and extracted by the function. If it is 0, SCAN$ will assume the maximum amount for 63 words unless otherwise indicated (252 ASCII or 378 Fieldata characters).

'Type' is the Fieldata identifier of the character set against which all characters scanned during this function are to be tested. If 'type' is 0, any non-stop character will be accepted. 'Type' may also be set to 077, which means the same as 0 except that leading blanks are not ignored. The coding of 'type' implies that a character type table for the current scanning mode has been created and its address stored in the SCAN$ packet.

When 'type' is a letter, the octal value generated must be for the corresponding Fieldata character (06-037), regardless of scanning mode. This need not concern the user as long as the SCAN$ proc calls are used for all functions; the procedures will always generate the correct value.

All scanning functions begin with the next non-blank character in the image unless 'type' is set to 077 or to the identifier of a character set of which blank is a member. In the cases where leading blanks are ignored, they will not be considered in the final character count and should not be included as part of the MAXCHR argument.

Scanning functions are terminated by a character not in the type being tested for (if one was specified), a stop character (blank or otherwise), or end- of- image. When more than one test is to be performed on an extracted character, the order of testing is for leading blank (unless the character set includes blanks), membership in the given character set, and stop character. Testing stops after the first 'true' test. Any mode 1 or mode 2 translation is performed before testing.

The functions that decode numbers (SOCT$, SDEC$, SINTV$, SSFP$, and SDFP$) all perform their own testing for valid characters, so no type needs to be specified. The only reasons a user might have for doing so would be to disallow leading blanks (077) or otherwise limit the permissible characters in the number being decoded (such as not allowing a leading sign or a decimal point).

SCAN$ maintains a column pointer, initially set to the first column, 0, which is advanced by the number of characters extracted whenever a scanning function is performed. The pointer is never allowed to be advanced beyond the upper or lower bounds of the image; any attempt to do so will cause a scanning function to stop, and the pointer will remain at the end or beginning of the image. If a scanning function is stopped by an invalid character or a stop character, the pointer will point to the column immediately following that character. If the function is stopped because the user's MAXCHR is exhausted, it will point to the column immediately following the last character extracted.

All functions which can extract more than one character (groups 2 & 3 as discussed in the next section) return to the user with registers set as follows:

A0-A1 - Vary depending on the function. Will usually contain extracted characters or a decoded number.

A2 - Has either the character which caused scanning to stop or, if MAXCHR was exhausted, the character immediately following the last one loaded (i.e., the first that will be extracted by the next scanning operation). A2 will be negative, however, if an attempt was made to scan beyond the last word of the image; any further scanning attempts will yield no characters and will return with A2 negative until the column pointer is reset somewhere within the image. A2 will also be returned negative for any group 1 function which exceeds the image length, such as SSKIP$, SCHAR$, or SIMAG$.

A3 - Contains the total number of characters extracted, not including leading blanks if these were ignored.

R1 - If negative, it means that MAXCHR was exhausted and the exact number of characters specified by the user was extracted.
If positive (including 0), the scan was interrupted by an illegal character, a stop character, or end- of- image.

Appropriate testing of these registers can provide one's exact status within the image being processed. For example, if on return from a function both R1 and A2 are negative, it means that the scan function was successfully completed with the exact character count expected, but it was the last item before the end of the image and no further scanning should be attempted on it. (See also the paragraph on optional post-scan processing.)


5. SCAN$ Functions
[Top][Contents]

This section describes the available functions of the SCAN$ package. They are grouped into three sections, according to which relocatable elements they require: 1) SCAN$ only; 2)SCAN$ & SCAN$C; and 3) SCAN$, SCAN$C, & SCAN$F.


5.1. Calling Methods
[Top][Contents]

Following the standard calling method for each function is the corresponding procedure call that may be used instead. Unless otherwise stated, whenever the proc field parameters for a register are omitted in a proc call, the load instruction for that register will not be generated.

Wherever an address or other parameter is required as the last or only subfield in a proc call field, it may be coded in the standard assembler operand format *u,*x,j, where the j-field is assumed to be 016 if omitted (017 if a negative value is allowed).

If a function calls for the MAXCHR*/6+'type' format to be loaded into A0, the two items may be coded in a proc call as the first two subfields of the first field, as will be shown in each example (note that 'type' comes first). Alternatively, the first field may indicate an address where the correct format is located. In the latter case, however, the j field must always be coded, as in 'S$DF addr,,T3'.


5.2. Optional Post-scan Error Testing & Processing
[Top][Contents]

Certain additional processing may be invoked upon completion of all scanning functions which use SCAN$C, except for SDEFT$. The purpose of this processing is to override certain default actions and/or jump to a user-specified alternate return address if any of the following occurs:

1. The scan terminated with A2 containing an invalid character; i.e., not a member of the type being tested for (if any), and not a stop character. If MAXCHR was reached, however, any non-stop, non-blank character immediately following will be considered invalid, whether it is in the given type or not. (Reaching end- of- image, with A2 negative, is not invalid.)

2. The scan terminated with 0 characters extracted (A3 = 0).

3. One of the integer decoding functions (SOCT$, SDEC$, SINTV$) decoded a number larger than the non-zero value loaded into the increment portion of A0 before the call. Refer to these functions for details.

4. An overflow or underflow occurred while decoding a number.

Post-scan processing is triggered by coding an extra word following the LMJ to the function (or following the proc call). This word has the following format:

S1 - Must be 0, to inform SCAN$ that this is the error test word and not the next instruction.

Bit 25 - If set and MAXCHR was reached, position the column pointer after the following character, as though it had been an interrupt or stop character. That following character will still be returned in A2.

Bit 24 - If set, do not jump to the alternate address if MAXCHR was reached but an invalid character was encountered immediately afterwards. This allows for adjoining fields with no intervening spaces or stop character.

Bit 23 - If set, ignore condition 2 above when 0 characters are extracted. This allows for legally void fields or subfields, where the stop character or end- of- image is encountered immediately at the beginning of the scan.

Bit 22 - If set, and scanning was interrupted before MAXCHR was reached, leave the column pointer positioned on the interrupting character instead of on the one after it. The character that caused interruption will then always be the next one to be extracted; this character will be returned in A2.

Bits 21-18 - May specify an index register to modify the address in bits 15-00.

Bits 17-16 - May specify incrementation and indirect addressing.

Bits 15-00 - The alternate error address.

The trigger word may be generated by means of the proc S$CERR:

S$CERR[,*code] *u,*x .

where *u,*x denotes the alternate address and code is as follows:

0 or omitted - The basic error conditions apply (bits 24-23 = 0).

1 - Set bit 23 (0 characters ok)

2 - Set bit 24 (any character after reaching MAXCHR ok)

3 - Set bits 23 & 24. SCAN$ will jump to the error address only if a non-stop, non-member character was extracted prior to reaching either MAXCHR or end- of- image.

4 - Set bit 25 (position after character after MAXCHR).

The 1, 2, and 4, values may be ORed or added in any combination. If the code is preceded by an asterisk, bit 22 will be set. If the address field is omitted, 1,X11 will be generated (normal return).

Note: the jump to the error address is done indirectly. If this address is expected to exceed 65K, the following sequence must be used:

             LX,U   xreg,error-addr . Xreg is X1-X3 or X7-X10
             LMJ    X11,SCAN$-FUNCTION
             S$CERR 0,xreg


5.3. Functions Requiring SCAN$ Only
[Top][Contents]

5.3.1. SCAN$
[Top][Contents]

Initiate scanning mode. Registers X4-X6 are saved and the column pointer is set to 0. If necessary, quarter-word mode is established.

        LA,U A0,pktadr
        LMJ  X11,SCAN$ .

--Proc: S$CAN pktadr


5.3.2. SCANX$
[Top][Contents]

Terminate scanning mode. The column pointer is saved, registers X4-X6 are restored, and the packet address is returned in A0. If quarter-word mode was established at initiation or thru SCANM$, will revert to third-word mode.

LMJ X11,SCANX$ .

--Proc: S$CANX .


5.3.3. SCANR$
[Top][Contents]

Re-establish scanning mode to its status at the time SCANX$ was last called. Registers X4-X6 are saved, the column pointer is restored, and quarter-word mode is re-established if necessary.

        LA,U A0,pktadr .
        LMJ  X11,SCANR$ .

--Proc: S$CANR pktadr .


5.3.4. SCANM$
[Top][Contents]

Alter scanning mode. A0 is loaded with 0, 1, 2, or 3 according to the mode desired. If the mode is to be 1 or 2, the upper half of A0 must be loaded with the address of the SCAN$XL element.

If ASCII or Fieldata type tables are being used and the mode is being switched between 0 or 2 and 1 or 3 (i.e., the mode after translation is being changed), then either the 'FTBL' and 'ATBL' fields must have been used when defining the SCAN$ packet or A1 must be loaded with the address of the new table to be used, if any. In the former case, a switch will be made to the opposite table; in the latter case, the new value will be stored in the packet.

If the mode after translation is not being changed, the table address in the packet will be retained, unless A1 is non-zero.

If the new mode is ASCII before translation, quarter-word mode will be established as needed.

        LA,U A0,0-OR-3   or   LA  A0,(SCAN$XL,1-OR-2)
        LA,U A1,type-table-addr   or   LA,U A1,0 .
        LMJ  X11,SCANM$ .

--Proc: S$CANM mode [type-table-addr] .

where mode may be 0, 1, 2, 3, 'ASCII', 'ASCFD', 'FDASC', 'FDATA', or *u,*x,j. The proc will automatically load the SCAN$XL address for 1, 2, 'ASCFD', 'FDASC', and *u,*x,j. If mode is coded but the type table address is not, A1 will be loaded with 0.


5.3.5. SPRINT$
[Top][Contents]

Print the image, using PRINT$ or APRINT$ based on the input mode before translation. SPRINT$ checks that the image does not exceed maximum length.

LMJ X11,SPRINT$ .

--Proc: S$PRINT .


5.3.6. SCLRI$
[Top][Contents]

Clear image to ASCII or Fieldata blanks, according to current input mode (before translation); and reset the column pointer to 0.

LMJ X11,SCLRI$ .

--Proc: S$CLRI .


5.3.7. SZERI$
[Top][Contents]

Clear image to zeros and set column pointer to 0.

LMJ X11,SZERI$ .

--Proc: S$ZERI .


5.3.8. SCOLN$
[Top][Contents]

Obtain the current column pointer in A0. SCOLN$ uses only A0.

LMJ X11,SCOLN$ .

--Proc: S$COLN [addr] .

If an address is supplied, the proc will generate a store of A0 into it. The j-field is assumed to be 0 if not coded.


5.3.9. SCOL$
[Top][Contents]

Set the column pointer to the number in A0.

        LA,U A0,column .
        LMJ  X11,SCOL$ .

--Proc: S$COL column .


5.3.10. SSKIP$
[Top][Contents]

Advance the column pointer by the number in A0. To back up the pointer, load the number negative into A0.

        LA,U A0,count .
        LMJ  X11,SSKIP$ .

--Proc: S$SKIP count .


5.3.11. SCHAR$
[Top][Contents]

Load the next character in the image into A2.

LMJ X11,SCHAR$ .

--Proc: S$CHAR .

The proc will generate 'ex *11,X4' and thus avoid the LMJ.


5.3.12. SNBC$
[Top][Contents]

Load the next non-blank character in the image into A2. The number of blanks skipped over will be in A3.

LMJ X11,SNBC$ .

--Proc: S$NBC .


5.3.13. SBNBC$
[Top][Contents]

Same as SNBC$, except that the column pointer will be backed up to just before the non-blank character (which will still be in A2).

LMJ X11,SBNBC$ .

--Proc: S$BNBC .


5.3.14. SSTOP$
[Top][Contents]

Define a new stop character for the current mode.

        LA,U A0,+'char' .
        LMJ  X11,SSTOP$ .

--Proc: S$STOP 'char' .


5.3.15. SIMAG$
[Top][Contents]

Switch over to a new image address, length, and column pointer. The new image must be in the same mode as the old one. On return, A3 contains the column, length, and address of the old image in the same format as shown below for A0:

        LA   A0,(column*/6+length,image-addr) .
        LMJ  X11,SIMAG$ .

--Proc: S$IMAG[,column] length,image-addr [save-addr]

Column and length, if coded, may only be integer constants. A single, non-zero subfield in the first field is treated as the address of a word (or register) containing the entire (column*/6+length,image-addr) parameter. If save-addr is coded, the proc will generate a store of A3 into it, allowing the user to revert back to the previous image and column via 'S$IMAG save-addr'.

Or:

--Proc: S$IMAGE[,column] length image-addr [save-addr]

This allows the full *u,*x,j format for column and length as well as image-addr.


5.4. Functions Requiring SCAN$ & SCAN$C
[Top][Contents]

5.4.1. SCTST$
[Top][Contents]

Test the next MAXCHR characters in the image according to the given type, but do not advance the column pointer. (This can serve as a 'look-ahead' function.) A1 will contain the last valid character extracted; A2 and A3 will be loaded as usual for SCAN$C functions.

        LA,U A0,MAXCHR*/6+'type' .
        LMJ  X11,SCTST$ .

--Proc: S$CTST 'type',MAXCHR .


5.4.2. SFD$
[Top][Contents]

Load the next MAXCHR characters in the image into A0-A1 according to the given type, padded and justified according to the code loaded in the upper half of A0:

                  0 - Left-justified, space-filled
                  1 - Right-justified, space-filled
                  2 - Left-justified, zero-filled
                  3 - Right justified, zero-filled

Up to 8 ASCII characters (modes 0 & 2) or 12 Fieldata characters (modes 1 & 3) may be loaded. If MAXCHR is set greater than this maximum, n, and more than n valid characters are encountered, only the last n characters loaded will be returned. If MAXCHR is 0, n will be assumed.

        LA   A0,(code,MAXCHR*/6+'type') .
        LMJ  X11,SFD$ .

--Proc: S$FD,code 'type',MAXCHR .


5.4.3. SCOPY$
[Top][Contents]

Copy the next MAXCHR characters from the image to the given address according to the given type. A positive or negative offset of up to 252 ASCII or 378 Fieldata characters may be applied to the destination address. Upon completion the current location in the destination area is saved in the packet.

        LA,U A0,MAXCHR*/6+'type' .
        LA,U A1,addr   or   LA  A1,(offset,addr) .
        LMJ  X11,SCOPY$ .

--Proc: S$COPY[,offset] 'type',MAXCHR addr .


5.4.4. SCPYR$
[Top][Contents]

Same as SCOPY$, except that the copy operation will begin at that point in the destination area where the previous SCOPY$ or SCPYR$ operation terminated (at least one must have occurred prior to this call). Upon completion the current location in the destination area will again be saved.

        LA,U A0,MAXCHR*/6+'type' .
        LMJ  X11,SCPYR$ .

--Proc: S$CPYR 'type',MAXCHR .


5.4.5. SDEFT$
[Top][Contents]

This function allows the user to redefine a character set in the current type table at execution time. Depending on whether the mode is ASCII (or Fieldata), A1 is loaded with the address of a 4- (or 2-) word packet having bits 0 thru 127 (or 0 thru 63) set according to which of the corresponding characters belong to the character set. Bit 128 of the ASCII packet is the "folding" bit. To clear the set, use 0 for the bit mask address.

        LA,U A0,+'type' .
        LA,U A1,bit-mask-addr .
        LMJ  X11,SDEFT$ .

--Proc: S$DEFT 'type',bit-mask-addr .

Or: S$DEFT[,mode] [*]'type' 'char',char',...'thru',...'except',...

(In the latter proc example the valid characters are listed in the same manner as for the proc S$TYPE. The desired mode must be coded only if it is not the same as the current system character set.)


5.4.6. SDEC$
[Top][Contents]

Decode a decimal integer up to MAXCHR characters long into A0. If the optional post-scan error testing feature is being used, a maximum non-zero value of up to 262143 (0777777) may be loaded into the increment portion of A0 to test against the number decoded; if it is exceeded, SCAN$ will jump to the error address.

   LA,U A0,MAXCHR*/6[+'type'] or LA A0,(maxval,MAXCHR*/6[+'type'])
       [LXI,U A0,maxval .]
        LMJ   X11,SDEC$ .

--Proc: S$DEC[,maxval] 'type',MAXCHR .


5.4.7. SOCT$
[Top][Contents]

Decode an octal integer in the same manner as for SDEC$.

        LA,U  A0,MAXCHR*/6[+'type'] .
       [LXI,U A0,maxval .]
        LMJ   X11,SOCT$ .

--Proc: S$OCT[,maxval] 'type',MAXCHR .


5.4.8. SINTV$
[Top][Contents]

Decode either a decimal or octal integer in the same manner as for SDEC$ or SOCT$, depending on whether the first digit is a leading '0'. On return, if the number was octal, WORK2 will be non-zero. A number with a leading '0' containing '8' or '9' will be considered in error.

        LA,U  A0,MAXCHR*/6[+'type'] .
       [LXI,U A0,maxval .]
        LMJ   X11,SINTV$ .

--Proc: S$INTV[,maxval] 'type',MAXCHR .


5.5. Functions Requiring SCAN$, SCAN$C, & SCAN$F
[Top][Contents]

Note: on return, if WORK2 is non-zero, the sign of the exponent was negative.


5.5.1. SSFP$
[Top][Contents]

Decode a single precision floating point number into A0.

        LA,U A0,MAXCHR*/6[+'type'] .
        LMJ  X11,SSFP$ .

--Proc: S$SFP 'type',MAXCHR .


5.5.2. SDFP$
[Top][Contents]

Decode a double precision floating point number into A0-A1.

        LA,U A0,MAXCHR*/6[+'type'] .
        LMJ  X11,SDFP$ .

--Proc: S$DFP 'type',MAXCHR .


5.5.3. SSNUMV$
[Top][Contents]

Decode a number which may be integer or real. If a decimal point is encountered, SSFP$ will be called; otherwise, SINTV$ will be called. If on return digits is non-zero, the number was real.

        LA,U A0,MAXCHR*/6[+'type'] .
        LMJ  X11,SSNUMV$ .

--Proc: S$SNUMV 'type',MAXCHR .


5.5.4. SDNUMV$
[Top][Contents]

Same as SSNUMV$, except that SDFP$ is called if a decimal point is encountered.

        LA,U A0,MAXCHR*/6[+'type'] .
        LMJ  X11,SDNUMV$ .

--Proc: S$DNUMV 'type',MAXCHR .


5.5.5. SSDNMV$, SDDNMV$
[Top][Contents]

Same as SSNUMV$ and SDNUMV$, except that SDEC$ instead of SINTV$ will be called if no decimal point is encountered.

        LA,U A0,MAXCHR*/6[+'type'] .
        LMJ  X11,SSDNMV$   or   LMJ  X11,SDDNMV$ .

--Procs: S$SDNMV 'type',MAXCHR . S$DDNMV 'type',MAXCHR .

6. Changes Since Earlier Levels [Top][Contents]

6.1. Changes in SCAN$ 2R2B (since 2R2A)
[Top][Contents]

Addition of one word to SCAN$ packet, to allow both ASCII and Fieldata character type tables to be prestored so SCAN$ can switch between them automatically.

Addition of 'FTBL' and 'ATBL' fields to S$PKT call to define these tables.

Correction of bugs in S$CANM procedure that would sometimes load incorrect values for *u,*x,j or string items in the first argument.


6.2. Changes in SCAN$ 2R2C (since 2R2B)
[Top][Contents]

Addition of bit 25 to optional post-scan testing word. This causes the column pointer to be positioned after the character following the item extracted, even if MAXCHR was reached.

MAXTST cell (3,X4,S3) set if maximum value exceeded by numeric scans.

Upgrading of procedures that need maxchr*/6+'type' argument, so that they may use EQUF labels to denote where the whole argument is, as well as the u,x,j format.

Fix bug in post-scan error testing (S$CERR) after SCTST$ routine.

Add ability to define SCAN$ type to include out-of-range ASCII characters (>0177).

Add SBNBC$ function and S$BNBC proc.

Add SPRINT$ function and S$PRINT proc.


Table of Contents

(Go to Top)

1. Introduction
2. SCAN$ Packet
2.1. Description
2.2. S$PKT Procedure
3. Character Type Table Generation And Usage
3.1. Description
3.2. S$TYPE Procedure
4. Basics Of Using SCAN$
5. SCAN$ Functions
5.1. Calling Methods
5.2. Optional Post-scan Error Testing & Processing
5.3. Functions Requiring SCAN$ Only
5.3.1. SCAN$
5.3.2. SCANX$
5.3.3. SCANR$
5.3.4. SCANM$
5.3.5. SPRINT$
5.3.6. SCLRI$
5.3.7. SZERI$
5.3.8. SCOLN$
5.3.9. SCOL$
5.3.10. SSKIP$
5.3.11. SCHAR$
5.3.12. SNBC$
5.3.13. SBNBC$
5.3.14. SSTOP$
5.3.15. SIMAG$
5.4. Functions Requiring SCAN$ & SCAN$C
5.4.1. SCTST$
5.4.2. SFD$
5.4.3. SCOPY$
5.4.4. SCPYR$
5.4.5. SDEFT$
5.4.6. SDEC$
5.4.7. SOCT$
5.4.8. SINTV$
5.5. Functions Requiring SCAN$, SCAN$C, & SCAN$F
5.5.1. SSFP$
5.5.2. SDFP$
5.5.3. SSNUMV$
5.5.4. SDNUMV$
5.5.5. SSDNMV$, SDDNMV$
6. Changes Since Earlier Levels
6.1. Changes in SCAN$ 2R2B (since 2R2A)
6.2. Changes in SCAN$ 2R2C (since 2R2B)