100 WINDOW 448,192,32,16
110 BORDER 2,4
120 PAPER 7
130 CLS: CLS #0
140 DEFine PROCedure COM(C$)
150  PRINT "*** ";C$
160 END DEFine COM
170 DEFine PROCedure PL
180  PRINT #0;"Press a key"
190  PAUSE
200  CLS #0
210 END DEFine
220 DIM psn(4)
230 psn(1)=0
240 psn(2)=6
250 psn(3)=22
260 psn(4)=32
270 :
280 COM "Export/Import Demonstration."
290 PRINT
300 COM "Start off with TEST_DBS database produced by TEST_BASIC1_BAS."
310 COM "Open TEST_DBS (READ ONLY!!)."
320 :
330 OPEN_DIN #3;TEST_DBS
340 :
350 PRINT: PL
360 COM "Now EXPORT the whole database to TEST_EXP."
370 COM "And dump the results."
380 COM "The resulting file can be IMPORTED to abacus/archive."
390 COM "(Note: The SEXTRA string is put out as line 1, up to the 1st LF)."
400 :
410 EXPORT #3 TO TEST_EXP
420 DEFine PROCedure file_dump(f$)
430  PRINT
440  OPEN_IN #4;"FLP2_"&f$
450  REPeat file_lp
460   IF EOF(#4) THEN EXIT file_lp
470   PRINT INKEY$(#4;-1);
480  END REPeat file_lp
490  CLOSE #4
500  PRINT
510 END DEFine file_dump
520 file_dump "TEST_EXP"
530 :
540 PRINT: PL
550 COM "EXPORT string$ and int_w% fields to TEST2_EXP."
560 COM "(Note: The appropriate field names are exported on line 1)."
570 :
580 EXPORT #3 TO FLP2_TEST2_EXP\"string$"\"int_w%"
590 file_dump "TEST2_EXP"
600 :
610 PRINT: PL
620 COM "EXPORT string$ and int_w% fields to TEST2_EXP with field names."
630 COM '(Note 1: the names are in "", separated by commas, ending in CR LF).'
640 COM "(Note 2: the names do not have to be the same as those in the"
650 COM "          SEXTRA string)."
660 :
670 EXPORT #3 TO FLP2_TEST2_EXP;"STRING$";"wordint"\"string$"\"int_w%"
680 file_dump "TEST2_EXP"
690 :
700 PRINT: PL
710 COM "EXPORT whole file under new field names."
720 COM "(Note: a string field name MUST end in a $)."
730 :
740 EXPORT #3 TO FLP2_TEST2_EXP;"word_i";"characters$";"int_l";"fpnum"
750 file_dump "TEST2_EXP"
760 :
770 PRINT: PL
780 COM "IMPORT TEST_EXP to TEST2_DBS"
790 COM "(Note 1: The first line will be put in the SEXTRA string)."
800 COM "(Note 2: The Numeric fields default to floating point)."
810 COM "(Note 3: The String fields default to VARIABLE, 128 bytes"
820 COM "         length)."
830 :
840 IMPORT flp2_TEST_EXP TO #4;flp2_TEST2_DBS
850 DEFine PROCedure dbase_dump(c)
860  PRINT
870  PRINT "SEXTRA string:"
880  PRINT FEXTRA(#c)\
890  PRINT FLNUM(#c);" fields available:"
900  PRINT "Type:   ";
910  FOR f_lp=1 TO FLNUM(#c):PRINT FLTYP(#c;f_lp) TO f_lp*4+8;
920  PRINT \"Length: ";
930  FOR f_lp=1 TO FLNUM(#c):PRINT FLLEN(#c;f_lp) TO f_lp*4+8;
940  PRINT \\COUNT(#c);" records available:"
950  FOR r_lp=0 TO COUNT(#c)-1
960   RPOSAB #c;r_lp
970   FOR f_lp=1 TO FLNUM(#c)
980    PRINT TO psn(f_lp);FETCH(#c;f_lp);
990   END FOR f_lp
1000   PRINT
1010  END FOR r_lp
1020 END DEFine dbase_dump
1030 dbase_dump #4
1040 CLOSE_DATA #4
1050 :
1060 PRINT: PL
1070 COM "Now EXPORT to TEST2_EXP, 2 of int_w% and 2 of int_l, but"
1080 COM " attach % and @ only to the ends of the 2nd group of field"
1090 COM " names respectively. Then IMPORT the file to TEST2_DBS."
1100 COM "(Note 1: a name ending in % forces 2-byte integer type)."
1110 COM "(Note 2: a name ending in @ forces 4-byte integer type)."
1120 COM "(Note 3: these do NOT apply to ARCHIVE/ABACUS)."
1130 :
1140 EXPORT #3 TO FLP2_TEST2_EXP;"int_w";"int_l";"int_w%";"int_l@"\1\3\1\3
1150 file_dump "TEST2_EXP"
1160 IMPORT FLP2_TEST2_EXP TO #4;flp2_TEST2_DBS
1170 dbase_dump #4
1180 CLOSE_DATA #4
1190 :
1200 PRINT: PL
1210 COM "IMPORT TEST_EXP and force int_w and int_l types,"
1220 COM " and the string to be 20 bytes long."
1230 COM "(Note: the IMPORT job looks at the field ending and if:"
1240 COM "       $: Tries to take a value out of the supplied list"
1250 COM "          for its length, default (2+)128;"
1260 COM "       %: Is always word integer;"
1270 COM "       @: Is always long integer;"
1280 COM "       None: Tries to get type [1/2/3 only] from list,"
1290 COM "             default 3 [floating point])."
1300 :
1310 IMPORT flp2_TEST_EXP TO #4;FLP2_TEST2 \1\16\2
1320 dbase_dump #4
1330 CLOSE_DATA #4
1340 COM "Done."
1350 CLOSE_DATA #3
