www.retrosoftware.co.uk
http://www.retrosoftware.co.uk/forum/

How do I define a String Variable?
http://www.retrosoftware.co.uk/forum/viewtopic.php?f=17&t=300
Page 1 of 1

Author:  RetroClinic [ Sat Jul 11, 2009 12:20 pm ]
Post subject:  How do I define a String Variable?

Hi folks.

Okay

ver = 3

is fine, but

ver$ = "3.00"

is not. How do I define a string variable? I can't seem to find an answer on the BeebASM pages.

Thanks, Mark.

Author:  RichTW [ Sun Jul 12, 2009 12:33 am ]
Post subject:  Re: How do I define a String Variable?

You can't, I'm afraid. String variables aren't supported by BeebAsm, mainly because I couldn't ever imagine why they would be useful.

What is it you'd like to do? Perhaps there's another way to achieve it (e.g. using IF...ENDIF or something).

Author:  RetroClinic [ Wed Jul 29, 2009 1:12 am ]
Post subject:  Re: How do I define a String Variable?

Hi.

(Sorry for late reply, I don't seem to be getting topic notifications)

It was simply for Version numbers and dates:

ver$ = "1.00"
date$ = "28 Jul 2009" or even better to be able to set it to the current date of the PC, so that it automatically assembles with the correct date.

So at the beginning of a ROM, I would have

EQUS ver$
EQUB &00
EQUS "("
EQUS date$
EQUS ")"

and later on in the help system, use ver$ again. Just so where the version appears in several places, I only have to keep track of one string.

Mark.

Author:  RichTW [ Wed Jul 29, 2009 7:14 am ]
Post subject:  Re: How do I define a String Variable?

Oh I understand! I never expected BeebAsm to be used for serious apps like ROMs :D

I'll have a think about whether I can implement string variables easily (they're a whole different beast to a numeric variable and have very limited use in BeebAsm).

Perhaps a better solution would now be to implement a kind of basic macro system, even something akin to #define in C/C++, which does a fairly simple substitution. I'll see if I can find time to play with this idea sometime soon.

Author:  RichTW [ Wed Jul 29, 2009 7:17 am ]
Post subject:  Re: How do I define a String Variable?

Another thought for now (a hacky one at that) is to try running the source file first through the C preprocessor (cpp.exe) in GCC, and then you could use #define to implement this. The only potential problem is, because BeebAsm source files don't have C-like syntax, it might not process it properly. Maybe worth a try though...

Author:  PhillHS [ Tue Sep 15, 2009 1:48 pm ]
Post subject:  Re: How do I define a String Variable?

RetroClinic wrote:
Hi.

(Sorry for late reply, I don't seem to be getting topic notifications)

It was simply for Version numbers and dates:

ver$ = "1.00"
date$ = "28 Jul 2009" or even better to be able to set it to the current date of the PC, so that it automatically assembles with the correct date.

So at the beginning of a ROM, I would have

EQUS ver$
EQUB &00
EQUS "("
EQUS date$
EQUS ")"


What I did for dates was to write a little external program that spits out the date in the apropreate format for my assembler, add a command to run that to my Makefile, and include the output.

I could let you have a copy of that if youi want.

Cheers.

Phill.

Page 1 of 1 All times are UTC [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/