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?
Line breaks in DATA statements?
-
- Coder
- Posts: 45
- Joined: Sun Nov 26, 2006 2:00 pm
- Location: Champaign, Illinois
-
- Veteran
- Posts: 288
- Joined: Sat Feb 18, 2006 4:02 pm
Right, you can't use chr$ inside a DATA statement.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?
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$
I tested it and it works.
Good luck.
Regards..... Moneo
-
- Coder
- Posts: 45
- Joined: Sun Nov 26, 2006 2:00 pm
- Location: Champaign, Illinois
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!
Padding the words out with spaces works but it's rather clunky, plus you need to count the exact number of spaces needed.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!
Use the dummy character technique.
P.S.: "Seabiscuit" --- are you a horse racing fan?
Regards..... Moneo
-
- Coder
- Posts: 45
- Joined: Sun Nov 26, 2006 2:00 pm
- Location: Champaign, Illinois
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.seaBiscuit$ wrote:You must have me confused with another Seabiscuit.moneo wrote:P.S.: "Seabiscuit" --- are you a horse racing fan?
Alright, I'll use the dummy characters.
Thought you knew this.
P.S.: Glad you're using the dummy characters technique.
Regards..... Moneo
-
- Coder
- Posts: 45
- Joined: Sun Nov 26, 2006 2:00 pm
- Location: Champaign, Illinois
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.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.