Listing: 1 IMPLEMENTATION MODULE NdxFiles; 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/ndxfiles.mov 1.8 10 Mar 1991 15:30:18 coleb $ 12 * 13 *) 14 15 IMPORT FAPI; 16 (*EntryDiag: 17 IMPORT Diagnostics; 18 :EntryDiag*) 19 20 IMPORT Drectory; 21 IMPORT ErrorManager; 22 IMPORT ErrorNames; 23 IMPORT HandleIO; 24 IMPORT GenLists; 25 IMPORT ListUtils; 26 IMPORT LowLevel; 27 IMPORT M2Strings; 28 IMPORT NdxBones; 29 IMPORT NdxTypes; 30 FROM NdxTypes IMPORT NdxRecord; ***** ^ duplicate identifier 31 IMPORT Numbers; 32 IMPORT NumTypes; 33 IMPORT PosUtils; 34 IMPORT StrEdit; 35 IMPORT StringIO; 36 IMPORT SYSTEM; 37 IMPORT VStorage; 38 39 VAR 40 Initialized : BOOLEAN; 41 42 VAR 43 NulHandle: VStorage.MemHandle; ***** ^ not supported yet 44 45 46 PROCEDURE NoMemMessage( message: ARRAY OF CHAR ); ***** ^ not supported yet 47 VAR 48 tmpstr: ARRAY [0..79] OF CHAR; ***** ^ not supported yet ***** ^ not supported yet 49 BEGIN 50 StrEdit.AssignStr( 'Ran out of memory in ', tmpstr ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 51 StrEdit.Append( tmpstr, message ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 52 ErrorManager.WARN( tmpstr ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 53 END NoMemMessage; ***** ^ not supported yet 54 55 56 PROCEDURE CreateNdxFile( VAR NdxFile: NdxTypes.NdxFileType; fname, ***** ^ not supported yet 57 Structure: ARRAY OF CHAR ); ***** ^ not supported yet 58 (*Structure should look something like this: 59 "Name, Password, AcctBal, Address {Street, City, State}' 60 Names listed here can be used to access specific fields 61 within records, using the Get and Put procedures below. 62 All procedures that use field names are case sensitive. *) 63 VAR 64 TmpName: ARRAY [0..255] OF CHAR; ***** ^ not supported yet ***** ^ not supported yet 65 StruSize: CARDINAL; 66 BytesWritten: LONGINT; 67 SavedMessage: CARDINAL; 68 69 PROCEDURE MakeStructure( VAR StruList: GenLists.GenList; Structure: ***** ^ not supported yet 70 ARRAY OF CHAR ); ***** ^ not supported yet 71 VAR 72 NextSpot, BraceSpot, CommaSpot: CARDINAL; 73 SubList: GenLists.GenList; ***** ^ not supported yet 74 NameStr: ARRAY [0..255] OF CHAR; ***** ^ not supported yet ***** ^ not supported yet 75 76 PROCEDURE PosCloseBrace( Start: CARDINAL; Structure: 77 ARRAY OF CHAR): CARDINAL; ***** ^ not supported yet 78 (* find the closing brace that matches this open brace *) 79 VAR 80 OpenSpot, CloseSpot: CARDINAL; 81 BEGIN 82 CloseSpot := PosUtils.Positn( '}', Structure, Start); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 83 OpenSpot := PosUtils.Positn( '{', Structure, Start); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 84 IF (CloseSpot < OpenSpot) OR 85 (CloseSpot > HIGH( Structure)) THEN ***** ^ undeclared identifier ***** ^ not supported yet 86 RETURN CloseSpot; 87 ELSE 88 RETURN PosCloseBrace( 1+PosCloseBrace( OpenSpot + 1, ***** ^ not supported yet ***** ^ not supported yet 89 Structure), Structure); ***** ^ not supported yet ***** ^ not supported yet 90 END; 91 END PosCloseBrace; ***** ^ not supported yet 92 93 BEGIN 94 (*MakeStructure*) 95 IF M2Strings.Length(Structure) = 0 THEN ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 96 RETURN; 97 END; 98 IF Structure[ M2Strings.Length(Structure) - 1 ] # ',' THEN ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 99 StrEdit.Append(Structure, ","); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 100 (*Makes all names end the same way for the 101 convenience of the loop below; nothing will 102 be appended, however, if a constant structure 103 string was passed because it completely fills 104 its array.*) 105 END; 106 WHILE M2Strings.Length(Structure) > 0 DO ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 107 CommaSpot := PosUtils.Pos(',', Structure); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 108 (*OK if no comma*) 109 BraceSpot := PosUtils.Pos('{', Structure); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 110 IF CommaSpot < BraceSpot THEN 111 NextSpot := CommaSpot; 112 ELSE 113 NextSpot := BraceSpot; 114 END; 115 IF NextSpot = 0 THEN 116 ErrorNames.WarningName( 'NoNam' ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 117 RETURN; 118 END; 119 M2Strings.Copy( Structure, 0, NextSpot, NameStr ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 120 (*Copy everything up to the next separator, but not the 121 separator itself.*) 122 M2Strings.Delete( Structure, 0, NextSpot ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 123 (*Delete everything up to but not including 124 the separator.*) 125 IF M2Strings.Length( Structure ) > 0 THEN ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 126 M2Strings.Delete( Structure, 0, 1 ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 127 (*Delete the separator, if present.*) 128 END; 129 GenLists.ListInsert( NameStr, GenLists.StrCode, StruList, 65535); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 130 (* insert this name into the list *) 131 IF (NextSpot = BraceSpot) AND (BraceSpot <= HIGH(Structure)) THEN ***** ^ undeclared identifier ***** ^ not supported yet 132 (* the preceeding name has a sublist *) 133 GenLists.NewList( SubList); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 134 GenLists.ListInsert( SubList, GenLists.ListCode, StruList, 65535); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 135 (* insert a sublist into the list *) 136 BraceSpot := PosCloseBrace( 0, Structure); ***** ^ not supported yet ***** ^ not supported yet 137 IF BraceSpot > HIGH( Structure) THEN ***** ^ undeclared identifier ***** ^ not supported yet 138 ErrorNames.WarningName( 'NdxBrac' ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 139 RETURN; 140 END; 141 M2Strings.Copy( Structure, 0, BraceSpot, NameStr ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 142 (*Copy everything up to the next brace, but not the 143 brace itself.*) 144 M2Strings.Delete( Structure, 0, BraceSpot + 1 ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 145 (*Delete everything up to and including the brace.*) 146 IF M2Strings.Length( Structure) > 0 THEN ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 147 (* now delete comma after closing brace *) 148 IF Structure[0] # ',' THEN ***** ^ not supported yet ***** ^ not supported yet 149 ErrorNames.WarningName( 'NdxCmm' ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 150 RETURN; 151 ELSE 152 M2Strings.Delete( Structure, 0, 1); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 153 END; 154 END; 155 MakeStructure( SubList, NameStr); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 156 END; 157 END; 158 END MakeStructure; ***** ^ not supported yet 159 160 BEGIN 161 (*CreateNdxFile*) 162 NdxTypes.InitNdxFile( NdxFile ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 163 StrEdit.AssignStr( fname, NdxFile^.name ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 164 WITH NdxFile^ DO ***** ^ not supported yet 165 StringIO.PrintMessage( HandleIO.CreateFile( handle, name ) ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ undeclared identifier ***** ^ undeclared identifier 166 UpdateNeeded := TRUE; ***** ^ undeclared identifier 167 GenLists.NewList( Ndx); ***** ^ not supported yet ***** ^ not supported yet ***** ^ undeclared identifier 168 GenLists.NilList( AltKeys ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ undeclared identifier 169 GenLists.NewList( ListBuf); ***** ^ not supported yet ***** ^ not supported yet ***** ^ undeclared identifier 170 GenLists.NewList( StructLst); ***** ^ not supported yet ***** ^ not supported yet ***** ^ undeclared identifier 171 END; ***** ^ not supported yet 172 StrEdit.DeleteChar( ' ', Structure ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ undeclared identifier 173 StrEdit.CAPstr(Structure); ***** ^ not supported yet ***** ^ not supported yet ***** ^ undeclared identifier 174 StringIO.WriteStr( NdxFile^.handle, '00' ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ undeclared identifier ***** ^ not supported yet ***** ^ not supported yet 175 (* space at start of file for size of structure to be put *) 176 MakeStructure( NdxFile^.StructLst, Structure); ***** ^ undeclared identifier ***** ^ undeclared identifier ***** ^ not supported yet ***** ^ undeclared identifier 177 M2Strings.Concat( NdxBones.IsGarbageByte, NdxBones.StructName, TmpName); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ undeclared identifier 178 GenLists.ListInsert( TmpName, GenLists.StrCode, NdxFile^.StructLst, 1); ***** ^ not supported yet ***** ^ not supported yet ***** ^ undeclared identifier ***** ^ not supported yet ***** ^ not supported yet ***** ^ undeclared identifier ***** ^ not supported yet ***** ^ not supported yet 179 (* add structure name to structure list *) 180 SavedMessage := ListUtils.ListToFileHandle( ***** ^ undeclared identifier ***** ^ not supported yet ***** ^ not supported yet 181 NdxFile^.StructLst, NdxFile^.handle, NdxBones.StartSep, ***** ^ undeclared identifier ***** ^ not supported yet ***** ^ undeclared identifier ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 182 NdxBones.EndSep, 0, BytesWritten ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ undeclared identifier 183 StruSize := Numbers.C( BytesWritten ); ***** ^ undeclared identifier ***** ^ not supported yet ***** ^ not supported yet ***** ^ undeclared identifier 184 IF (SavedMessage # StringIO.NoError) THEN ***** ^ undeclared identifier ***** ^ not supported yet ***** ^ not supported yet 185 ErrorNames.WarningName( 'StructCreate' ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 186 END; 187 GenLists.ListDelete( NdxFile^.StructLst, 1, 1); ***** ^ not supported yet ***** ^ not supported yet ***** ^ undeclared identifier ***** ^ not supported yet ***** ^ not supported yet 188 (* deletes the StructName from the Structure *) 189 NdxFile^.NdxFilePtr := Numbers.Lc( 2 + StruSize); ***** ^ undeclared identifier ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ undeclared identifier 190 (* Point to NdxMarker *) 191 StringIO.WriteStr( NdxFile^.handle, NdxBones.NdxMarker ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ undeclared identifier ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 192 StringIO.PrintMessage( HandleIO.BlockWrite( NdxFile^.handle, ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ undeclared identifier ***** ^ not supported yet 193 SYSTEM.ADR(NdxFile^.NdxFilePtr), 4)); ***** ^ not supported yet ***** ^ not supported yet ***** ^ undeclared identifier ***** ^ not supported yet ***** ^ not supported yet 194 (* write ndxmarker & position out to end of file *) 195 HandleIO.SetFilePtr( NdxFile^.handle, HandleIO.FromStart, Numbers.Lc( 0)); ***** ^ not supported yet ***** ^ not supported yet ***** ^ undeclared identifier ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 196 StringIO.PrintMessage( HandleIO.BlockWrite( NdxFile^.handle, ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ undeclared identifier ***** ^ not supported yet 197 SYSTEM.ADR( StruSize), 2)); ***** ^ not supported yet ***** ^ not supported yet ***** ^ undeclared identifier ***** ^ not supported yet 198 (* write size of structure out to start of file *) 199 NdxBones.MakeEmptyBuf( NdxFile^.StructLst, NdxFile^.ListBuf ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ undeclared identifier ***** ^ not supported yet ***** ^ undeclared identifier ***** ^ not supported yet 200 END CreateNdxFile; ***** ^ not supported yet 201 202 203 PROCEDURE WriteNdx( NdxFile: NdxTypes.NdxFileType ); ***** ^ not supported yet 204 VAR 205 BytesWritten: LONGINT; 206 BEGIN 207 HandleIO.SetFilePtr( NdxFile^.handle, HandleIO.FromStart, ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 208 NdxFile^.NdxFilePtr ); ***** ^ not supported yet ***** ^ not supported yet 209 (*Go to end of data area.*) 210 StringIO.WriteStr( NdxFile^.handle, NdxBones.NdxMarker); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 211 (*Write NdxMarker.*) 212 IF StringIO.NoError # ListUtils.ListToFileHandle( ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 213 NdxFile^.Ndx, NdxFile^.handle, '', '', 0, BytesWritten ) THEN ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 214 (*The nulls mean "don't write delimiters."*) 215 ErrorNames.WarningName( 'NdxWrt' ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 216 END; 217 StringIO.PrintMessage( HandleIO.BlockWrite( NdxFile^.handle, ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 218 SYSTEM.ADR(NdxFile^.NdxFilePtr), 4) ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 219 (* write starting position of index *) 220 StringIO.PrintMessage(Drectory.SetFileLength(NdxFile^.handle, ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 221 HandleIO.GetFilePtr(NdxFile^.handle))); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 222 HandleIO.UpdateDisk(NdxFile^.handle); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 223 SetFileUpdate( NdxFile^.handle, NdxBones.NotGarbageByte); ***** ^ undeclared identifier ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 224 NdxFile^.UpdateNeeded := FALSE; ***** ^ not supported yet ***** ^ not supported yet 225 END WriteNdx; ***** ^ not supported yet 226 227 PROCEDURE SetFileUpdate( handle: CARDINAL; GbgByte: CHAR); 228 BEGIN 229 (* Puts the passed character in the file's UpdateNeeded 230 Byte (use IsGarbageByte when file index needs update, 231 and NotGarbageByte when update no longer needed). *) 232 HandleIO.SetFilePtr( handle, HandleIO.FromStart, Numbers.Lc( 10)); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 233 StringIO.WriteStr( handle, GbgByte); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 234 END SetFileUpdate; ***** ^ not supported yet 235 236 PROCEDURE CloseNdxFile( VAR NdxFile: NdxTypes.NdxFileType ); ***** ^ not supported yet 237 BEGIN 238 NdxTypes.CheckInit( NdxFile ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 239 IF NdxFile^.UpdateNeeded THEN ***** ^ not supported yet ***** ^ not supported yet 240 WriteNdx( NdxFile); ***** ^ not supported yet ***** ^ not supported yet 241 (* Write Ndx if it has been changed *) 242 END; 243 WITH NdxFile^ DO ***** ^ not supported yet 244 GenLists.DisposeList( ListBuf); ***** ^ not supported yet ***** ^ not supported yet ***** ^ undeclared identifier 245 GenLists.DisposeList( StructLst); ***** ^ not supported yet ***** ^ not supported yet ***** ^ undeclared identifier 246 GenLists.DisposeList( Ndx ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ undeclared identifier 247 GenLists.DisposeList( AltKeys ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ undeclared identifier 248 (*Note that we don't dispose of the FileBufPtr because 249 it should always have been absorbed into the ListBuf.*) 250 IF handle # 0 THEN ***** ^ undeclared identifier 251 (*handle may be 0 if the NdxFile record was initialized 252 but never passed to OpenNdxFile.*) 253 StringIO.PrintMessage( HandleIO.CloseHandle( handle) ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ undeclared identifier 254 END; 255 END; ***** ^ not supported yet 256 VStorage.DosDealloc( NdxFile, SYSTEM.TSIZE(NdxRecord) ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ undeclared identifier ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 257 END CloseNdxFile; ***** ^ not supported yet 258 259 260 PROCEDURE ChangedIndex(NdxFile: NdxTypes.NdxFileType); ***** ^ not supported yet 261 BEGIN 262 (* need to account for small changes to index or just big?? *) 263 IF NdxFile^.SafetyOn THEN ***** ^ not supported yet ***** ^ not supported yet 264 WriteNdx( NdxFile); ***** ^ not supported yet ***** ^ not supported yet 265 HandleIO.UpdateDisk( NdxFile^.handle ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 266 (* writes entire index at end of file *) 267 ELSE 268 IF NOT NdxFile^.UpdateNeeded THEN ***** ^ not supported yet ***** ^ not supported yet 269 SetFileUpdate( NdxFile^.handle, NdxBones.IsGarbageByte); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 270 NdxFile^.UpdateNeeded := TRUE; ***** ^ not supported yet ***** ^ not supported yet 271 END; 272 END; 273 END ChangedIndex; ***** ^ not supported yet 274 275 276 PROCEDURE DeleteRecord( VAR NdxFile: NdxTypes.NdxFileType; ***** ^ not supported yet 277 RecName: ARRAY OF CHAR ): BOOLEAN; ***** ^ not supported yet 278 (*Marks RecName as garbage in the linked list so that 279 CrunchNdxFile can delete it from the file, sets garbage 280 byte in file record, and erases in current buffer (if 281 there). If SafetyOn is set for this NdxFile, also writes 282 the linked list out to the file.*) 283 VAR 284 FilePos: LONGINT; 285 UsedSize, AllocSize : CARDINAL; 286 BEGIN 287 NdxTypes.CheckInit( NdxFile ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 288 StrEdit.CrunchBlanks( RecName ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 289 IF (M2Strings.Length(RecName) = 0) OR ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 290 (NOT NdxBones.FindRecord( NdxFile, RecName, FilePos, UsedSize, ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 291 AllocSize)) THEN ***** ^ not supported yet 292 (* If don't find record in index, return FALSE *) 293 RETURN FALSE; 294 END; 295 IF NOT ChangeNdxEntry( RecName, '', FilePos, AllocSize, ***** ^ undeclared identifier ***** ^ not supported yet 296 NdxFile) THEN ***** ^ not supported yet 297 RETURN FALSE; 298 END; 299 (* change index entry to garbage *) 300 INC( FilePos, 8 ); ***** ^ undeclared identifier ***** ^ not supported yet 301 HandleIO.SetFilePtr( NdxFile^.handle, HandleIO.FromStart, FilePos); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 302 StringIO.WriteStr( NdxFile^.handle, NdxBones.IsGarbageByte); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 303 (* write garbage byte in old record *) 304 IF PosUtils.Equal(RecName, NdxFile^.BufRecName) THEN ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 305 (* if record is now in buffer, erase it *) 306 StrEdit.SetLength( NdxFile^.BufRecName, 0); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 307 END; 308 ChangedIndex( NdxFile); ***** ^ not supported yet ***** ^ not supported yet 309 RETURN TRUE; 310 END DeleteRecord; ***** ^ not supported yet 311 312 313 PROCEDURE EncodeList( VAR TheList: GenLists.GenList); ***** ^ not supported yet 314 315 PROCEDURE EnCodeField( OldAddr: SYSTEM.ADDRESS; OldSize, ***** ^ not supported yet 316 NumberFound: CARDINAL; VAR NewAddr: SYSTEM.ADDRESS; ***** ^ not supported yet 317 VAR NewSize: CARDINAL); 318 (* Change all occurences of CodeChar to CodedStr *) 319 VAR 320 tmpsize, toskip : CARDINAL; 321 Source, Dest: SYSTEM.ADDRESS; ***** ^ not supported yet 322 BEGIN 323 NewSize := NumberFound + OldSize; 324 VStorage.DosAlloc( NewAddr, NewSize); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 325 (* max size needed *) 326 tmpsize := OldSize; 327 Source := OldAddr; ***** ^ not supported yet ***** ^ not supported yet 328 (* starting address *) 329 Dest := NewAddr; ***** ^ not supported yet ***** ^ not supported yet 330 LOOP 331 toskip := LowLevel.ScanEQ( tmpsize, NdxBones.CodeChar, Source); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 332 (* look for next CodeChar *) 333 LowLevel.Move( Source, Dest, toskip); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 334 IF toskip >= tmpsize THEN 335 EXIT; 336 END; 337 Dest := LowLevel.AddAddr( Dest, toskip ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 338 LowLevel.Move( SYSTEM.ADR( NdxBones.CodedStr), Dest, 2); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 339 Dest := LowLevel.AddAddr( Dest, 2 ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 340 INC( OldSize); ***** ^ undeclared identifier ***** ^ not supported yet 341 Source := LowLevel.AddAddr( Source, toskip + 1 ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 342 DEC( tmpsize, toskip + 1); ***** ^ undeclared identifier ***** ^ not supported yet 343 END; 344 END EnCodeField; ***** ^ not supported yet 345 346 VAR 347 NumberFound, OldSize, NewSize, ElmntType, cnt, leng: CARDINAL; 348 SubList: GenLists.GenList; ***** ^ not supported yet 349 OldAddr, NewAddr: SYSTEM.ADDRESS; ***** ^ not supported yet 350 BEGIN 351 leng := GenLists.ListLength( TheList ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 352 FOR cnt := 1 TO leng DO 353 GenLists.GetElmtAdr( TheList, cnt, OldAddr, OldSize, ElmntType); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 354 IF ElmntType # GenLists.ListCode THEN ***** ^ not supported yet ***** ^ not supported yet 355 NumberFound := PosUtils.ByteCount( OldSize, ***** ^ not supported yet ***** ^ not supported yet 356 NdxBones.CodeChar, OldAddr ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 357 IF NumberFound > 0 THEN 358 (* do not replace unless code chars found *) 359 EnCodeField( OldAddr, OldSize, NumberFound, NewAddr, NewSize ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 360 GenLists.ListReplaceAdr( NewAddr, NewSize, ElmntType, ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 361 TheList, cnt); ***** ^ not supported yet ***** ^ not supported yet 362 VStorage.DosDealloc( NewAddr,NewSize ); (* 9/14/91 ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 363 per report from J March *) 364 END; 365 ELSE 366 (* this element is a list *) 367 GenLists.GetChildList( TheList, cnt, SubList); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 368 IF GenLists.Initialized( SubList ) THEN ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 369 (*Make sure it's not a nil list.*) 370 EncodeList( SubList ); ***** ^ not supported yet ***** ^ not supported yet 371 (* encode this sublist *) 372 END; 373 END; 374 END; 375 END EncodeList; ***** ^ not supported yet 376 377 378 PROCEDURE WriteRecord( VAR NdxFile: NdxTypes.NdxFileType; ***** ^ not supported yet 379 RecName: ARRAY OF CHAR ): BOOLEAN; ***** ^ not supported yet 380 (*First checks to see whether RecName is in the List buffer 381 created by the Put routines below. Returns FALSE if it 382 isn't. If it is, then checks to see whether RecName is in 383 the list of existing record names. If so, and if the 384 record will still fit in its old spot in the file, 385 WriteRecord overwrites the old spot in the file with the 386 data in the list buffer. Otherwise, it adds the record to 387 the end of the NdxFile, overwriting the ndx, and if the 388 record is not new, marks the spot it formerly occupied as 389 garbage. If the NdxFile's SafetyOn feature has been turned 390 on, a new ndx will be written each time a record is added 391 to the end of the NdxFile. Otherwise, the new ndx will be 392 written only when CloseNdxFile is called.*) 393 VAR 394 OldTotalBytes, OldUsedBytes, NewTotData, NumLsts: 395 CARDINAL; 396 BytesWritten, NumElmts, NewFilePtr, offset, TotMem: LONGINT; 397 OldEntry, RecordExists: BOOLEAN; 398 TmpStr: ARRAY [0..79] OF CHAR; ***** ^ not supported yet ***** ^ not supported yet 399 SavedMessage: CARDINAL; 400 BEGIN 401 (* WriteRecord *) 402 NdxTypes.CheckInit( NdxFile ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 403 StrEdit.CrunchBlanks( RecName ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 404 IF NOT PosUtils.Equal(RecName, NdxFile^.BufRecName) THEN ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 405 (* if record not in buffer, return FALSE *) 406 RETURN( FALSE ); 407 END; 408 StrEdit.AssignStr( RecName, TmpStr ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 409 M2Strings.Insert( NdxBones.NotGarbageByte, TmpStr, 0 ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 410 GenLists.ListInsert( TmpStr, GenLists.StrCode, ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 411 NdxFile^.ListBuf, 1 ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 412 (*Put the record name into the ListBuf.*) 413 StrEdit.SetLength( NdxFile^.BufRecName, 0); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 414 (*We set BufRecName to null to guarantee that this record 415 gets read from the file next time it is needed, because 416 we are about to encode it.*) 417 OldTotalBytes := 0; 418 RecordExists := NdxBones.FindRecord( NdxFile, RecName, ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 419 offset, OldUsedBytes, OldTotalBytes); ***** ^ not supported yet 420 EncodeList( NdxFile^.ListBuf ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 421 NewTotData := Numbers.C( GenLists.ListSize( NdxFile^.ListBuf, ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 422 NumElmts, NumLsts, TotMem)); ***** ^ not supported yet 423 (* find out maximum size of data in record to be written *) 424 INC( NewTotData, 6 + 6 * Numbers.C( NumElmts)); ***** ^ undeclared identifier ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 425 (* add room for: 2 char start & end seps for record, 426 2 char start & end seps for every element, and 427 2 char TypeCode for every element & for record *) 428 OldEntry := RecordExists AND (NewTotData <= OldTotalBytes); 429 (* whether record exists and old file spot is big enough *) 430 IF OldEntry THEN 431 (* rewrite in old spot if not too big *) 432 IF NOT ChangeNdxEntry( RecName, RecName, offset, ***** ^ undeclared identifier ***** ^ not supported yet ***** ^ not supported yet 433 NewTotData, NdxFile) THEN ***** ^ not supported yet 434 RETURN FALSE; 435 END; 436 HandleIO.SetFilePtr( NdxFile^.handle, HandleIO.FromStart, offset ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 437 NewFilePtr := offset; 438 (*I'm not sure this assignment is necessary, but it 439 prevents confusion.*) 440 ELSE 441 (* new entry is too big; so delete old index entry and 442 write at end *) 443 IF RecordExists THEN 444 (* change old entry to garbage *) 445 IF NOT ChangeNdxEntry( RecName, '', offset, ***** ^ undeclared identifier ***** ^ not supported yet 446 OldTotalBytes, NdxFile) THEN ***** ^ not supported yet 447 RETURN FALSE; 448 END; 449 INC( offset, 8 ); ***** ^ undeclared identifier ***** ^ not supported yet 450 (*We skip past the record's first NdxBones.StartSep and 451 its ListCode, plus the NdxBones.StartSep for the 452 RecordName and its StrCode. Using a numeric literal 453 here is dangerous.*) 454 HandleIO.SetFilePtr( NdxFile^.handle, HandleIO.FromStart, offset); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 455 StringIO.WriteStr( NdxFile^.handle, NdxBones.IsGarbageByte); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 456 (* write garbage byte in old record *) 457 END; 458 NewFilePtr := NdxFile^.NdxFilePtr; ***** ^ not supported yet ***** ^ not supported yet 459 (*NdxFile^.NdxFilePtr always points at the end of the 460 NdxFile's data area--at the NdxMarker, in other words.*) 461 OldTotalBytes := NewTotData; 462 (* initialize two variables that InsertNdxEntry will 463 update if it finds old garbage space to re-use *) 464 IF NOT InsertNdxEntry( RecName, NewFilePtr, NewTotData, ***** ^ undeclared identifier ***** ^ not supported yet 465 OldTotalBytes, NdxFile) THEN ***** ^ not supported yet 466 (* make new entry for this record, or re-use garbage 467 space *) 468 RETURN FALSE; 469 END; 470 (* make new index entry *) 471 HandleIO.SetFilePtr( NdxFile^.handle, HandleIO.FromStart, NewFilePtr); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 472 (* put file pointer at start of this new record *) 473 END; 474 SavedMessage := ListUtils.ListToFileHandle( NdxFile^.ListBuf, ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 475 NdxFile^.handle, NdxBones.StartSep, NdxBones.EndSep, 0, ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 476 BytesWritten ); ***** ^ not supported yet 477 IF BytesWritten # Numbers.Lc(NewTotData) THEN ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 478 (*we've miscalculated NewTotData*) 479 (* 480 Diagnostics.diagL( "Unexpected value for BytesWritten", BytesWritten ); 481 Diagnostics.diagC( "Should be", NewTotData ); 482 *) 483 END; 484 IF NewTotData < OldTotalBytes THEN 485 (* garbage space at end of record to fill *) 486 DEC( OldTotalBytes, NewTotData); ***** ^ undeclared identifier ***** ^ not supported yet 487 IF HandleIO.FillFile( NdxFile^.handle, OldTotalBytes, 0C ) # ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 488 StringIO.NoError THEN ***** ^ not supported yet ***** ^ not supported yet 489 (* fill end of record with nulls *) 490 RETURN FALSE; 491 END; 492 END; 493 IF (NOT OldEntry) OR (NewTotData # OldUsedBytes) THEN 494 (* if not using old index entry *) 495 IF NewFilePtr = NdxFile^.NdxFilePtr THEN ***** ^ not supported yet ***** ^ not supported yet 496 NdxFile^.NdxFilePtr := NdxFile^.NdxFilePtr + Numbers.Lc( NewTotData ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 497 StringIO.WriteStr( NdxFile^.handle, NdxBones.NdxMarker); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 498 (* correct ndxfileptr and write ndxmarker if adding 499 to end of file *) 500 END; 501 ChangedIndex( NdxFile); ***** ^ not supported yet ***** ^ not supported yet 502 (* write changed index to file, or set UpdateNeeded *) 503 END; 504 GenLists.DisposeList( NdxFile^.ListBuf ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 505 (*Might as well dispose of the list buffer since it's no good once 506 we've encoded it.*) 507 StrEdit.SetLength( NdxFile^.BufRecName, 0); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 508 (*Set BufRecName to null again because ChangeNdxEntry may 509 have put the name back in.*) 510 RETURN TRUE; 511 END WriteRecord; ***** ^ not supported yet 512 513 514 PROCEDURE ResetBuf( VAR TheBuf: GenLists.GenList ); ***** ^ not supported yet 515 VAR 516 ElmntBytes, ElmntType, theleng, cnt: CARDINAL; 517 TmpAddr: SYSTEM.ADDRESS; ***** ^ not supported yet 518 sublst: GenLists.GenList; ***** ^ not supported yet 519 BEGIN 520 theleng := GenLists.ListLength( TheBuf); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 521 IF theleng # 0 THEN 522 FOR cnt := 1 TO theleng DO 523 GenLists.GetElmtAdr( TheBuf, cnt, TmpAddr, ElmntBytes, ElmntType); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 524 IF ElmntType = GenLists.ListCode THEN ***** ^ not supported yet ***** ^ not supported yet 525 GenLists.GetChildList( TheBuf, cnt, sublst); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 526 ResetBuf( sublst); ***** ^ not supported yet ***** ^ not supported yet 527 ELSIF ElmntType = GenLists.StrCode THEN ***** ^ not supported yet ***** ^ not supported yet 528 LowLevel.Fill( TmpAddr, 1, 0C); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 529 ELSE 530 LowLevel.Fill( TmpAddr, ElmntBytes, 0C); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 531 END; 532 END; 533 END; 534 END ResetBuf; ***** ^ not supported yet 535 536 537 PROCEDURE FindField( StruList: GenLists.GenList; FieldName: ARRAY OF CHAR; ***** ^ not supported yet ***** ^ not supported yet 538 VAR DataList: GenLists.GenList; VAR spot: CARDINAL): BOOLEAN; ***** ^ not supported yet 539 (* flip thru structure to find field & return the sublist 540 it is in & its position in that list; 541 if can't find, return FALSE. 542 Start counting with spot.*) 543 VAR 544 NameSize, NameType, PeriodSpot, indx, cnt, 545 FieldLeng, ElmntBytes, ElmntType: CARDINAL; 546 TmpPtr, NamePtr: LowLevel.Address8086; ***** ^ not supported yet 547 SubName: ARRAY [0..255] OF CHAR; ***** ^ not supported yet ***** ^ not supported yet 548 NotFound, StillMatches: BOOLEAN; 549 SubStruList, SubDataList: GenLists.GenList; ***** ^ not supported yet 550 TmpAddr: SYSTEM.ADDRESS; ***** ^ not supported yet 551 BEGIN 552 (*FindField*) 553 StrEdit.CAPstr(FieldName); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 554 IF PosUtils.Equal( FieldName, 'RECORD') THEN ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 555 spot := 0; 556 RETURN TRUE; 557 END; 558 cnt := 1; 559 NotFound := TRUE; 560 PeriodSpot := PosUtils.Pos( '.', FieldName); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 561 StrEdit.SetLength( SubName, 0); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 562 IF PeriodSpot <= HIGH( FieldName) THEN ***** ^ undeclared identifier ***** ^ not supported yet 563 (* period found -> subfields specified *) 564 IF PeriodSpot = M2Strings.Length(FieldName) - 1 THEN ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 565 StrEdit.SetLength( FieldName, M2Strings.Length( FieldName) - 1); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 566 (* delete period if alone at end of field name *) 567 ELSE 568 M2Strings.Copy( FieldName, PeriodSpot + 1, ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 569 M2Strings.Length(FieldName) -PeriodSpot - 1, ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 570 SubName); ***** ^ not supported yet 571 (* SubName is the name of the subfields *) 572 StrEdit.SetLength( FieldName, PeriodSpot); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 573 (* make field name the name at the first level *) 574 END; 575 END; 576 FieldLeng := M2Strings.Length( FieldName); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 577 (* length of name sought *) 578 WHILE (cnt <= GenLists.ListLength( StruList)) AND NotFound DO ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 579 (* flip thru structure to find field *) 580 GenLists.GetElmtAdr( StruList, cnt, NamePtr.a, NameSize, NameType); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 581 (* read next field *) 582 INC( cnt); ***** ^ undeclared identifier ***** ^ not supported yet 583 IF (NameType # GenLists.ListCode) THEN ***** ^ not supported yet ***** ^ not supported yet 584 (* if not a list, see if it is the sought name *) 585 INC( spot); ***** ^ undeclared identifier ***** ^ not supported yet 586 (* inc the field counter *) 587 IF NameSize = (1 + FieldLeng) THEN 588 (* compare this field name to name sought *) 589 indx := 0; 590 TmpPtr := NamePtr; ***** ^ not supported yet ***** ^ not supported yet 591 StillMatches := TRUE; 592 WHILE StillMatches AND (indx < FieldLeng) DO 593 StillMatches := FieldName[ indx] = TmpPtr.b^; ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 594 IF StillMatches THEN 595 INC( indx); ***** ^ undeclared identifier ***** ^ not supported yet 596 LowLevel.IncAddr( TmpPtr.a, 1 ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 597 END; 598 END; 599 NotFound := NOT StillMatches; 600 END; 601 END; 602 END; 603 IF NotFound THEN 604 RETURN FALSE ; 605 END; 606 IF M2Strings.Length( SubName) # 0 THEN ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 607 GenLists.GetElmtAdr( StruList, cnt, TmpAddr, ElmntBytes, ElmntType); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 608 IF ElmntType = GenLists.ListCode THEN ***** ^ not supported yet ***** ^ not supported yet 609 (* if this field has a sub list *) 610 GenLists.GetChildList( StruList, cnt, SubStruList); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 611 GenLists.GetChildList( DataList, spot, SubDataList); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 612 DataList := SubDataList; ***** ^ not supported yet ***** ^ not supported yet 613 spot := 0; 614 IF NOT FindField( SubStruList, SubName, DataList, spot) ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 615 THEN 616 RETURN FALSE; 617 END; 618 ELSE 619 RETURN FALSE; 620 END; 621 END; 622 RETURN TRUE; 623 END FindField; ***** ^ not supported yet 624 625 PROCEDURE AddRecord( NdxFile: NdxTypes.NdxFileType; RecName: ***** ^ not supported yet 626 ARRAY OF CHAR); ***** ^ not supported yet 627 (* Adds new record to file by: 628 putting record name in BufRecName 629 (don't add to index; WriteRec will do it) 630 and creating empty list buffer *) 631 BEGIN 632 StrEdit.AssignStr(RecName, NdxFile^.BufRecName); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 633 ResetBuf( NdxFile^.ListBuf ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 634 (* initialize empty ListBuf *) 635 END AddRecord; ***** ^ not supported yet 636 637 638 PROCEDURE PutField( VAR NdxFile: NdxTypes.NdxFileType; ***** ^ not supported yet 639 RecName, FieldName: ARRAY OF CHAR; TheType: CARDINAL; ***** ^ not supported yet 640 TheField: ARRAY OF SYSTEM.BYTE ): BOOLEAN; ***** ^ not supported yet 641 BEGIN 642 RETURN PutFieldAdr( NdxFile, RecName, FieldName, TheType, ***** ^ undeclared identifier ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 643 SYSTEM.ADR(TheField), HIGH(TheField) + 1 ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ undeclared identifier ***** ^ not supported yet ***** ^ not supported yet 644 END PutField; ***** ^ not supported yet 645 646 647 PROCEDURE GetField( VAR NdxFile: NdxTypes.NdxFileType; ***** ^ not supported yet 648 RecName, FieldName: ARRAY OF CHAR; VAR TheType: CARDINAL; ***** ^ not supported yet 649 VAR TheField: ARRAY OF SYSTEM.BYTE ): BOOLEAN; ***** ^ not supported yet 650 VAR 651 TmpAdr: SYSTEM.ADDRESS; ***** ^ not supported yet 652 TmpSize: CARDINAL; 653 found: BOOLEAN; 654 BEGIN 655 found := GetFieldAdr( NdxFile, RecName, FieldName, TheType, ***** ^ undeclared identifier ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 656 TmpAdr, TmpSize ); ***** ^ not supported yet ***** ^ not supported yet 657 IF found THEN 658 LowLevel.Move( TmpAdr, SYSTEM.ADR(TheField), ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 659 Numbers.Min(TmpSize, HIGH(TheField) + 1) ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ undeclared identifier ***** ^ not supported yet ***** ^ not supported yet 660 IF TheType = GenLists.StrCode THEN ***** ^ not supported yet ***** ^ not supported yet 661 IF (HIGH(TheField) + 2) < TmpSize THEN ***** ^ undeclared identifier ***** ^ not supported yet 662 (*Ignore the fact that we couldn't store the null 663 terminator.*) 664 found := FALSE; 665 END; 666 ELSIF (HIGH(TheField) + 1) < TmpSize THEN ***** ^ undeclared identifier ***** ^ not supported yet 667 (*We do this to warn user that there's been an 668 overflow.*) 669 found := FALSE; 670 END; 671 END; 672 RETURN found; 673 END GetField; ***** ^ not supported yet 674 675 676 PROCEDURE PutFieldAdr( VAR NdxFile: NdxTypes.NdxFileType; RecName, ***** ^ not supported yet 677 FieldName: ARRAY OF CHAR; TheType: CARDINAL; TheFieldAdr: ***** ^ not supported yet 678 SYSTEM.ADDRESS; TheFieldSize: CARDINAL ): BOOLEAN; ***** ^ not supported yet 679 (*Returns FALSE if FieldName is not in the structure list 680 associated with NdxFile, or if not of TheType. It 681 calls InitBuffer to: do a Retrieve if current contents of 682 RecName are not in the read buffer, and then it transfers 683 from the read buffer into the list buffer (actually it 684 allocates a list element for every field in the read 685 buffer). If the RecName does not exist, it is created. 686 Then it looks for FieldName in that list (the list 687 buffer), encodes the incoming string and puts it over the 688 current value. Doesn't actually write anything to the 689 file; you have to use WriteRecord before doing a Put with 690 any different record, else the stuff you've stored in the 691 list buffer will be lost.*) 692 VAR 693 len1, len2, spot: CARDINAL; 694 TmpList, DataList: GenLists.GenList; ***** ^ not supported yet 695 BEGIN 696 spot := 0; 697 StrEdit.CrunchBlanks( RecName ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 698 len1 := M2Strings.Length(RecName); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 699 IF len1 > NdxTypes.RecNameLength THEN ***** ^ not supported yet ***** ^ not supported yet 700 StrEdit.SetLength( RecName, NdxTypes.RecNameLength ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 701 END; 702 IF len1 = 0 THEN 703 RETURN FALSE; 704 ELSIF NOT NdxBones.InitBuffer( NdxFile, RecName) THEN ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 705 (*Loads file data if exists, or else creates new record.*) 706 AddRecord( NdxFile, RecName); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 707 END; 708 DataList := NdxFile^.ListBuf; ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 709 IF NOT FindField( NdxFile^.StructLst, FieldName, DataList, spot) THEN ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 710 (* locates field; returns list and position *) 711 RETURN FALSE; 712 END; 713 IF (spot = 0) THEN 714 (* replacing the entire record *) 715 IF (TheType # GenLists.ListCode) THEN ***** ^ not supported yet ***** ^ not supported yet 716 (*This used to be illegal. Now we anticipate what 717 they're trying to do.*) 718 GenLists.NewList( TmpList ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 719 GenLists.ListInsertAdr( TheFieldAdr, TheFieldSize, ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 720 TheType, TmpList, 1 ); ***** ^ not supported yet ***** ^ not supported yet 721 ELSIF NOT GenLists.AdrToList( TheFieldAdr, TheFieldSize, TmpList ) THEN ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 722 HALT(); ***** ^ undeclared identifier ***** ^ not supported yet 723 END; 724 len1 := GenLists.ListLength(TmpList); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 725 len2 := GenLists.ListLength(DataList); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 726 IF ( 1 + len1 ) >= len2 THEN 727 (* only allow if list as big as structure *) 728 IF SYSTEM.ADDRESS(NdxFile^.ListBuf) # SYSTEM.ADDRESS(TmpList) THEN ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 729 (*We do this test because it's likely that ListBuf and 730 TmpList will be the same--GetField gives you the real 731 ListBuf, not a copy of it, so people may be modifying 732 the ListBuf directly and then passing it back to 733 PutField. The PutField in that case isn't necessary, 734 since PutField's only purpose is to modify the 735 ListBuf.*) 736 GenLists.DisposeList( NdxFile^.ListBuf); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 737 NdxFile^.ListBuf := TmpList; ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 738 (* dispose of old buffer and use new data as buffer *) 739 END; 740 ELSE 741 RETURN FALSE; 742 END; 743 ELSE 744 GenLists.ListReplaceAdr( TheFieldAdr, TheFieldSize, TheType, ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 745 DataList, spot ); ***** ^ not supported yet ***** ^ not supported yet 746 (* puts new data in list buffer in proper spot *) 747 END; 748 RETURN TRUE; 749 END PutFieldAdr; ***** ^ not supported yet 750 751 752 PROCEDURE GetFieldAdr( VAR NdxFile: NdxTypes.NdxFileType; RecName, ***** ^ not supported yet 753 FieldName: ARRAY OF CHAR; VAR TheType: CARDINAL; VAR ***** ^ not supported yet 754 TheFieldAdr: SYSTEM.ADDRESS; VAR TheFieldSize: CARDINAL ): ***** ^ not supported yet 755 BOOLEAN; 756 (*GetFieldAdr first calls InitBuffer to do retrieve if 757 needed & finds field in index list if it is there. If 758 problem with either, return FALSE. Then get the element 759 out of the ListBuffer *) 760 VAR 761 spot: CARDINAL; 762 DataList: GenLists.GenList; ***** ^ not supported yet 763 offset: LONGINT; (*Not used.*) 764 RecSize, ListSpot: CARDINAL; (*Not used.*) 765 766 BEGIN 767 spot := 0; 768 StrEdit.CrunchBlanks( RecName ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 769 IF (M2Strings.Length(RecName)=0) OR (NOT NdxBones.FindRecord( ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 770 NdxFile, RecName, offset, RecSize, ListSpot )) THEN ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 771 RETURN FALSE; 772 END; 773 IF NOT NdxBones.InitBuffer( NdxFile, RecName) THEN ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 774 RETURN FALSE; 775 END; 776 DataList := NdxFile^.ListBuf; ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 777 IF NOT FindField( NdxFile^.StructLst, FieldName, ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 778 DataList, spot) THEN ***** ^ not supported yet ***** ^ not supported yet 779 RETURN FALSE; 780 END; 781 IF spot = 0 THEN 782 (* entire record requested *) 783 TheFieldSize := (*SYSTEM.TSIZE(GenLists.GenList)*) 4; 784 TheFieldAdr := GenLists.AdrOfList( NdxFile^.ListBuf ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 785 TheType := GenLists.ListCode; ***** ^ not supported yet ***** ^ not supported yet 786 RETURN TRUE; 787 ELSE 788 GenLists.GetElmtAdr( DataList, spot, TheFieldAdr, ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 789 TheFieldSize, TheType); ***** ^ not supported yet 790 (* try to retrieve the requested element *) 791 END; 792 RETURN TRUE; 793 END GetFieldAdr; ***** ^ not supported yet 794 795 796 PROCEDURE FileStructure( NdxFile: NdxTypes.NdxFileType; ***** ^ not supported yet 797 VAR Structure: ARRAY OF CHAR ); ***** ^ not supported yet 798 (*Returns a string containing the names of all fields 799 defined for the NdxFile, in the form used by the 800 Structure parameter of the CreateNdxFile procedure.*) 801 802 PROCEDURE AddTheList( TheList: GenLists.GenList); ***** ^ not supported yet 803 VAR 804 leng, cnt, TheType, TmpSize: CARDINAL; 805 tmpbuf: ARRAY [0..NdxTypes.RecNameLength] OF CHAR; ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 806 TmpAddr: SYSTEM.ADDRESS; ***** ^ not supported yet 807 SubList: GenLists.GenList; ***** ^ not supported yet 808 BEGIN 809 leng := GenLists.ListLength( TheList); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 810 FOR cnt := 1 TO leng DO 811 GenLists.GetElmtAdr( TheList, cnt, TmpAddr, TmpSize, TheType); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 812 IF TheType # GenLists.ListCode THEN ***** ^ not supported yet ***** ^ not supported yet 813 IF cnt # 1 THEN 814 StrEdit.Append( Structure, ','); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 815 END; 816 IF TmpSize <= (NdxTypes.RecNameLength + 1) THEN ***** ^ not supported yet ***** ^ not supported yet 817 LowLevel.Move( TmpAddr, SYSTEM.ADR(tmpbuf), TmpSize); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 818 ELSE 819 LowLevel.Move( TmpAddr, SYSTEM.ADR(tmpbuf), ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 820 (NdxTypes.RecNameLength + 1)); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 821 END; 822 StrEdit.Append( Structure, tmpbuf); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 823 ELSE 824 StrEdit.Append( Structure, '{'); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 825 GenLists.GetChildList( TheList, cnt, SubList); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 826 AddTheList( SubList); ***** ^ not supported yet ***** ^ not supported yet 827 StrEdit.Append( Structure, '}'); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 828 END; 829 END; 830 END AddTheList; ***** ^ not supported yet 831 832 BEGIN 833 NdxTypes.CheckInit( NdxFile ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 834 StrEdit.SetLength( Structure, 0); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 835 AddTheList( NdxFile^.StructLst); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 836 END FileStructure; ***** ^ not supported yet 837 838 839 PROCEDURE RecordExists( NdxFile: NdxTypes.NdxFileType; VAR ***** ^ not supported yet 840 RecName: ARRAY OF CHAR ): BOOLEAN; ***** ^ not supported yet 841 VAR 842 offset: LONGINT; (*Not used.*) 843 RecSize, ListSpot: CARDINAL; (*Not used.*) 844 BEGIN 845 NdxTypes.CheckInit( NdxFile ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 846 StrEdit.CrunchBlanks( RecName ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 847 RETURN (M2Strings.Length(RecName) # 0) AND ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 848 (NdxBones.FindRecord( NdxFile, RecName, offset, RecSize, ListSpot )); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 849 END RecordExists; ***** ^ not supported yet 850 851 PROCEDURE SafetyOn( VAR NdxFile: NdxTypes.NdxFileType ); ***** ^ not supported yet 852 (*After SafetyOn is called, every time WriteRecord adds a 853 record to the end of an NdxFile and thereby overwrites the 854 ndx, it writes out a new copy of the ndx at the end of the 855 file. NdxFiles are initialized with Safety off.*) 856 BEGIN 857 NdxTypes.CheckInit( NdxFile ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 858 NdxFile^.SafetyOn := TRUE; ***** ^ not supported yet ***** ^ not supported yet 859 END SafetyOn; ***** ^ not supported yet 860 861 PROCEDURE SafetyOff( VAR NdxFile: NdxTypes.NdxFileType ); ***** ^ not supported yet 862 (*After SafetyOff is called, the ndx at the end of an NdxFile 863 can be overwritten, and will be restored only when 864 CloseNdxFile is called.*) 865 BEGIN 866 NdxTypes.CheckInit( NdxFile ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 867 NdxFile^.SafetyOn := FALSE; ***** ^ not supported yet ***** ^ not supported yet 868 END SafetyOff; ***** ^ not supported yet 869 870 871 PROCEDURE FindBlankSpace( VAR Ndx: GenLists.GenList; VAR NewElmt: ***** ^ not supported yet 872 NdxTypes.NdxElement; VAR OldElmt: CARDINAL): BOOLEAN; ***** ^ not supported yet 873 (* if can find space for NewElmt in deleted records at end of 874 index, change NewElmt to point to the empty spot, return 875 the cardinal position of the re-used garbage element of 876 the index, and return TRUE *) 877 VAR 878 TheType: CARDINAL; 879 TmpElmt: NdxTypes.NdxElement; ***** ^ not supported yet 880 BEGIN 881 IF (M2Strings.Length( NewElmt.RecName) = 0) OR ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 882 (NewElmt.UsedChars = 0) OR ***** ^ not supported yet ***** ^ not supported yet 883 (GenLists.ListLength(Ndx) = 0) THEN ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 884 (* don't try this for garbage entries or empty index *) 885 RETURN FALSE; 886 ELSE 887 GenLists.GetElmt( Ndx, GenLists.ListLength(Ndx), TmpElmt, TheType); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 888 END; 889 WHILE M2Strings.Length(TmpElmt.RecName) = 0 DO ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 890 (* search through all entries in index with no name 891 (garbage entries) *) 892 IF TmpElmt.Allocated >= NewElmt.Allocated THEN ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 893 (* found an entry to re-use *) 894 NewElmt.Allocated := TmpElmt.Allocated; ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 895 NewElmt.FilePos := TmpElmt.FilePos; ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 896 OldElmt := GenLists.ElmtNow( Ndx); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 897 RETURN TRUE; 898 END; 899 IF GenLists.ElmtNow( Ndx ) = 1 THEN ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 900 (* if can't back up any more, return FALSE *) 901 RETURN FALSE; 902 END; 903 GenLists.NextElmt( Ndx, -1, TmpElmt, TheType); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 904 END; 905 RETURN FALSE; 906 END FindBlankSpace; ***** ^ not supported yet 907 908 (*$O-*) 909 (*We turn off optimization in this procedure to avoid a bug in 910 the beta copy of Logitech's v3.0 compiler.*) 911 912 PROCEDURE InsertNdxEntry( RecName: ARRAY OF CHAR; ***** ^ not supported yet 913 VAR FilePos: LONGINT; UsedChars: CARDINAL; 914 VAR AllocatedChars: CARDINAL; VAR NdxFile: NdxTypes.NdxFileType ): ***** ^ not supported yet 915 BOOLEAN; 916 VAR 917 dummylong: LONGINT; 918 TheElmt, dummycard, OldElmt, NameLength: CARDINAL; 919 TmpElmt: NdxTypes.NdxElement; ***** ^ not supported yet 920 BEGIN 921 NameLength := M2Strings.Length(RecName); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 922 IF NameLength < (HIGH(RecName) + 1) THEN ***** ^ undeclared identifier ***** ^ not supported yet 923 LowLevel.Fill( LowLevel.AddAddr(SYSTEM.ADR(RecName), NameLength ), ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 924 1 + HIGH(RecName) - NameLength, 0C ); ***** ^ undeclared identifier ***** ^ not supported yet ***** ^ not supported yet 925 (*We do this to initialize end space in the Ndx; makes it 926 easier to read when debugging.*) 927 END; 928 LowLevel.Fill( SYSTEM.ADR(TmpElmt.RecName), ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 929 M2Strings.Length(TmpElmt.RecName), 0C ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 930 StrEdit.AssignStr( RecName, TmpElmt.RecName ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 931 TmpElmt.FilePos := FilePos; ***** ^ not supported yet ***** ^ not supported yet 932 TmpElmt.UsedChars := UsedChars; ***** ^ not supported yet ***** ^ not supported yet 933 TmpElmt.Allocated := AllocatedChars; ***** ^ not supported yet ***** ^ not supported yet 934 IF NOT NdxBones.FindRecord(NdxFile, RecName, dummylong, ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 935 dummycard, TheElmt) THEN ***** ^ not supported yet 936 (*The FindRecord returns the alphabetically correct 937 insertion point, TheElmt.*) 938 IF FindBlankSpace( NdxFile^.Ndx, TmpElmt, OldElmt) THEN ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 939 (* if can find space for record in existing garbage, use it 940 and delete the garbage index entry *) 941 FilePos := TmpElmt.FilePos; ***** ^ not supported yet ***** ^ not supported yet 942 AllocatedChars := TmpElmt.Allocated; ***** ^ not supported yet ***** ^ not supported yet 943 GenLists.ListDelete( NdxFile^.Ndx, OldElmt, 1); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 944 END; 945 GenLists.ListInsert( TmpElmt, NdxTypes.NdxTypeCode, ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 946 NdxFile^.Ndx, TheElmt); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 947 RETURN TRUE; 948 ELSE 949 RETURN FALSE; 950 END; 951 END InsertNdxEntry; ***** ^ not supported yet 952 (*$O=*) 953 954 955 PROCEDURE ChangeNdxEntry( OldRecName, NewRecName: ARRAY OF CHAR; ***** ^ not supported yet 956 FilePos: LONGINT; NumUsed: CARDINAL; VAR NdxFile: NdxTypes.NdxFileType): ***** ^ not supported yet 957 BOOLEAN; 958 VAR 959 TmpElmt: NdxTypes.NdxElement; ***** ^ not supported yet 960 dummylong: LONGINT; 961 dummycard, NewElmt, OldElmt: CARDINAL; 962 ToGarbage: BOOLEAN; 963 BEGIN 964 LowLevel.Fill( SYSTEM.ADR(TmpElmt.RecName), ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 965 M2Strings.Length(TmpElmt.RecName), 0C ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 966 StrEdit.AssignStr( NewRecName, TmpElmt.RecName ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 967 ToGarbage := M2Strings.Length( NewRecName)=0; ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 968 IF ToGarbage THEN 969 TmpElmt.UsedChars := 0; ***** ^ not supported yet ***** ^ not supported yet 970 (* Marks the entry as garbage if you change name to '' *) 971 ELSE 972 TmpElmt.UsedChars := NumUsed; ***** ^ not supported yet ***** ^ not supported yet 973 END; 974 TmpElmt.FilePos := FilePos; ***** ^ not supported yet ***** ^ not supported yet 975 TmpElmt.Allocated := NumUsed; ***** ^ not supported yet ***** ^ not supported yet 976 IF NdxBones.FindRecord(NdxFile, OldRecName, dummylong, ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 977 dummycard, dummycard) THEN ***** ^ not supported yet 978 IF NdxBones.CompareProc( OldRecName, NewRecName) # 0 THEN ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 979 (* to change record names, find and save old position, 980 if new name does not exist then delete old and insert 981 new *) 982 OldElmt := GenLists.ElmtNow(NdxFile^.Ndx); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 983 IF ToGarbage OR (NOT NdxBones.FindRecord(NdxFile, NewRecName, ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 984 dummylong, dummycard, dummycard)) THEN ***** ^ not supported yet 985 GenLists.ListDelete( NdxFile^.Ndx, OldElmt, 1); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 986 (*If new name does not exist (or represents garbage) 987 and old entry can be deleted, return success of 988 trying to insert new name *) 989 ToGarbage := NdxBones.FindRecord(NdxFile, NewRecName, dummylong, ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 990 dummycard, NewElmt); ***** ^ not supported yet 991 (*We do not need this result. We need NewElmt. *) 992 IF ToGarbage THEN 993 (* if found new value in file already, it is a 994 garbage entry; insert at that point *) 995 NewElmt := GenLists.ElmtNow( NdxFile^.Ndx); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 996 END; 997 GenLists.ListInsert( TmpElmt, NdxTypes.NdxTypeCode, ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 998 NdxFile^.Ndx, NewElmt); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 999 RETURN TRUE; 1000 ELSE 1001 RETURN FALSE; 1002 END; 1003 (* if changed name, delete old and add new *) 1004 END; 1005 GenLists.ListReplace( TmpElmt, NdxTypes.NdxTypeCode, NdxFile^.Ndx, ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 1006 GenLists.ElmtNow(NdxFile^.Ndx)); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 1007 RETURN TRUE; 1008 ELSE 1009 RETURN FALSE; 1010 END; 1011 END ChangeNdxEntry; ***** ^ not supported yet 1012 1013 1014 PROCEDURE Init(); 1015 BEGIN 1016 IF Initialized THEN 1017 RETURN; 1018 ELSE 1019 Initialized := TRUE; 1020 END; 1021 (*EntryDiag: 1022 Diagnostics.Init(); 1023 :EntryDiag*) 1024 1025 Drectory.Init(); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 1026 ErrorManager.Init(); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 1027 ErrorNames.Init(); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 1028 HandleIO.Init(); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 1029 GenLists.Init(); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 1030 ListUtils.Init(); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 1031 LowLevel.Init(); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 1032 M2Strings.Init(); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 1033 NdxBones.Init(); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 1034 NdxTypes.Init(); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 1035 Numbers.Init(); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 1036 NumTypes.Init(); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 1037 PosUtils.Init(); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 1038 StrEdit.Init(); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 1039 StringIO.Init(); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 1040 VStorage.Init(); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 1041 (*EntryDiag: 1042 Diagnostics.diagS( 'Entering NdxFiles', '' ); 1043 :EntryDiag*) 1044 1045 VStorage.NilHandle( NulHandle ); ***** ^ not supported yet ***** ^ not supported yet ***** ^ not supported yet 1046 1047 (*EntryDiag: 1048 Diagnostics.diagS( 'Exiting NdxFiles', '' ); 1049 :EntryDiag*) 1050 1051 END Init; ***** ^ not supported yet 1052 1053 1054 BEGIN 1055 Initialized := FALSE; 1056 Init(); ***** ^ not supported yet ***** ^ not supported yet 1057 END NdxFiles. ***** ^ not supported yet 1331 errors