Page 1 of 1

Line breaks in DATA statements?

Posted: Tue Dec 12, 2006 9:54 pm
by seaBiscuit$
How can I put strings with line breaks in DATA statements? I could do something like this and PRINT it or store it in a variable:

"Hello," + chr$(13) + "World!"

but I can't use chr$ inside DATA statements. Is there any way I can put a string in a DATA statement with line breaks in it?

Posted: Wed Dec 13, 2006 2:34 pm
by bungytheworm
To be honest, i dont know any simple way to do that. Well, "simple" is pretty personal thing but as far as i know, there aint no quick trick to do that.

I would like to hear more what you are up with, maybe we can figure out some solution for this.

Posted: Wed Dec 13, 2006 6:20 pm
by moneo
seaBiscuit$ wrote:How can I put strings with line breaks in DATA statements? I could do something like this and PRINT it or store it in a variable:

"Hello," + chr$(13) + "World!"

but I can't use chr$ inside DATA statements. Is there any way I can put a string in a DATA statement with line breaks in it?
Right, you can't use chr$ inside a DATA statement.
However, you could use a seldom used DUMMY character, like a backslash (\) in the DATA statement, like:
DATA "Hello,\World!"

As you do the READ of the DATA statements, replace backslashes with a chr$(13) right after every READ, like:

Code: Select all

READ A$
for x=1 to len(A$) 
     if mid$(A$,x,1)="" then mid$(A$,x,1)=chr$(13)
next x
print A$
If your data has backslahes, which I doubt, then pick another dummy character, like & or ^ or |.

I tested it and it works.
Good luck.
Regards..... Moneo

Posted: Wed Dec 13, 2006 6:31 pm
by seaBiscuit$
I found a way to add line breaks. (sort of) If I want it to break after a certain word, I can just put spaces after it until it wraps the text on its own. That's a good idea to use dummy characters too! I could use that for other special characters, or if I get sick of putting lots of spaces in. Thanks! :D

Posted: Wed Dec 13, 2006 7:06 pm
by moneo
seaBiscuit$ wrote:I found a way to add line breaks. (sort of) If I want it to break after a certain word, I can just put spaces after it until it wraps the text on its own. That's a good idea to use dummy characters too! I could use that for other special characters, or if I get sick of putting lots of spaces in. Thanks! :D
Padding the words out with spaces works but it's rather clunky, plus you need to count the exact number of spaces needed.

Use the dummy character technique.

P.S.: "Seabiscuit" --- are you a horse racing fan?

Regards..... Moneo

Posted: Wed Dec 13, 2006 8:09 pm
by seaBiscuit$
moneo wrote:P.S.: "Seabiscuit" --- are you a horse racing fan?
You must have me confused with another Seabiscuit. :P
Alright, I'll use the dummy characters.

Posted: Wed Dec 13, 2006 9:25 pm
by moneo
seaBiscuit$ wrote:
moneo wrote:P.S.: "Seabiscuit" --- are you a horse racing fan?
You must have me confused with another Seabiscuit. :P
Alright, I'll use the dummy characters.
No, what I meant was that Seabiscuit was a famous race horse in the 1930's and 1940's. Books were written about him, and several motion pictures were made. He was one of the greatest race horses in America.

Thought you knew this.

P.S.: Glad you're using the dummy characters technique.

Regards..... Moneo

Posted: Wed Dec 13, 2006 10:18 pm
by seaBiscuit$
moneo wrote:No, what I meant was that Seabiscuit was a famous race horse in the 1930's and 1940's. Books were written about him, and several motion pictures were made. He was one of the greatest race horses in America.

Thought you knew this.
That's what I meant. I guess I should have made that clearer. I just thought Seabiscuit would be a cool name, though I haven't seen the movie yet.