| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348 |
- 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<StrLen) AND ((TheStr[Spot]<'0'
- ***** ^ not supported yet
- ***** ^ not supported yet
- 47 ) OR (TheStr[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<StrLen) AND (TheStr[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<StrLen) AND ((TheStr[Spot]<'0'
- ***** ^ not supported yet
- ***** ^ not supported yet
- 74 ) OR (TheStr[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<StrLen) AND (TheStr[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<leng) AND ((TheStr[Spot]<'0')
- 129 OR (TheStr[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<leng) AND ((TheStr[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<lngth) AND (TheStr[Spot]#'.') AND
- 180 ((TheStr[Spot]<'0') OR (TheStr[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 (Spot<lngth) AND (DigitArrayIndex<=digitsize) AND
- 193 (('0'<=TheStr[Spot]) AND (TheStr[Spot]<='9')) DO
- 194 digit[DigitArrayIndex] := INTEGER(ORD(TheStr[Spot])-OrdZero);
- 195 INC(DigitArrayIndex);
- 196 INC(Spot);
- 197 END;
- 198
- 199 WholeNum := zero;
- 200 FOR j := 1 TO DigitArrayIndex-1 DO
- 201 WholeNum := WholeNum*ten + Numbers.IntToR8(digit[j]);
- 202 END;
- 203 IF negative THEN
- 204 TheReal := -WholeNum;
- 205 ELSE
- 206 TheReal := WholeNum;
- 207 END;
- 208
- 209 IF (Spot=lngth) OR ((TheStr[Spot]#'.') AND (TheStr[Spot]#'E')) THEN
- 210 (*We're either at the end of the string or at the end of
- 211 the part of it that contains a valid real number, and
- 212 we've found at least one numeric character, so we
- 213 return true. *)
- 214 RETURN TRUE;
- 215 END;
- 216
- 217 IF (TheStr[Spot]='.') THEN
- 218 scale := 0;
- 219 WholeNum := zero;
- 220 INC(Spot);
- 221 WHILE (Spot<lngth) AND (DigitArrayIndex<=digitsize) AND
- 222 (('0'<=TheStr[Spot]) AND (TheStr[Spot]<='9')) DO
- 223 temp := Numbers.IntToR8(ORD(TheStr[Spot])-OrdZero);
- 224 IF negative THEN
- 225 WholeNum := WholeNum*ten-temp;
- 226 ELSE
- 227 WholeNum := WholeNum*ten+temp;
- 228 END;
- 229 INC(scale);
- 230 INC(DigitArrayIndex);
- 231 INC(DigitsRightOfDec);
- 232 INC(Spot);
- 233 END;
- 234 IF WholeNum#zero THEN
- 235 r := WholeNum;
- 236 REPEAT
- 237 r := r/ten;
- 238 DEC(scale);
- 239 UNTIL scale=0;
- 240 TheReal := TheReal + r;
- 241 ELSE
- 242 scale := 0;
- 243 END;
- 244 END;
- 245 IF (Spot=lngth) OR (TheStr[Spot] # 'E') THEN
- 246 RETURN TRUE;
- 247 END;
- 248
- 249 IF TheStr[Spot]='E' THEN
- 250 INC(Spot);
- 251 M2Strings.Copy( TheStr, Spot, lngth - Spot, expstr );
- 252 IF NOT GetEmbeddedInt(expstr, Spot, exp) THEN
- 253 RETURN FALSE;
- 254 END;
- 255 END;
- 256
- 257 scale := DigitsRightOfDec + exp;
- 258 IF scale#0 THEN
- 259 scalesign := scale<0;
- 260 scale := ABS(scale);
- 261 IF scale>307 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
|