GLBasic forum

Main forum => Bug Reports => Topic started by: Minion on 2012-Feb-06

Title: Problem with CONSTANT
Post by: Minion on 2012-Feb-06
Not sure if this is a bug or not, can anyone else confirm this for me ?

when using constant I get funny results.

I defined the following ....

CONSTANT CR$ = CHR$(13)

But whenever I use it in a string value, it returns the path for the EXE file i`m running :(

Using " "+CHR$(13) returns some very weird characters indeed :(

But if I use just " " it works fine.

Am I missing something here, or doing something wrong ? Or can I not set a constant to CHR$(13) ?
Title: Re: Problem with CONSTANT
Post by: kanonet on 2012-Feb-06
I can confirm your problem and i know what it is:
You cant assign a function to a constant (cuz it may change in some situations), it need to be a constant expression. But here is your solution:
CHR$(13) = "\r"
CHR$(10) = "\n"

So just make it
COSTANT CR$ = "\r"
and it should work fine. ;)
Title: Re: Problem with CONSTANT
Post by: Minion on 2012-Feb-06
Spelndid stuff :) TY Kanonet. 30 years in the biz and I`m still learning new stuff daily :)
Title: Re: Problem with CONSTANT
Post by: kanonet on 2012-Feb-06
Btw its called escape sequence, you can find a list here:
http://de.wikipedia.org/wiki/Escape-Sequenz
(german but you will find a english list somewhere in the internet too^^)