Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 16:53 29 Nov 2024 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : Non-printable and Delimiters in MMBasic string / DATA statement

Author Message
Mark
Regular Member

Joined: 26/11/2022
Location: United States
Posts: 45
Posted: 01:53pm 08 Mar 2023
Copy link to clipboard 
Print this post

Is the only way to include non-printable characters, such as TAB and the QUOTE delimiter in a MMBasic string constant with CHR$() and concatenation?

CONST S$ = CHR$(9) + "Preceded by TAB and followed by Quote." + CHR$(34)


It appears that the + concatenation doesn't work in DATA statements. Only the part up to the first + is READ.

Thanks,
Mark
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 4047
Posted: 02:39pm 08 Mar 2023
Copy link to clipboard 
Print this post

Hi Mark,

If memory serves correctly then this is a known limitation; the syntax of DATA is a bit "iffy" and doesn't evaluate string expressions, something about a need to support unquoted strings in DATA statements for backward compatibility with earlier BASIC dialects.

What I have done previously is use some combination of printable characters in the DATA and then process the strings as I read them out of the DATA section to replace with the desired non-printable characters.

Best wishes,

Tom
Edited 2023-03-09 00:41 by thwill
Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 6814
Posted: 02:41pm 08 Mar 2023
Copy link to clipboard 
Print this post

That's correct. You can't have a non-printable character on screen because it's non-printable. :)  (This is actually a lie. You can PRINT CHR$(240) for example.)

Your example works ok for me.

PicoMiteVGA MMBasic Version 5.07.07b20

> CONST S$ = CHR$(9) + "Preceded by TAB and followed by Quote." + CHR$(34)
> ? s$
       Preceded by TAB and followed by Quote."


You can also do silly stuff like:

> a$=" an experiment "
> poke var a$,1,9
> poke var a$,15,34
> ? a$
       an experiment"
>



DATA statements are a different thing.
They store:
- unquoted text under certain conditions.
- quoted text.
- numeric values.
- numeric expressions.

They don't store string expressions.
Edited 2023-03-09 00:51 by Mixtel90
Mick

Zilog Inside! nascom.info for Nascom & Gemini
Preliminary MMBasic docs & my PCB designs
 
CaptainBoing

Guru

Joined: 07/09/2016
Location: United Kingdom
Posts: 2080
Posted: 03:08pm 08 Mar 2023
Copy link to clipboard 
Print this post

DATA statements can be made dynamic with the use of a variable.

try the following

Dim Integer aa=222,n,x

Data 1,aa,3

for n=1 to 3:read x:Print x:next


Very nice.

Unfortunately, this is confined to numeric varables:


Dim Integer aa=222,n
Dim s$="fred",x$

Data "!",s$,"3"

for n=1 to 3:read x$:Print x$:next


treats the data s$ as the literal characters s and $

As an aside, String CONSTants don't need to be explicitly typed e.g. when DIMing variables, the explicit type can be omitted if basic sees the type coming so

Dim String s="fred"

is fine, but

Dim s="fred" throws an error

counter-intuitively,

Const e=Chr$(27)+"["

is fine and e is used as a string of characters with no explicit type (i.e. e$)
Edited 2023-03-09 01:13 by CaptainBoing
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 6814
Posted: 03:11pm 08 Mar 2023
Copy link to clipboard 
Print this post

That'd the nice thing about standards. There are so many to choose from. :)
Mick

Zilog Inside! nascom.info for Nascom & Gemini
Preliminary MMBasic docs & my PCB designs
 
Print this page


To reply to this topic, you need to log in.

© JAQ Software 2024