News:

Printed Amstrad Addict magazine announced, check it out here!

Main Menu
avatar_zogo

How to include a new line character in a DATA statement

Started by zogo, 19:14, 01 April 24

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

zogo

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.


MoteroV4

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.
Released cpc games: Memtrainer, El Gerente (Remake)

McArti0

copy to text character 10 and 13
CPC 6128, Whole 6128 and Only 6128, with .....
NewPAL v3 for use all 128kB RAM by CRTC as VRAM
TYPICAL :) TV Funai 22FL532/10 with VGA-RGB-in.

The Electric Monk

#3
EDIT: Never mind. The other ideas are a lot simpler and better.

The Electric Monk

Quote from: McArti0 on 20:50, 01 April 24copy to text character 10 and 13
On second thought, this may be the easiest way.

zogo

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