andre
New Member
Posts: 1
|
Post by andre on Jul 16, 2022 14:18:42 GMT -5
Is there a way to use any other delimiter than a comma in sequential files.
I understand that you can use a | (upright bar) in some other languages.
I find difficulties using a comma as delimiter.
In previous versions of BASIC (Turbo BASIC and GWBASIC), I simply put strings in inverted commas and any comma in the text would be ignored.
LINE INPUT does not work for my application.
If you cannot use any other delimiter in Liberty BASIC, I wonder, is it too much to wish for in LB5?
|
|
|
Post by Walt Decker on Jul 16, 2022 14:31:14 GMT -5
Use any delimiter(s) you want, e. g.
Txt$ = "Field 1 || Field 2 <| Sub-Field 1 || Field 3 |> Sub-Field 2 "
Please show how you are using LINE INPUT.
|
|
|
Post by tsh73 on Jul 16, 2022 15:38:25 GMT -5
Really interesting.
single modification needed to run in QBASIC or LB
OPEN "test.txt" FOR OUTPUT AS #1 PRINT #1, "one" 'PRINT #1, "two, three" 'PRINT #1, "'two, three'" 'PRINT #1, "`two, three`" qq$ = CHR$(34) PRINT #1, qq$; "two, three"; qq$ PRINT #1, "four" CLOSE #1
OPEN "test.txt" FOR INPUT AS #1 'WHILE NOT (EOF(1)) 'for QBASIC WHILE NOT (EOF(#1)) 'for LB INPUT #1, a$ i = i + 1 PRINT i, a$ WEND CLOSE #1 PRINT "Over"
'RUN "notepad.exe test.txt" 'obviously this is LB
Then run on QBASIC, I got
1 one 2 two, three 3 four Over Then on LB, I got second line split in two no matter that I tried.
1 one 2 "two 3 three" 4 four Over
Never knew such thing existed on the first place.
Of course probably could be circumvented. Post sample of your data and folks will suggest a way to read it.
|
|
|
Post by tsh73 on Jul 16, 2022 15:43:38 GMT -5
as for other delimiter, there is a function in LB From a help file
(there are more text, have a look)
|
|
|
Post by Rod on Jul 17, 2022 2:31:21 GMT -5
|
|
|
Post by DARKNIGHT on Jul 2, 2023 16:14:27 GMT -5
a way I have found that works for using commas as file delimiters is:
print a$;",";b$;",";c$
this works for print and print # x , but not for input # x
Hope this helps a bit, if you decide to use commas.
Jim
|
|