This works
tmp$ = OUTPUTDIR$ + regplate$ + files$[i] + "\n"
This doesn't
tmp$ = OUTPUTDIR$ + regplate$ + "\" + files$[i] + "\n"
????? :rant: ?????
Works
regplate$ = regplate$ + "."
Doesn't Work
regplate$ = regplate$ + "\"
This is sooooo foolish ????
I think its due to the \ being part of a control sequence. if you use \\ it should insert a single \ into the string
Its still foolish though, I used CHR$(92) in the end.
Why foolish? This is the way in many programming languages.
\ = start of escape sequence.
\n means new line
\r means carriage return.
\\ is replaced with a single \
I would miss this function badly if it didn't exist. Having to type CHR$(10) + CHR$(13) instead of "\r\n" to print a new line to the console for example.
The foolish part is windows using \ as a path separator. :-) I believe you should be using / in GLBasic, no matter what you are programming for.
Quote from: Moru on 2012-Sep-10
The foolish part is windows using \ as a path separator. :-) I believe you should be using / in GLBasic, no matter what you are programming for.
Yup ...found that part out too when trying cross platform stuff. I couldn`t work out why my some of my sounds wouldnt load on other devices... Was me being an idiot and using \ instead of / ! took me a week to find that after trying to resample all my sounds at different bitrates and formats. I dont make that mistake now tho ;)
If you are using "\" as a path separator, you should use "/" instead.
Whilst it would be nice if the compiler automatically made sure that "\\" was used, it would cause problems inline as you might need to use "\" with escape codes...
Quote from: Moru on 2012-Sep-10
Why foolish? This is the way in many programming languages.
\ = start of escape sequence.
\n means new line
\r means carriage return.
\\ is replaced with a single \
I would miss this function badly if it didn't exist. Having to type CHR$(10) + CHR$(13) instead of "\r\n" to print a new line to the console for example.
The foolish part is windows using \ as a path separator. :-) I believe you should be using / in GLBasic, no matter what you are programming for.
It's foolish because when the language is being parsed prior to compiling, the fact that I get a syntax error because I'm joining a string which is defined as a STRING hence the quotes "\" should not give errors. It should know that its a string and not give an error, how can that NOT be foolish. I love GLB but don't be so rose tinted, this is a stupid error.
<3
"\" isn't a string. That's why you get errors.
It's like typing:
a$ = "string here but no end string symbol.
because the \ uses the next character as a control character. Compiler does not know what you want.
I will just ignore your personal remarks since this is such a nice community :-)
What personal remarks
Quote from: spicypixel on 2012-Sep-10
It's foolish because when the language is being parsed prior to compiling, the fact that I get a syntax error because I'm joining a string which is defined as a STRING hence the quotes "\" should not give errors. It should know that its a string and not give an error, how can that NOT be foolish. I love GLB but don't be so rose tinted, this is a stupid error.
\" is a control sequence to print a single quote so the compiler is expecting another quote on the end of your string thus "\"". its not an error.
This is very handy if you are outputting HTML-code since this includes a lot of " around attributes.
Eg:
a$ = "<a href=\"www.glbasic.com\">GLBasic</a>"
// Instead of:
a$ = "<a href="+chr$(92)+"www.glbasic.com"+chr$(92)+">GLBasic</a>"
Would it be more polite to ask not to be an error\n?
Being BASIC "\" should be treated as "\\" - but it would know when it is being used : Inline or standard for example.
Whether or not it would be easy to implement is another thing. Perhaps a more descriptive error message is needed instead...
\ is evil.
Use allways "/" to separate paths, and the language converts for you to the target platform. Use "\" only for control characters, they are powerful, if you need to put a single \ put "\\" (control code for back slash).