GLBasic forum

Main forum => GLBasic - en => Topic started by: Bursar on 2010-Oct-06

Title: Problem storing backslash in a string.
Post by: Bursar on 2010-Oct-06
In my code I have:
Code (glbasic) Select
gkeyDesc$[86] = "\\"
It causes my app to close down as soon as it gets to that line. If I comment out that line, it works fine.
The same happens if I use "\"" to try and get a quote symbol into a string.

Using a single \ I get a syntax error when trying to compile. Am I making another school boy error?
Title: Re: Problem storing backslash in a string.
Post by: MrTAToad on 2010-Oct-06
Sure that the array is large enough to hold at least 86 indicies ?  That line should present no problem...
Title: Re: Problem storing backslash in a string.
Post by: monono on 2010-Oct-06
No MrTAToud, he is right. It doesn´t work.
But Bursar, you culd go the ASCII way.

CHR$(92)+CHR$(92) is the same as "\\"
Title: Re: Problem storing backslash in a string.
Post by: MrTAToad on 2010-Oct-06
Works fine here - hence the query about the array size...
Title: Re: Problem storing backslash in a string.
Post by: ampos on 2010-Oct-06
try a$="\"+"\"
Title: Re: Problem storing backslash in a string.
Post by: Kitty Hello on 2010-Oct-06
"\" is a bug. You must escape the escape character. If you want "\" ou must type "\\", which is a bug, thus you mmust use char$(92) (only one!)
Title: Re: Problem storing backslash in a string.
Post by: Bursar on 2010-Oct-06
Yes, the array is big enough, it's been sized for 256 entries, and entries after that one are fine.

I've just deleted the line and retyped it, and now it's working. I wonder if maybe some odd invisible characters had got stuck onto the line, as it was part of a copy and paste operation. Before that, none of the suggestions were working either, and when I replaced "//" with "a", that also caused my game to exit out immediately. Very odd.

Anyway, problem solved for the time being :)
Title: Re: Problem storing backslash in a string.
Post by: MrTAToad on 2010-Oct-06
I think that sort of thing happened to someone a fair while ago...
Title: Re: Problem storing backslash in a string.
Post by: Ian Price on 2010-Oct-07
QuoteI think that sort of thing happened to someone a fair while ago...
That was me a couple of months back - I had some characters in my text that appeared to be correct, but GLBasic didn't like them - and it was virtually impossible to tell they were different unless you copied them into another file (as in this forum) then back again. Removing them (and replacing) sorted the problem.