home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
RBBS in a Box Volume 1 #2
/
RBBS_vol1_no2.iso
/
002z
/
wswpdata.bas
< prev
next >
Wrap
BASIC Source File
|
1988-06-13
|
4KB
|
74 lines
100 PRINT " WSWPDATA.bas Test Version 0.9 (c) 1988 Bob Gallie 312-863-8591
105 ' 880402 draft. Seems to work well. Easier dis-
110 ' tribution & reading chosen over speed.
115 PRINT ' Permission may be presumed for NONCOMMERCIAL uses of this program. .
120 PRINT " This is a program to use a data file of one of these types
125 PRINT " to create a data file of the other type:
130 PRINT "
135 PRINT " - COMMA-DELIMITED CHARACTER DATA
140 PRINT " - WORD PERFECT MERGE DATA.
145 PRINT
150 PRINT " COMMA-DELIMITED CHARACTER DATA files are the kind that:
155 PRINT " - are used by WordStar as MailMerge data;
160 PRINT " - have character fields separated with commas, and may have
165 PRINT " quotation marks surrounding some or all fields,
170 PRINT " - have a carriage return + linefeed after each record
175 PRINT " except the last record;
180 PRINT " - are created when BASIC does WRITE# with string data;
185 PRINT " - dBASE creates with .COPY TO XXX.TXT delimited with "+CHR$(34)
190 PRINT
195 PRINT " WORD PERFECT MERGE DATA files are the kind that:
200 PRINT " - Word Perfect creates for data to merge with documents;
205 PRINT " - have ASCII 005 + ASCII 010 after each record;
210 PRINT " - have ASCII 018 + ASCII 010 after each field except those
215 PRINT " fields which conclude records.
220 ON ERROR GOTO 0:BEEP
225 PRINT "
230 SOURCE.ALA.WS%=-1
235 PRINT "IS THE SOURCE FILE Comma-delimited OR Word Perfect (C or W) ?"
240 X$=INPUT$(1)
245 X%=INSTR("cCwW",X$)
250 IF X%=0 THEN GOTO 235 ELSE IF X%>2 THEN SOURCE.ALA.WS%=0
255 INPUT"Enter the full precise name of the source file: ";X$
260 OPEN X$ FOR INPUT AS #1:CLOSE ' for error if source doesn't exist.
265 OPEN X$ AS #1 LEN=1: FIELD #1, 1 AS I$
270 INPUT"Name a file for the output: ";OUTPUTFILE$
275 OPEN OUTPUTFILE$ AS #2 LEN=1:FIELD #2, 1 AS O$
280 I!=1:LOF1!=LOF(1):NEWRECORD%=-1
285 PRINT "Per cent processed: 0 ... ";
290 IF SOURCE.ALA.WS% THEN GOSUB 335 ELSE GOSUB 405
295 CLOSE:BEEP
300 PRINT:PRINT "Finished. The files are closed.":BEEP
305 PRINT "The output file was ---> ";OUTPUTFILE$
310 'print:SHELL "copy/b "+OUTPUTFILE$+" con" '<-- debugging line...
315 PRINT
320 PRINT "Enter RUN for another run. SYSTEM for return to DOS. ...":PRINT
325 END '=============
330 '
335 'wstowp: 'subroutine ====
340 COPYINGASTRING%=0
345 WHILE I! < LOF1!
350 GET #1:I!=I!+1
355 IF I$=CHR$(13) THEN NEWRECORD%=-1:LSET O$=CHR$(5):PUT #2:LSET O$=CHR$(10):PUT #2:PRINT USING " ### ...";I!/LOF1!*100;:QUOTESFLAG%=0: GOTO 395
360 IF I$=CHR$(10) THEN IF NEWRECORD%=-1 THEN GOTO 395 '...
365 NEWRECORD%=0
370 IF I$=CHR$(34) THEN QUOTESFLAG%=NOT QUOTESFLAG%:GOTO 395
375 IF I$=" "AND QUOTESFLAG%=0 AND COPYINGASTRING%=0 THEN GOTO 395
380 COPYINGASTRING%=-1
385 IF I$=","AND QUOTESFLAG%=0 THEN COPYINGASTRING%=0:LSET O$=CHR$(18):PUT #2:LSET O$=CHR$(10):PUT #2:GOTO 395
390 LSET O$=I$:PUT #2
395 WEND
400 RETURN
405 'wptows: 'subroutine ===
410 WHILE I! < LOF1!
415 IF NEWRECORD%=-1 THEN LSET O$=CHR$(34):PUT #2:NEWRECORD%=0
420 GET #1:I!=I!+1
425 IF I$=CHR$(5) THEN LSET O$=CHR$(34):PUT #2:LSET O$=CHR$(13):PUT #2:LSET O$=CHR$(10):PUT #2:PRINT USING " ### ...";I!/LOF1!*100;:GET #1:I!=I!+1:NEWRECORD%=-1:GOTO 440
430 IF I$=CHR$(18) THEN LSET O$=CHR$(34):PUT #2:LSET O$=",":PUT #2:LSET O$=CHR$(34):PUT #2:GET #1:I!=I!+1:GOTO 440
435 LSET O$=I$:PUT #2
440 WEND
445 LSET O$=CHR$(26):PUT #2 'EOF mark
450 RETURN
455 'end of listing