October 30, 2025, 11:48:41 AM

News:

IWBasic runs in Windows 11!


String assign not supported in latest Alpha 3?

Started by Rock Ridge Farm (Larry), May 22, 2006, 05:26:18 AM

Previous topic - Next topic

0 Members and 2 Guests are viewing this topic.

Rock Ridge Farm (Larry)

string Created = "Created 2/06/2006";
Gives me the error:
    String: Initializer not supported


Rock Ridge Farm (Larry)

Never mind - deleleted old installation and re-installed - now working.
Shoud a delete old instalation option be added to the install script to keep
idiots like me from constantly dorking this up?

Rock Ridge Farm (Larry)

OK - now I am really confused - problem is back????????

Rock Ridge Farm (Larry)

If I compile single - I have the problem.
If I compile as a project - I do not have the problem.
?????

Rock Ridge Farm (Larry)

The project was pointing to an old source.
The problem is still here - I am having problems with what appear to be external string assigns.
I suspect I am violating some new rule.
???

Parker

You can't actually assign to a string globally yet, it says so in the update announcement (did you read the whole thing? ;) )

The reason is, if you emit the string "Hello", you expect that you'll be able to assign something like "The butter is in the refridgerator" to that string. But it actually only has the length of "Hello" plus the null. To resolve it, you would emit assembly code that looks like this:
theString db "Hello"
    times 255-string_len db 0

where "255-string_len" would be calculated by the compiler. The "times" instruction tells NASM to emit whatever follows it a certain number of times. But that isn't supported yet.

Ionic Wind Support Team

And it never worked either.  A global variable and an assignment was just ignored before.

string s = "hello";  //ignored in Rev2, proper error message in Rev3

global sub main()
{
string s2 = "hello";  //always worked.
...
}

And parker is pretty much correct, except I did have it working that way but the string would end up in both the data/bss segments because of the way the parser is handling string constants.  It wasn't a 'quickie' addition and requires a bit of rewrite so I left it with the error message for now.
Ionic Wind Support Team

Rock Ridge Farm (Larry)

Kool - Just creating error conditions before they are recoginized.

Ionic Wind Support Team

However the compiler does support constant strings now.

#define CREATED_LINE  "Created 2/06/2006";

Stick that in an include file and anytime you want to flash up the created date you can refer to it as any other string.
Ionic Wind Support Team