File- FLRT.TXT KL Danneil 13-Nov-85 The FLECS (Fortran Language with Extended Control Structures) pro- gram is a pre-processor for FORTRAN programs. It will process standard FORTRAN source programs (causing no changes or errors). Other pre-processors such as RATFOR have so corrupted the FORTRAN language that they can't be used on standard FORTRAN source files. So, FLECS al- lows you to start with a previous FORTRAN program then update it using the structured FLECS statements as you care to. There are several versions of the precompiler included on the disk. They represent various corruptions of implementation mostly varying in the details of STRING handling. The problem is that the original FLECS can 'compile' itself, but its internal data stacking is so badly struc- tured that FLECS can't compile itself with the new STRING features. This requires that the 'original' FLECS be available to compile the new versions. The two 'new' implementations are FLXRT (supplied as part of DECUS 11-SP-30 RT11 SIG fall 1981 tape) and my version FLRT. The FLECS and FLXRT implementations use the 1st 2 bytes of the string as an INTEGER to hold just the present length of the string. They also didn't even provide the length library routines ie. you had to continually keep track of the length or retrieve it from the first INTEGER element and had to guard aginst string length overflow yourself on all string copy operations. Also FLECS and FLXRT strings were IN- TEGER arrays so it was difficult to retrieve individual characters. FLXRT implements the RT11 standard of a '0' termination of ASCII strings. I found that to be almost useless because of incompatability of the string functions with both RT11 string functions and the constant need to keep track of the actual length of the string. I implemented a 'maximum length of string' parameter so that the string library functions would do the work for me. The changes neces- sary are found in FLXCD4.FLX and the library FLSTRL.FLX (the FLXRT ver- sion is STRLIB.FLX). This implementation uses the first 2 bytes of the string to hold length information followed by the string and terminated with a 0. Notice that this restricts the maximum length string to 255 characters verses 16383 for FLECS. The string is defined as a BYTE array, and a DATA statement is gen- erated to initialize the string. In the first form of the STRING defin- ition, the first two DATA items initialize the maximum length as speci- fied in the STRING definition, and initialize the present length as 0. Example-- String Sinput(80) Alternatly the STRING can be defined as a constant by supplying the characters as part of the definition. In this case the string is ini- tialized with the supplied strings length, the maximum length is set to the supplied strings length, the supplied string is then inserted into the DATA definition. Example-- String Sbye 'Have a good day.' Page 2 In either form, the DATA definition is followed by the terminating 0 byte, then is .EVENed (ie. whole INTEGER length). The first byte contains the 'present length' of the string and the second byte contains the 'maximum length'. Note that the form of the FLECS STRING statement hasn't been changed. Only the internal implementation has changed. If a string overflows on a copy operation, the CPYSUB routine will type a message so that you have a chance to figure out the problem or choose to ignor it. The string will be copied only up to the maximum specified length. If you don't like the error message, you can alter the string library source for CPYSUB and recompile the library. I haven't had time to implement all the RT11 string functions in FLECS library routines so you will need to refer to the 3'rd element of the string in any calls to the RT11 functions you have to use (ie. Fstr(3) is the 1'st character in the string and Fstr(Slen(Fstr)+2) or possibly Fstr(LEN(Fstr(3)+2) to get the last character). The original FLECS string functions are still in the STRLIB library if you should need them. Note that they can't be used on the 'new' type strings. The FLSTRL library (I renamed the object version STRLIB.OLB) contains my modified versions of the string functions and a number of additional functions to support the 'new' strings. To rebuild FLRT, first precompile the .FLX files using FLECS. Then compile the .FTX files using FORTRAN. Finaly link using the FLRT.LNK command file. I have included FIORTN and UTILIB which are collections of file handling and input/output routines. Also included is AMOEBA in the ori- ginal Fortran source and the FLECS updated version of a CRT 'idle time' display program. Karl L. Danneil 6767 Pittsfield Road Nassau, NY 12123 (413) 494-2907 Page 3 FLECS supplied functions and subprograms ---------------------------------------- BY2INT (BARRAY) TO RETURN VALUE IN 1ST 2 BYTES OF AN ARRAY AS INTEGER CHNEXT (STRING,CURSOR,CWD,CPOS) TO GET-CHARACTER CHNEXT RETURNS CHARACTER IN STRING AT CURSOR POSITION AS CHGET. Increments CURSOR before extracting CHNEXT still word alligned, so use WORD(CWD) and CPOS byte within WORD CHPUT (CH,STRING,CURSOR,CWD,CPOS) CHPUT PUTS CHARACTER CH IN CURSOR CPOS OF STRING CHTYP(CH) RETURNS: 1 FOR A-Z (UC OR LC) 2 FOR 0-9 3 FOR '-' 4 FOR '(' 5 FOR ')' 6 FOR TAB OR BLANK 7 FOR ALL OTHER CHARACTERS CHUC (CH) CHUC SHIFTS CHARACTER CH TO UPPER CASE IF CH IS LOWER CASE GETCH (WORD,POS,CH) GETCH RETURNS THE CHARACTER IN POSITION POS IN CH PUTINT (INTG,BARRAY) TO PUT INTEGER INTO BYTE ARRAY NEWNO(N) NEWNO IS A SEQUENTIAL NUMBER GENERATOR. Modified or new functions and subprograms ----------------------------------------- CATNUM(DEST,NUMBER) Concatenates to the string DEST, the 5 character representation for the number NUMBER. CATSTR(DEST,SOURCE) Concatenates the string SOURCE to the right end of the string DEST. CATSUB(STR1,STR2,START,LENGTH) CATSUB CONCATENATES A SUBSTRING OF STR2 TO THE END OF STRING STR1. CPYSTR(STR1,STR2) CPYSTR SETS STRING STR1 EQUAL TO A COPY OF STRING STR2 Page 4 CPYSUB(STR1,STR2,START,LENGTH) CPYSUB SETS STRING STR1 EQUAL TO A COPY OF A SUBSTRING OF STR2 OF LENGTH LENGTH STARTING AT START FLNDEX (ISTRNG,IPATRN) RETURN POSITION OF IPATRN IN ISTRNG DESIGNED TO WORK THE SAME AS "INDEX" BY L.BRUNS (DEC-10) HASH(A,PRIME) HASH COMPUTES AN INTEGER IN THE RANGE 0 TO PRIME-1 BY HASHING THE STRING A INCLUDING ITS LENGTH. HASH REDUCED MOD PRIME BEFORE SUMMING TO AVOID INTEGER OVERFLOW. PUTCH (BYTES,POS,CH) PUTCH PUTS CHARACTER CH IN BYTE POS OF WORD PUTNUM (BSTRNG,NUMBER) PUTNUM PLACES A 5 DIGIT NUMBER AT THE BEGINNING OF STRING BSTRNG Slen (BARRAY) Return the present length of String BARRAY (a BYTE or LOGICAL*1 array). Slenpt (LENGTH,BARRAY) Put the present length of String BARRAY (a BYTE or LOGICAL*1 array). Smaxpt (LENGTH,BARRAY) Put the maximum length into String BARRAY (a BYTE or LOGICAL*1 array). Smaxln (BARRAY) Return the maximum length of String BARRAY (a BYTE or LOGICAL*1 array). SPadSt(LSTRNG) Pad string LSTRNG with space characters to its maximum length STREQ (STR1,STR2) STREQ IS A LOGICAL FUNCTION WHICH INDICATES WHETHER OR NOT STRING STR1 IS EQUAL TO STRING STR2. STRLT(STR1,STR2) STRLT IS A LOGICAL FUNCTION WHICH INDICATES WHETHER OR NOT STRING STR1 IS LEXICOGRAPHICALLY LESS THAN STRING STR2. STRUC (BSTRNG) STRUC shifts the characters in string BSTRNG to upper case