ISAM-TWO - INDEXED SEQUENTIAL ACCESS METHOD - 27 May 2010 Altair BASIC used in ASDC Accounting Software Pertec replacement for original defective routines Tom Sanderson www.virtualaltair.com 60000 'ISAM062878RB ISAM-TWO INDEXED SEQUENTIAL ACCESS METHOD 60005 ' STANDARD LENGTH KEYS (6 CHAR) 60010 OPEN"R",FI%,NA$,DI%:GOSUB60300:LSETO0$=O9$:LSETO1$=DA$ 60020 O$=MKI$(O):LSETO2$=O$:LSETO3$=MKI$(2):LSETO4$=O$:LSETO5$=O$ 60030 LSETO6$=O$:PUTOJ,2:CLOSEOJ:RETURN 60200 GOSUB60800:OP=1:GOSUB65150:OU=3:RETURN 60300 GOSUB60800:O9$="ISAM-TWO" 60310 FIELDOJ,8ASO0$,8ASO1$,2ASO2$,2ASO3$,2ASO4$,2ASO5$,2ASO6$:RETURN 60500 DEFINTO:O=0:OJ=O 60550 DIMOB$(NB%),OZ(NB%),OW(NB%),OC(NB%),OF(NB%),OB(NB%) 60560 FOROI=OTONB%:OZ(OI)=O:OB(OI)=OI-1:OF(OI)=OI+1:NEXT:OB=NB%:OF=O 60580 DIMOX(6,NF%),OY(6,NF%):FOROI=OTONF%:OX(O,OI)=O:OY(O,OI)=O:NEXT 60590 DIMOO(NF%),OU(NF%),OQ(NF%),OL(NF%),OK(NF%),OH(NF%),OD(NF%),OE(NF%) 60600 DIMNR%(NF%),OA(NF%),EX%(NF%),CD$(NF%) 60610 IFV$(21)="H"THENOD(O)=32760ELSEIFV$(21)="F"THENOD(O)=2032 60620 DIMOK$(12),OS$(12),OP$(12):RETURN 60800 ER%=O:IFOJ=FI%THENRETURN 60810 OQ(OJ)=OQ:OL(OJ)=OL:OK(OJ)=OK:OH(OJ)=OH:OO(OJ)=OO:OU(OJ)=OU:OJ=FI% 60820 OQ=OQ(OJ):OL=OL(OJ):OK=OK(OJ):OH=OH(OJ):OO=OO(OJ):OU=OU(OJ) 60830 FIELDOJ,128ASBU$:OT=2:FIELDOJ,2ASOP$(O) 60840 FOROI=1TO12:FIELDOJ,(OT)ASO$,6ASOK$(OI),2ASOS$(OI),2ASOP$(OI) 60850 OT=OT+10:NEXT:FIELDOJ,(OT)ASO$,2ASOM$,2ASOX$:RETURN 61000 OPEN"R",FI%,NA$,DI%:GOSUB60300:GETOJ,2 61010 IFO0$<>O9$THENER%=16:CLOSEOJ:RETURN 61130 OD(OJ)=DI%:CD$(OJ)=O1$:NR%(OJ)=CVI(O2$):EX%(OJ)=CVI(O3$) 61140 OA(OJ)=CVI(O4$):OH=CVI(O5$):OE(OJ)=CVI(O6$) 61150 FOROI=OTONB%:IFOW(OI)=OJTHENOZ(OI)=O 61160 NEXT:OO=O 61200 GOSUB60800:OQ=O:OL=O:OK=O:RETURN 61500 GOSUB60300:IFOO<>OTHENPUTOJ,OO 61560 FOROI=OTONB%:IFOZ(OI)<>OANDOW(OI)=OJANDOC(OI)=1ANDOI<>OFTHEN LSETBU$=OB$(OI):PUTOJ,OZ(OI):OZ(OI)=O 61600 NEXT:LSETO0$=O9$:LSETO1$=CD$(OJ):LSETO2$=MKI$(NR%(OJ)) 61610 LSETO3$=MKI$(EX%(OJ)):LSETO4$=MKI$(OA(OJ)) 61620 LSETO5$=MKI$(OH):LSETO6$=MKI$(OE(OJ)):PUTOJ,2:CLOSEOJ:RETURN 62000 GOSUB60800:GOSUB65000:IFOP<>OTHENER%=3:GOTO62190 62050 IFOE(OJ)>6GOTO62060ELSEIFOD(O)OTHENOP=OL:GOSUB65200:GOTO62110 62090 GOSUB65100:LSETBU$=MKI$(OH)+OU$:OM=1:OU=1:OH=OP:GOTO62180 62110 O$=LEFT$(BU$,OK*10+2)+OU$+MID$(BU$,OK*10+3) 62130 LSETBU$=O$:OU=1:OM=OM+1:IFOM<=12GOTO62180 62140 OM=6:OZ$=MID$(O$,71,62):GOSUB65100:OU=1 62150 OU$=MID$(O$,63,8)+MKI$(OP):LSETBU$=OZ$:GOSUB65400:GOTO62080 62180 GOSUB63200:OO=OV:OU=3:RETURN 62190 GOSUB63200:RETURN 62500 GOSUB63000:IFER%<>OGOTO62780ELSEGOSUB62900:NR%(OJ)=NR%(OJ)-1 62560 OP=OL:GOSUB65200:IFCVI(OP$(OK))=OGOTO62600ELSEOT=OL:OI=OK 62570 GOSUB65300:OP=OL:GOSUB65200:OK=O:IFCVI(OP$(OK))<>OGOTO62570 62580 OK=1:OU$=OK$(OK):OZ$=OS$(OK):OP=OT:GOSUB65200 62590 OU=1:LSETOK$(OI)=OU$:LSETOS$(OI)=OZ$:OP=OL:GOSUB65200 62600 O$=LEFT$(BU$,10*OK-8)+MID$(BU$,10*OK+3,10*(OM-OK)) 62610 IFOQ>OGOTO62640ELSEOM=OM-1 62620 IFOM=OTHENOH=CVI(OP$(O)):GOSUB62900:GOTO62780 62630 LSETBU$=O$:OU=1:GOTO62780 62640 OI=OM:GOSUB65400:OP=OL:GOSUB65200:IFOK<>OGOTO62680 62650 O$=O$+MID$(BU$,3,8):OP=CVI(OP$(1)):GOSUB65300 62660 GOSUB65200:O$=O$+LEFT$(BU$,10*OM+2):OI=OI+OM 62670 OP=OL:GOSUB65200:GOTO62700 62680 O$=MID$(BU$,10*OK-7,8)+O$:OK=OK-1:GOSUB65300:OP=OL 62690 GOSUB65200:O$=LEFT$(BU$,10*OM+2)+O$:OI=OI+OM 62700 OU=1:IFOI>12GOTO62730ELSELSETBU$=O$:OM=OI 62710 GOSUB65400:OP=OL:GOSUB65200:OK=OK+1:OP=CVI(OP$(OK)) 62720 GOSUB65200:GOSUB62900:OP=OL:GOSUB65200:GOTO62600 62730 OM=OI\2:LSETBU$=LEFT$(O$,10*OM+2):GOSUB65400:OP=OL:GOSUB65200:OU=1 62740 OT=10*(OI\2)+3:OK=OK+1 62750 LSETOK$(OK)=MID$(O$,OT,6):LSETOS$(OK)=MID$(O$,OT+6,2):GOSUB65300 62760 OP=OL:GOSUB65200:OM=(OI-1)\2:OU=1:LSETBU$=RIGHT$(O$,10*OM+2) 62780 GOSUB63200:RETURN 62900 OE(OJ)=OE(OJ)+1:LSETOX$=MKI$(OA(OJ)):OU=3:OA(OJ)=OP:RETURN 63000 GOSUB60800:GOSUB65000:IFOP=OTHENGOSUB63200:ER%=2:RETURN 63010 GOSUB65150:RETURN 63200 OP=-1:GOSUB65250:RETURN 63500 GOSUB63000:IFER%<>0THENRETURNELSEOU=3:RETURN 64000 GOSUB60800:IFOL<>OTHENOP=OL:GOSUB65200:GOTO64100 64060 OQ=O:OL=OH:IFOL=OGOTO64130 64070 OP=OL:GOSUB65200:OK=O 64080 IFOK=OGOTO64100 64090 KE$=OK$(OK):OP=CVI(OS$(OK)):GOSUB65150:RETURN 64100 IFCVI(OP$(OK))<>OTHENGOSUB65300:GOTO64070 64110 OK=OK+1:IFOK<=OMGOTO64080ELSEGOSUB65400 64120 IFOQ=>OTHENOP=OL:GOSUB65200:GOTO64110 64130 GOSUB63200:GOSUB61200:ER%=1:RETURN 64500 GOSUB60800:IFOL<>OTHENOP=OL:GOSUB65200:GOTO64610 64560 OQ=O:OL=OH:IFOL=OGOTO64630 64570 OP=OL:GOSUB65200:OK=OM 64580 IFCVI(OP$(OK))<>OTHENGOSUB65300:GOTO64570 64590 IFOK=OGOTO64610 64600 KE$=OK$(OK):OP=CVI(OS$(OK)):GOSUB65150:RETURN 64610 OK=OK-1:IFOK=>OGOTO64580ELSEGOSUB65400 64620 IFOQ=>OTHENOP=OL:GOSUB65200:GOTO64590 64630 GOSUB63200:GOSUB61200:ER%=1:RETURN 65000 KE$=LEFT$(KE$+SPACE$(6),6) 65006 OQ=O:OL=OH:IFOL=OTHENOP=O:RETURN 65007 OP=OL:GOSUB65200:OK=O 65008 IFKE$OBGOTO65205 65210 GETOJ,OP:OU=O:GOTO65220 65212 IFOW(OE)<>OJTHENIFOB<>OEGOTO65205ELSEGOTO65210 65215 LSETBU$=OB$(OE):OU=OC(OE):OZ(OE)=O:IFOE<>OBTHENGOSUB65240 65220 OM=CVI(OM$):OO=OP:RETURN 65240 OF(OB(OE))=OF(OE):OF(OB)=OE:OB(OF(OE))=OB(OE):OB(OE)=OB:OB=OE: RETURN 65250 IFOO=OTHENRETURNELSEIFOU>1GOTO65292 65255 IFOZ(OB)=OPANDOW(OB)=OJTHENOE=OB(OB):GOSUB65240 65260 LSETOM$=MKI$(OM):OB$(OF)=BU$:OC(OF)=OU:OZ(OF)=OO:OW(OF)=OJ 65265 IFOC(OB)=OOROZ(OB)=OGOTO65290ELSEOW=OW(OB):IFOW=OJGOTO65285 65270 FIELDOW,128ASOW$:IFOO(OW)<>OTHENLSETBU$=OW$ 65275 LSETOW$=OB$(OB):PUTOW,OZ(OB):IFOO(OW)<>OTHENLSETOW$=BU$ 65280 GOTO65290 65285 LSETBU$=OB$(OB):PUTOJ,OZ(OB) 65290 OF(OB)=OF:OB(OF)=OB:OF=OB:OB=OB(OB):OO=O:RETURN 65292 IFOU=3THENPUTOJ,OO 65294 OO=O:RETURN 65300 OQ=OQ+1:OX(OQ,OJ)=OL:OY(OQ,OJ)=OK:OL=CVI(OP$(OK)):RETURN 65400 OK=OY(OQ,OJ):OL=OX(OQ,OJ):OQ=OQ-1:RETURN'END OK