home *** CD-ROM | disk | FTP | other *** search
-
- '{CONVERT versions of QBTREE prior to 4.20}
- '{10-19-89 version 1.00}
-
- DEFINT A-Z
-
- REM $INCLUDE: 'qbtree42.bi'
-
- DIM byte AS STRING * 1
-
- PRINT
- PRINT "CONVERT 1.00 (C)1989 Cornel Huth 10-19-89"
- PRINT " convert QSAM 1.x - 3.xx and BTREE 4.x to QBTREE 4.20"
- PRINT
- COLOR 15, 0
- PRINT "DO NOT CONVERT YOUR ORIGINAL FILE ";
- COLOR 7, 0
- PRINT " - make a copy and convert it"
- PRINT
- INPUT "Key file to convert: ", fk$
- INPUT " ...its data file: ", fd$
- PRINT
- fk$ = UCASE$(fk$)
- fd$ = UCASE$(fd$)
-
- stat = OpenKeyFile(fk$, 0)
- IF stat = 228 THEN PRINT fk$; " cannot be converted": LOCATE 24, 1: SYSTEM
- IF stat = 0 THEN PRINT fk$; " does not need to be converted": LOCATE 24, 1: SYSTEM
- st = OpenDataFile(fd$, 0)
- IF st THEN
- PRINT "Error:"; st; " in OpenDataFile(" + CHR$(34) + fd$ + CHR$(34); ",0)"
- GOTO xitx
- END IF
-
- '{change the version id byte}
- IF stat = 227 THEN
- wbf = FREEFILE
- IF GetDosVersion >= 300 THEN
- OPEN fk$ FOR BINARY ACCESS READ WRITE SHARED AS #wbf
- ELSE
- OPEN fk$ FOR BINARY AS #wbf
- END IF
- byte = "*"
- PUT wbf, 1, byte '{leave the file open}
- stat = OpenKeyFile(fk$, 0) '{open her up}
- IF stat THEN
- PRINT "Error:"; stat; " in OpenKeyFile(" + CHR$(34) + fk$ + CHR$(34); ",0) after '*'"
- GOTO xit
- END IF
- ELSEIF stat <> 0 THEN
- PRINT "Error:"; stat; " in OpenKeyFile(" + CHR$(34) + fk$ + CHR$(34); ",0)"
- GOTO xitx
- END IF
-
- '{need the key length data}
- stat = StatKeyFile(0, kl, ks&, bf)
- IF stat THEN
- PRINT "Error:"; stat; " in StatKeyFile(0)"
- GOTO xit
- END IF
-
- '{start at the beginning}
- stat = RewindKeyFile(0)
- IF stat THEN
- PRINT "Error:"; stat; " in RewindKeyFile(0)"
- GOTO xit
- END IF
-
- '{get the key to transplant}
- stat = GetNext(0, 0, ke$, rec$)
- IF stat THEN
- PRINT "Error:"; stat; " in GetNext(0)"
- GOTO xit
- END IF
-
- '{null-out the first key space}
- null$ = STRING$(kl + 7, 0)
- PUT #wbf, 514, null$
- CLOSE #wbf
-
- '{transplant the first key and data}
- stat = PutKey(0, 0, ke$)
- IF stat THEN
- PRINT "Error:"; stat; " in PutKey(0)"
- GOTO xit
- END IF
-
- '{exit here}
- xit:
-
- stat = CloseKeyFile(0)
- IF stat THEN
- PRINT "Error:"; stat; " in CloseKeyFile(0)"
- END IF
-
- stat = CloseDataFile(0)
- IF stat THEN
- PRINT "Error:"; stat; " in CloseDataFile(0)"
- END IF
-
- xitx:
-
- PRINT "done."
- LOCATE 24, 1
- SYSTEM
-
-
-