CONVERTING "COMPRESSED" BAZIC DATA FILES TO ASCII

 Reprinted from: "MicroNotes", Micro Mike's, Inc.

BAZIC   data  files  are  stored  normally  in   a 
"compressed"  BCD  format,   where  numberics  are 
stored  as a few bytes,  i.e.,  each number stored 
under  8-digit  BAZIC (BAZIC08) is 5  bytes  long, 
each  number under 10-digit (BAZIC10) is  6  bytes 
long,  under 12-digit BAZIC each number is 7 bytes 
long  and  a  14-digit numeric is  8  bytes  long.  
String information is stored in ASCII, but leading 
bytes  specify the string length.   If the  string 
contains  fewer  than 256 bytes it has  2  leading 
bytes,  strings  256  bytes  or longer  contain  3 
leading bytes.

Compressed BAZIC data files can be converted to an 
ASCII  file format with a program similar  to  the 
following:

3 REM PROGRAM TO CONVERT BAZIC DATA FILES TO ASCII DATA FILES
5 CLS
7 DIM B$(1000)
10 INPUT "NAME OF SOURCE FILE: ",A$
20 A = FILE(A$)\IF A1<>-1 THEN 30\!"FILE DOES  NOT EXIST"\ GOTO 10
30 INPUT "NAME OF DESTINATION FILE: ",A1$
40 A1=FILE(A1$) \ IF A1<>-1 THEN 50 \ CREATE A1$,2 \ A1=3
50 OPEN #1 %A,A$ \ OPEN #2 A1,A1$
60 A2 =TYP(1) \  PM A2+1 GOTO 130,70,120 \ REM END MARK,STRING,NUMBER
70 READ #1,B$
80 FOR  N =  1 TO  LEN(B$) \ IF B$(N,N) = "," THEN F=1 \ NEXT N
90 IF  F=1 THEN B$=CHR$(34)+B$+CHR$(34) \ F=0  REM CHR$(34) IS "
100 FOR N = 1 TO LEN(B$) \ WRITE #2,&ASC(B$(N,N)) \ NEXT N
120 READ #1,B1 \ B$=STR$(B1) \ B$=B$(2) \ GOTO 80
130 WRITE #2,&24 \ REM END OF FILE MARKER
140 CLOSE #1 \ CLOSE #2
150 !"CONVERSION COMPLETED" \ END