1 CONSAD The following are currently in the CONSAD library ( LIB$CONSAD: ) and will be automatically linked into your program. Additional help may be obtained by typing "HELP CONSAD routine_name". Routine type args use ADTOxL I*4 (LIST,MAX,N,ENTRY) ADD ITEM TO LIST IF NEW xBSRCH L*4 (LIST,SIZE,N,ITEM) BINARY SEARCH OF LIST ISALPHA L*4 (CHAR) DETERMINE IF CHAR IS LETTER ISDIGIT L*4 (CHAR) DETERMINE IF CHAR IS NUMERIC ISINIL I*4 (LIST,SIZE) SEQUENTIAL SEARCH OF LIST FIND_NW I*4 (LINE,POS) FIND 1ST NON-BL OR TAB FIND_SP I*4 (LINE,POS) FIND 1ST BLANK OR TAB LOCATE I*4 (STR,POS,CHARS) FIND FIRST OCCURRENCE OF CHARS RJUST SUBR (STRING) RIGHT JUSTIFY STRING SETDIV0 SUBR ---- STD FIXUP FOR DIVIDE ZERO ERRS STREQ L*4 (S1,S2) STRING COMPARE DISREGARDING CASE TRULEN I*4 (STRING) FIND ACTUAL LENGTH xxSRdn SUBR (ARRAY,N) SORT ARRAY (VARYING TYPES) VERIFY I*4 (STR,POS,CHARS) VERIFY THAT CHARS ARE LEGAL 2 ADTOxL This function adds an item to a list of items if the item is not already in the list. It returns the index number of the item in the list and returns the value 0 if the maximum number of entries has been exceeded. Usage: INDEX = ADTOxL(LIST,MAX,N,ENTRY) Argument type use LIST ARRAY HOLDS ITEMS ALREADY ENTERED MAX I*4 MAXIMUM NUMBER OF ITEMS ALLOWED N I*4 NEW NUMBER OF ITEMS IN LIST ENTRY x ITEM TO BE ADDED TO LIST IF NOT IN IT ADTOxL I*4 RETURNED AS ITEM # OF ENTRY (0=FULL) Current versions are: ADTOIL - For Integer*4 lists ADTOCL - For character lists 2 xBSRCH This function performs a binary search of a list of items for the particular item sought and returns the value TRUE if the item is in the list and FALSE otherwise. In addition, it returns the index number of the item. Usage: FOUND = xBSRCH(LIST,SIZE,N,ITEM) Argument type use LIST ARRAY LIST OF ITEMS IN SORTED ORDER SIZE I*4 NUMBER OF ITEMS IN LIST N I*4 RETURNED AS INDEX NUMBER IF ITEM FOUND ITEM x ITEM TO LOOK FOR IN LIST xBSRCH L*4 RETURNS TRUE IF ITEM FOUND, ELSE FALSE Current versions are: CBSRCH - For character lists IBSRCH - For Integer*4 lists 2 FIND_NW This function finds the first non-blank or non-tab character in a character string and returns the position offset from the beginning of the string. Usage: NON_BL_AT = FIND_NW(LINE,POS) Arguments type use LINE CHAR THE STRING TO SEARCH IN POS I*4 WHERE TO START LOOKING IN LINE FIND_NW I*4 POSITION WHERE NEXT NON-BL/TAB FOUND. 2 FIND_SP This function finds the first blank or tab in a character string and returns the position as an offset from the beginning of the string. Usage: SPACE_AT = FIND_SP(LINE,POS) Arguments type use LINE CHAR THE STRING TO SEARCH IN POS I*4 WHERE TO START LOOKING IN LINE FIND_SP I*4 POSITION WHERE NEXT NON-BL/TAB FOUND. 2 ISALPHA This routine returns .TRUE. if its character argument is an alphabetic character (a-z, A_Z). Usage: ALPHA = ISALPHA(CHAR) Arguments type use CHAR CHAR THE CHARACTER TO BE TESTED ISALPHA L*4 THE RETURN TRUTH OR FALSE VALUE 2 ISDIGIT This routine returns .TRUE. if its character argument is a decimal digit (0-9). Usage: DIGIT = ISDIGIT(CHAR) Arguments type use CHAR CHAR THE CAHRACTER TO BE TESTED ISDIGIT L*4 THE RETURN TRUTH OR FALSE VLAUE 2 ISINIL This routine does a sequential search of a list to look for and item, and returns the index number in the list if it is found, otherwise 0 is returned. Usage: INDEX = ISINIL(LIST,SIZE,ITEM) Arguments type use LIST ARRAY THE LIST TO BE SEARCHED SIZE I*4 THE NUMBER OF ITEMS IN THE LIST ITEM x THE ITEM SOUGHT ISINIL L*4 THE RETURNED INDEX NUMBER 2 LIB_CLR_BIT Clears a bit in a bit array. A bit array is a section of memory (for instance, an INTEGER array) that the programmer wishes to treat as an array of bits. This routine clears any bit in that array. The bits are numbered logically from the beginning starting at 0 for the first bit. Usage: CALL LIB_CLR_BIT(BITNO,BITARRAY) Arguments type use BITNO I*4 Index of bit to be zeroed BITARRAY any Base address of the bit array 2 LIB_SET_BIT Sets a bit in a bit array. A bit array is a section of memory (for instance, an INTEGER array) that the programmer wishes to treat as an array of bits. This routine clears any bit in that array. The bits are numbered logically from the beginning starting at 0 for the first bit. Usage: CALL LIB_BIT_TST(BITNO,BITARRAY) Arguments type use BITNO I*4 Index of bit to be set (0-n) BITARRAY any Base address of the bit array 2 LIB_TST_BIT Tests a bit in a bit array. A bit array is a section of memory (for instance, an INTEGER array) that the programmer wishes to treat as an array of bits. This routine clears any bit in that array. The bits are numbered logically from the beginning starting at 0 for the first bit. Usage: VALUE = LIB_TST_BIT(BITNO,BITARRAY) Arguments type use VALUE I*4 Returned as -1 (TRUE) if bit is set, otherwise as 0 (FALSE) if not BITNO I*4 Index of bit to be tested (0-n) BITARRAY any Base address of bit array 2 LOCATE This subroutine is used to find the first occurrence of one of a set of characters in a string. For instance, it might be used to find the first occurrence of a FORTRAN mathematical operator in a line. Usage: LOC = LOCATE(STR,POS,CHARS) Arguments type use STR CHAR THE STRING TO SEARCH IN POS I*4 THE STARTING POSITION IN STR CHARS CHAR THE SET OF CHARS YOU ARE INTERESTED IN 2 RJUST This subroutine right justifies a string. This is done by copying the string to itself and eliminating any blanks or tabs in the rightmost character positions. The sole argument is a character variable. Usage: CALL RJUST(STRING) Arguments type use STRING CHAR THE CHARACTER VARIABLE TO RJUST 2 SETDIV0 This subroutine is called to bypass the normal error processing if a floating point or integer divide by zero error occurs in your program. The standard fixup of replacing the result with zero is taken. There are no arguments to this subroutine. Usage: CALL SETDIV0 2 STREQ This function compares two character string arguments and returns the value true if they are the same string, disregarding case (upper and lower cases are equivalent). In addition, blanks are treated as tabs, and any trailing blanks or tabs in either string are ignored. The arguments may be any character expression. The function returns the logical value .TRUE. if the strings are equivalent. Usage: EQUAL = STREQ(STRING_1,STRING_2) Arguments type use STRING_1 CHAR THE FIRST CHARACTER STRING STRING_2 CHAR THE SECOND CHARACTER STRING 2 TRULEN This function returns the actual length of a string (less any trailing blanks or tabs). The length is returned as zero if the string is empty. Usage: LENGTH = TRULEN(STRING) Arguments type use STRING CHAR A character variable or expression TRULEN I*4 Returned as actual length 2 xxSRdn This package comprises a set of array sorting subroutines. There are several different varieties, distinguished by the first 2 letters of the subroutine name. Sorts can proceed in ascending (d=A) or descending (d=D) order. Finalle\y, provision is made for sorting more than one array (n=#) according to the order of the first array. Usage: CALL xxSRdn(MASTER {SUB1,...} , N) Arguments type use MASTER ARRAY THE ARRAY TO BE SORTED SUB1... ARRAY ANY SUB-ARRAYS TO BE COSORTED N I*4 THE NUMBER OF ELEMENTS IN THE ARRAY Current versions are: I4SRA1 - Sorts an INTEGER*4 array in ascending order I4SRA2 - Sorts 2 INTEGER*4 arrays I4SRA3 - Sorts 3 INTEGER*4 arrays I2SRA1 - Sorts an INTEGER*2 array in ascending order R4SRA1 - Sorts a REAL*4 array in ascending order CHSRA1 - Sorts a character (<= *132) array CHSRA2 - Sorts 2 character arrays 2 VERIFY This subroutine is sort of the opposite of LOCATE - it finds the first instance of a character which does NOT belong to the specified set. An example of usage might be to determine that all characters in a token were either alphabetic, numeric, or certain special characters. Usage: NOT_VALID = VERIFY(STR,POS,CHARS) Arguments type use STR CHAR THE STRING TO SEARCH IN POS I*4 THE STARTING POSITION IN STR CHARS CHAR THE SET OF VALID CHARACTERS