home *** CD-ROM | disk | FTP | other *** search
/ World of Shareware - Software Farm 2 / wosw_2.zip / wosw_2 / QBAS / QBTREE42.ZIP / CONVERT.BAS next >
BASIC Source File  |  1989-10-19  |  2KB  |  108 lines

  1.  
  2. '{CONVERT versions of QBTREE prior to 4.20}
  3. '{10-19-89 version 1.00}
  4.  
  5. DEFINT A-Z
  6.  
  7. REM $INCLUDE: 'qbtree42.bi'
  8.  
  9. DIM byte AS STRING * 1
  10.  
  11. PRINT
  12. PRINT "CONVERT 1.00  (C)1989 Cornel Huth  10-19-89"
  13. PRINT "              convert QSAM 1.x - 3.xx and BTREE 4.x to QBTREE 4.20"
  14. PRINT
  15. COLOR 15, 0
  16. PRINT "DO NOT CONVERT YOUR ORIGINAL FILE ";
  17. COLOR 7, 0
  18. PRINT " - make a copy and convert it"
  19. PRINT
  20. INPUT "Key file to convert: ", fk$
  21. INPUT "   ...its data file: ", fd$
  22. PRINT
  23. fk$ = UCASE$(fk$)
  24. fd$ = UCASE$(fd$)
  25.  
  26. stat = OpenKeyFile(fk$, 0)
  27. IF stat = 228 THEN PRINT fk$; " cannot be converted": LOCATE 24, 1: SYSTEM
  28. IF stat = 0 THEN PRINT fk$; " does not need to be converted": LOCATE 24, 1: SYSTEM
  29. st = OpenDataFile(fd$, 0)
  30. IF st THEN
  31.    PRINT "Error:"; st; " in OpenDataFile(" + CHR$(34) + fd$ + CHR$(34); ",0)"
  32.    GOTO xitx
  33. END IF
  34.  
  35. '{change the version id byte}
  36. IF stat = 227 THEN
  37.    wbf = FREEFILE
  38.    IF GetDosVersion >= 300 THEN
  39.       OPEN fk$ FOR BINARY ACCESS READ WRITE SHARED AS #wbf
  40.    ELSE
  41.       OPEN fk$ FOR BINARY AS #wbf
  42.    END IF
  43.    byte = "*"
  44.    PUT wbf, 1, byte             '{leave the file open}
  45.    stat = OpenKeyFile(fk$, 0)   '{open her up}
  46.    IF stat THEN
  47.       PRINT "Error:"; stat; " in OpenKeyFile(" + CHR$(34) + fk$ + CHR$(34); ",0) after '*'"
  48.       GOTO xit
  49.    END IF
  50. ELSEIF stat <> 0 THEN
  51.    PRINT "Error:"; stat; " in OpenKeyFile(" + CHR$(34) + fk$ + CHR$(34); ",0)"
  52.    GOTO xitx
  53. END IF
  54.  
  55. '{need the key length data}
  56. stat = StatKeyFile(0, kl, ks&, bf)
  57. IF stat THEN
  58.    PRINT "Error:"; stat; " in StatKeyFile(0)"
  59.    GOTO xit
  60. END IF
  61.  
  62. '{start at the beginning}
  63. stat = RewindKeyFile(0)
  64. IF stat THEN
  65.    PRINT "Error:"; stat; " in RewindKeyFile(0)"
  66.    GOTO xit
  67. END IF
  68.  
  69. '{get the key to transplant}
  70. stat = GetNext(0, 0, ke$, rec$)
  71. IF stat THEN
  72.    PRINT "Error:"; stat; " in GetNext(0)"
  73.    GOTO xit
  74. END IF
  75.  
  76. '{null-out the first key space}
  77. null$ = STRING$(kl + 7, 0)
  78. PUT #wbf, 514, null$
  79. CLOSE #wbf
  80.  
  81. '{transplant the first key and data}
  82. stat = PutKey(0, 0, ke$)
  83. IF stat THEN
  84.    PRINT "Error:"; stat; " in PutKey(0)"
  85.    GOTO xit
  86. END IF
  87.  
  88. '{exit here}
  89. xit:
  90.  
  91. stat = CloseKeyFile(0)
  92. IF stat THEN
  93.    PRINT "Error:"; stat; " in CloseKeyFile(0)"
  94. END IF
  95.  
  96. stat = CloseDataFile(0)
  97. IF stat THEN
  98.    PRINT "Error:"; stat; " in CloseDataFile(0)"
  99. END IF
  100.  
  101. xitx:
  102.  
  103. PRINT "done."
  104. LOCATE 24, 1
  105. SYSTEM
  106.  
  107.  
  108.