Page 1 of 1
Store text with "Carnage Returns" in a text file? - Solved
Posted: Sun Mar 12, 2017 8:39 pm
by DR White
How do you Store text with "Carnage Returns" in a text file, when it is one of multiple items?
Thanks,
David
Re: Store text with "Carnage Returns" in a text file?
Posted: Sun Mar 12, 2017 9:59 pm
by Klaus
Hi David,
I don't have the slightest idea what you are talking about?
Best
Klaus
Re: Store text with "Carnage Returns" in a text file?
Posted: Sun Mar 12, 2017 11:32 pm
by dunbarx
Hi.
Carnage returns are very unstable; be careful how you use them.
Carriage returns (ASCII 10) though, are pretty straightforward, and require no special handing.
Craig Newman
Re: Store text with "Carnage Returns" in a text file?
Posted: Sun Mar 12, 2017 11:39 pm
by Klaus
Oh, yep, makes sense, as a non-native speaker I thought I was missing something.
Google only pointed me to some "horror clown" musical? WTF?

Re: Store text with "Carnage Returns" in a text file?
Posted: Mon Mar 13, 2017 2:19 am
by dunbarx
Yep?
You do pretty damn well, Klaus.
Craig
Re: Store text with "Carnage Returns" in a text file?
Posted: Mon Mar 13, 2017 11:09 am
by DR White
Yes, I did not describe my issue very well...
I am putting "Potatoes" into tVeg1
I am putting "Corn" into tVeg2
I am putting "Beans" & cr & "Tomatoes" & cr "Spinach" into tVeg3
I put tVeg1 & tVeg2 & tVeg2 into tSave
--- Saving Data
put tSave into url("file:" & tFile)
---- Retrieve data------
if there is a file tFile then
put url("file:" & tFile) into SetupData
end if
When I get the items one line at a time from SetupData, instead of item 3 of tLine having "Beans" & cr & "Tomatoes" & cr "Spinach", it has just has one item "Beans" and my next tLine of SetupData has just "Tomatoes" instead of three items.
How do I get all 3 things together of item 3 to put them into the same string?
Thanks,
David
Re: Store text with "Carnage Returns" in a text file?
Posted: Mon Mar 13, 2017 3:13 pm
by dunbarx
Hi.
You are getting back exactly what you put in.
You are missing returns. Step through the portion of your handler that builds the variables. Try adding returns after the lines that load "tVeg1", etc.
Also, when you ask for "items", is that what you meant? Because you might want to ask for "lines". Returns are line delimiters, not item delimiters, unless you make them so.
Craig
Re: Store text with "Carnage Returns" in a text file?
Posted: Mon Mar 13, 2017 11:05 pm
by DR White
The problem is that I want to save a contact list which includes carriage returns as below:
Name:
John Doe
Phone Number:
1 555 333 4444
Address:
2545 Wood Drive
Roanoke Virginia
24400
How can I save this in a text file?
Thanks
David
Re: Store text with "Carnage Returns" in a text file?
Posted: Mon Mar 13, 2017 11:24 pm
by Klaus
Hi David,
do this:
Code: Select all
...
put "2545 Wood Drive" & CR & "Roanoke Virginia" & CR & "24400" into tAddress
put urlencode(tAddress) into tVeg3
...
Turns multi-linetext into single-line text, you get the picture.
Best
Klaus
Re: Store text with "Carnage Returns" in a text file?
Posted: Tue Mar 14, 2017 12:09 am
by dunbarx
Hmmm.
Are you sure you are comfortable with applying returns to text in general? All the suggestions here have assumed so. Does this make sense to you?
Code: Select all
put "can be applied" into temp
put return & "in different ways?" after temp
put "See how returns" & return before temp
Craig
Re: Store text with "Carnage Returns" in a text file?
Posted: Tue Mar 14, 2017 12:46 am
by FourthWorld
You might also consider using an array:
Code: Select all
put "Potatoes" into tA[1]
put "Corn" into tA[2]
pit "Beans"&cr& "Tomatoes" &cr& "Spinach" into tA[3]
put arrayEncode(tA) into url ("binfile:"& tFile)
To read:
Code: Select all
put url ("binfile:" & tFile) into tData
put arrayDecode(tData) into tA
Re: Store text with "Carnage Returns" in a text file?
Posted: Tue Mar 14, 2017 10:10 am
by DR White
Klaus, Craig and Richard are Awesome.
Thanks so much for your help and the other great supporters of this forum over the years.
On this task of capturing user entered Returns, I believe that using the url ("binfile:" & tFile) works best for my application.
I strongly recommend LiveCode to everyone and use of this forum
LC is such an incredible programming language with an extremely vast instruction set and so many ways of doing things.
Thanks again to everyone at the LC forum, I could not develop good apps (6 in Google Play Store with 2 that have had 50,000 downloads and 2 in the Apple Store - all my apps are free),
David