CPCWiki forum

General Category => Programming => Topic started by: zogo on 19:14, 01 April 24

Title: How to include a new line character in a DATA statement
Post by: zogo on 19:14, 01 April 24
Hi,

I'm facing a problem where I have a list of strings in DATAs to be printed in BASIC.
I would like to have a new line character in some of the strings to cope with the screen width, e.g. avoid string splitting in the middle of a word, and make printing of the strings nicer.
Similar to '\n' in C string literals. Is that possible?


Thanks for your support.

Title: Re: How to include a new line character in a DATA statement
Post by: MoteroV4 on 20:30, 01 April 24
Hi,

To print the control characters CR and LF you can include them into a variable and print them with PRINT:

crlf$=CHR$(13)+CHR$(10)

Then you may want to detect in your DATAs the 2 characters "\n" and replace it, or any other character you want to assign the Carriage Return and Line Feed to, or perhaps do it based on the x coordinate of LOCATE.

I hope this helps you.
Title: Re: How to include a new line character in a DATA statement
Post by: McArti0 on 20:50, 01 April 24
copy to text character 10 and 13
Title: Re: How to include a new line character in a DATA statement
Post by: The Electric Monk on 20:59, 01 April 24
EDIT: Never mind. The other ideas are a lot simpler and better.
Title: Re: How to include a new line character in a DATA statement
Post by: The Electric Monk on 20:59, 01 April 24
Quote from: McArti0 on 20:50, 01 April 24copy to text character 10 and 13
On second thought, this may be the easiest way.
Title: Re: How to include a new line character in a DATA statement
Post by: zogo on 09:51, 06 April 24
Thanks guys, I ended up implementing the replacement of '\n' by chr$(10)+chr$(13)
https://gitlab.com/jferreira/cpc-basic-saga
Powered by SMFPacks Menu Editor Mod