pjh21
New Member
Posts: 5
|
Post by pjh21 on Sept 28, 2018 12:34:58 GMT -5
I apologize for being so green...
I want to write fields to a sequential file with each field delimited with a comma (so that it can be opened with a spreadsheet program).
It's been 20 years since I wrote a similar program in QBasic. Right now, I have a subroutine to add a comma after each print statement.
Also, do the fields have to be a string in order to be written to a sequential file? Here is the code I have so far..
======================================= TeamFile$="Data\"+Year$+Division$+".tea"
open TeamFile$ for output as #10
PRINT #10, TName$;
GOSUB [COMMA]
PRINT #10, Year$;
GOSUB [COMMA]
PRINT #10, Division$;
GOSUB [COMMA]
PRINT #10, "0";
GOSUB [COMMA]
print #10, "0";
GOSUB [COMMA]
print #10, "0"
close #10
END
[COMMA]
PRINT #10, ",";
RETURN
===================
Is there a way to write multiple fields with a single print statement, something like: PRINT #10,TName$,Year$,Division$,0,0,0
Thanks for any help!
PJH
|
|
|
Post by alincon on Sept 28, 2018 13:48:56 GMT -5
Does this help?
FILEDIALOG "Save Diary Files", "dat", fileName$ open fileName$ for output as #diary for n = 1 to t for m = 1 to 5 print #diary, trans$(n,m); "|"; next m print #diary, trans$(n,6) next n notice "Written "; str$(t) close #diary
The "|" allows you to keep the data fields separate.
|
|
pjh21
New Member
Posts: 5
|
Post by pjh21 on Sept 28, 2018 16:11:01 GMT -5
Do you use the Pipe sign so that commmas could be included in the fields? I think that may work if I change the Excel macro to accept the pipe sign as a delimiter.
Thanks!
PJH
|
|
pjh21
New Member
Posts: 5
|
Post by pjh21 on Sept 28, 2018 16:13:59 GMT -5
alincon,
I changed my code and your suggestion is much easier AND much more elegant. Thanks!
PJH
|
|