Listing: 1 IMPLEMENTATION MODULE StrCnv1; 2 (* 3 * REPERTOIRE 4 * Release 1.6 5 * By Charles Bradford and Cole Brecheen 6 * (c) Copyright 1985-1992 PMI 7 * Green Bay, Wisconsin 8 * All rights reserved 9 * (414) 468-6040 10 * 11 * $Header: D:/logfiles/mods/strcnv1.mov 1.5 10 Mar 1991 15:33:02 coleb $ 12 * 13 *) 14 15 16 IMPORT M2Strings; 17 IMPORT Numbers; 18 IMPORT NumTypes; 19 20 VAR 21 Initialized : BOOLEAN; 22 23 PROCEDURE Init(); 24 BEGIN 25 IF Initialized THEN 26 RETURN; 27 ELSE 28 Initialized := TRUE; 29 END; 30 M2Strings.Init(); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 31 Numbers.Init(); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 32 NumTypes.Init(); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 33 END Init; ***** ^ not supported yet 34 35 CONST 36 blank = ' '; 37 38 39 PROCEDURE GetEmbeddedCard(TheStr : ARRAY OF CHAR; VAR Spot : ***** ^ not supported yet 40 CARDINAL; VAR TheCard : CARDINAL) : BOOLEAN; 41 VAR 42 StrLen : CARDINAL; 43 BEGIN 44 TheCard := 0; 45 StrLen := M2Strings.Length(TheStr); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 46 WHILE ((Spot'9'))) DO ***** ^ not supported yet ***** ^ not supported yet 48 INC(Spot); ***** ^ undeclared identifier ***** ^ not supported yet 49 (*Skips all leading non-numeric stuff.*) 50 END; 51 IF Spot>=StrLen THEN 52 RETURN FALSE; 53 END; 54 WHILE (Spot='0' ***** ^ not supported yet ***** ^ not supported yet 55 ) AND (TheStr[Spot]<='9') DO ***** ^ not supported yet ***** ^ not supported yet 56 TheCard := TheCard*10; 57 INC(TheCard, ORD(TheStr[Spot])-48); ***** ^ undeclared identifier ***** ^ undeclared identifier ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 58 INC(Spot); ***** ^ undeclared identifier ***** ^ not supported yet 59 END; 60 RETURN TRUE; 61 END GetEmbeddedCard; ***** ^ not supported yet 62 63 64 PROCEDURE GetEmbeddedInt(TheStr : ARRAY OF CHAR; VAR Spot : ***** ^ not supported yet 65 CARDINAL; VAR TheInt : INTEGER) : BOOLEAN; 66 VAR 67 StrLen : CARDINAL; 68 negative : BOOLEAN; 69 BEGIN 70 TheInt := 0; 71 StrLen := M2Strings.Length(TheStr); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 72 negative := FALSE; 73 WHILE ((Spot'9'))) DO ***** ^ not supported yet ***** ^ not supported yet 75 IF TheStr[Spot]='-' THEN ***** ^ not supported yet ***** ^ not supported yet 76 negative := NOT negative; 77 (* Means negative will go back to FALSE if 78 there are two leading minus signs; may 79 not be good for much, but why not? *) 80 END; 81 INC(Spot); ***** ^ undeclared identifier ***** ^ not supported yet 82 (*Skips all leading non-numeric stuff.*) 83 END; 84 IF Spot>=StrLen THEN 85 RETURN FALSE; 86 END; 87 WHILE (Spot='0' ***** ^ not supported yet ***** ^ not supported yet 88 ) AND (TheStr[Spot]<='9') DO ***** ^ not supported yet ***** ^ not supported yet 89 TheInt := TheInt*10; 90 INC(TheInt, ORD(TheStr[Spot])-48); ***** ^ undeclared identifier ***** ^ undeclared identifier ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 91 INC(Spot); ***** ^ undeclared identifier ***** ^ not supported yet 92 END; 93 IF negative THEN 94 TheInt := -TheInt; 95 END; 96 RETURN TRUE; 97 END GetEmbeddedInt; ***** ^ not supported yet 98 99 100 (*$O-*) 101 (*We turn off optimization for this procedure because of a bug in 102 the beta copy of Logitech's v3.0.*) 103 PROCEDURE GetEmbeddedLongInt(TheStr : ARRAY OF CHAR; VAR Spot : ***** ^ not supported yet 104 CARDINAL; VAR TheLong : LONGINT) : BOOLEAN; 105 TYPE 106 LongAndShort = 107 RECORD 108 CASE : CHAR OF ***** ^ not supported yet ***** ^ 'POINTER' expected 109 'A' : 110 longi : LONGINT; 111 | 'B' : 112 locard, hicard : CARDINAL; 113 | 'C' : 114 loint, hiint : INTEGER; 115 END; 116 END; 117 VAR 118 positive : BOOLEAN; 119 ten : LONGINT; 120 dumlong : LongAndShort; 121 charstr : ARRAY [0..10] OF CHAR; 122 leng : CARDINAL; 123 BEGIN 124 leng := M2Strings.Length(TheStr); 125 TheLong := NumTypes.L0; 126 ten := Numbers.Lc(10); 127 positive := TRUE; 128 WHILE (Spot'9')) DO 130 IF TheStr[Spot]='-' THEN 131 positive := FALSE; 132 END; 133 INC(Spot); 134 END; 135 IF (Spot>=leng) THEN 136 RETURN FALSE; 137 END; 138 WHILE (Spot='0' 139 ) AND (TheStr[Spot]<='9')) DO 140 TheLong := TheLong * ten; 141 dumlong.hicard := 0; 142 dumlong.locard := ORD(TheStr[Spot])-48; 143 TheLong := TheLong + dumlong.longi; 144 INC(Spot); 145 END; 146 IF NOT positive THEN 147 TheLong := -TheLong; 148 END; 149 RETURN TRUE; 150 END GetEmbeddedLongInt; 151 (*$O=*) 152 153 154 PROCEDURE GetEmbeddedReal(TheStr : ARRAY OF CHAR; VAR Spot : 155 CARDINAL; VAR TheReal : NumTypes.Real8): BOOLEAN; 156 CONST 157 ten = 10.0; 158 one = 1.0; 159 zero = 0.0; 160 digitsize = 16; 161 OrdZero = 48; 162 VAR 163 digit : ARRAY [1..digitsize] OF INTEGER; 164 expstr : ARRAY [0..24] OF CHAR; 165 temp, WholeNum, r, fac : NumTypes.Real8; 166 scalesign, negative : BOOLEAN; 167 scale, DigitsRightOfDec, exp : INTEGER; 168 NumOfBlanks, Zeroes, DecPt, EPos : INTEGER; 169 limit, DigitArrayIndex, j : INTEGER; 170 lngth, tmpspot : CARDINAL; 171 BEGIN 172 TheReal := 0.0; 173 exp := 0; 174 DigitsRightOfDec := 0; 175 lngth := M2Strings.Length(TheStr); 176 negative := FALSE; 177 (* First we skip to the start of something that looks 178 like a number. *) 179 WHILE (Spot'9')) DO 181 IF TheStr[Spot]='-' THEN 182 negative := NOT negative; 183 ELSIF TheStr[Spot]='+' THEN 184 negative := FALSE; 185 END; 186 INC(Spot); 187 END; 188 IF (Spot>=lngth) THEN 189 RETURN FALSE; 190 END; 191 DigitArrayIndex := 1; 192 WHILE (Spot307 THEN 262 RETURN FALSE; 263 END; 264 IF TheReal # zero THEN 265 FOR tmpspot := 0 TO 8 DO 266 IF tmpspot IN BITSET(scale) THEN 267 IF scalesign THEN 268 TheReal := TheReal / NumTypes.R8TenPowers[tmpspot]; 269 ELSE 270 TheReal := TheReal * NumTypes.R8TenPowers[tmpspot]; 271 END; 272 END; 273 END; 274 END; 275 END; 276 RETURN TRUE; 277 END GetEmbeddedReal; 278 279 280 BEGIN 281 Initialized := FALSE; 282 Init(); 283 END StrCnv1. 59 errors