Store text with "Carnage Returns" in a text file? - Solved
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
Store text with "Carnage Returns" in a text file? - Solved
How do you Store text with "Carnage Returns" in a text file, when it is one of multiple items?
Thanks,
David
Thanks,
David
Last edited by DR White on Tue Mar 14, 2017 10:13 am, edited 1 time in total.
Re: Store text with "Carnage Returns" in a text file?
Hi David,
I don't have the slightest idea what you are talking about?
Best
Klaus
I don't have the slightest idea what you are talking about?
Best
Klaus
-
- VIP Livecode Opensource Backer
- Posts: 9648
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: Store text with "Carnage Returns" in a text file?
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
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?
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?
Google only pointed me to some "horror clown" musical? WTF?
-
- VIP Livecode Opensource Backer
- Posts: 9648
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: Store text with "Carnage Returns" in a text file?
You do pretty damn well, Klaus.Yep?
Craig
Re: Store text with "Carnage Returns" in a text file?
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
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
-
- VIP Livecode Opensource Backer
- Posts: 9648
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: Store text with "Carnage Returns" in a text file?
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
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?
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
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?
Hi David,
do this:
Turns multi-linetext into single-line text, you get the picture.
Best
Klaus
do this:
Code: Select all
...
put "2545 Wood Drive" & CR & "Roanoke Virginia" & CR & "24400" into tAddress
put urlencode(tAddress) into tVeg3
...
Best
Klaus
-
- VIP Livecode Opensource Backer
- Posts: 9648
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: Store text with "Carnage Returns" in a text file?
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?
Craig
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
-
- VIP Livecode Opensource Backer
- Posts: 9823
- Joined: Sat Apr 08, 2006 7:05 am
- Location: Los Angeles
- Contact:
Re: Store text with "Carnage Returns" in a text file?
You might also consider using an array:
To read:
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)
Code: Select all
put url ("binfile:" & tFile) into tData
put arrayDecode(tData) into tA
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
Re: Store text with "Carnage Returns" in a text file?
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
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