Author Topic: Problem storing backslash in a string.  (Read 2426 times)

Offline Bursar

  • Mr. Drawsprite
  • **
  • Posts: 63
    • View Profile
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?

MrTAToad

  • Guest
Re: Problem storing backslash in a string.
« Reply #1 on: 2010-Oct-06 »
Sure that the array is large enough to hold at least 86 indicies ?  That line should present no problem...

Offline monono

  • Mr. Polyvector
  • ***
  • Posts: 213
    • View Profile
    • Sockel Lernmedien
Re: Problem storing backslash in a string.
« Reply #2 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 "\\"

MrTAToad

  • Guest
Re: Problem storing backslash in a string.
« Reply #3 on: 2010-Oct-06 »
Works fine here - hence the query about the array size...

Offline ampos

  • Prof. Inline
  • *****
  • Posts: 1600
    • View Profile
    • AMpostata Website
Re: Problem storing backslash in a string.
« Reply #4 on: 2010-Oct-06 »
try a$="\"+"\"
check my web and/or my blog :D
http://diniplay.blogspot.com (devblog)
http://www.ampostata.org
http://ampostata.blogspot.com
I own PC-Win, MacBook 13", iPhone 3G/3GS/4G and iPAC-WinCE

Offline Kitty Hello

  • code monkey
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 10851
  • here on my island the sea says 'hello'
    • View Profile
    • http://www.glbasic.com
Re: Problem storing backslash in a string.
« Reply #5 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!)

Offline Bursar

  • Mr. Drawsprite
  • **
  • Posts: 63
    • View Profile
Re: Problem storing backslash in a string.
« Reply #6 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 :)

MrTAToad

  • Guest
Re: Problem storing backslash in a string.
« Reply #7 on: 2010-Oct-06 »
I think that sort of thing happened to someone a fair while ago...

Offline Ian Price

  • Administrator
  • Prof. Inline
  • *******
  • Posts: 4176
  • On the shoulders of giants.
    • View Profile
    • My Apps
Re: Problem storing backslash in a string.
« Reply #8 on: 2010-Oct-07 »
Quote
I 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.
I came. I saw. I played.