underscore in stringnames

new BookmarkLockedFalling
votan
Senior Member
****

votan Avatar

Posts: 304

Post by votan on Aug 8, 2008 11:47:57 GMT -5

Just wondering, why using the underscore in stringnames results in a sysntax error!?
Like "mystring$" is ok, while "my_string$" returns a syntax error. Didn't know that the underscore is treated in a special way that it causes these problems.... So not sure if this actually is a bug or if it is supposed to be this way!?
Janet
Global Moderator
*****

Janet Avatar

Posts: 276

Post by Janet on Aug 8, 2008 12:22:47 GMT -5

In Liberty BASIC, the use of an underscore with a variable is reserved for Windows constants. A simple windows constant is VK_ESCAPE which holds the ascii value for the tab key (27). Liberty BASIC expects the Windows constant to be preceded with an underscore as well, so that the output of

Print _VK_ESCAPE

would be

27

Run BASIC doesn't appear to have any Windows constants built in. Print _VK_ESCAPE results in a Compile Error, but it may be that RB follows the same rules as LB: underscores aren't allowed as part of user defined variables. Perhaps you could use a modification?

myString$
MyString$
my.string$
[br]
Carl Gundel - admin
Administrator
*****

Carl Gundel - admin Avatar

Posts: 550

Post by Carl Gundel - admin on Aug 9, 2008 10:45:59 GMT -5

votan Avatar
Just wondering, why using the underscore in stringnames results in a sysntax error!?
Like "mystring$" is ok, while "my_string$" returns a syntax error. Didn't know that the underscore is treated in a special way that it causes these problems.... So not sure if this actually is a bug or if it is supposed to be this way!?

Underscores are not valid in Run BASIC variable names. This is not a bug in the compiler.

-Carl
StefanPendl
Global Moderator
*****

StefanPendl Avatar

Run for BASIC ...
Posts: 945

[b]Stefan[/b] - [a href=http://stefanpendl.runbasichosting.com/]Homepage[/a][br][br][b]Please give credit if you use code I post, no need to ask for permission.[/b][br][br]Run BASIC 1.01, Fire-/Waterfox (IE11, Edge), Windows 10 Professional x64, Intel Core i7-4710MQ 2.5GHz, 16GB RAM
Carl Gundel - admin
Administrator
*****

Carl Gundel - admin Avatar

Posts: 550