What the....???

Archives Forums/Blitz3D Bug Reports/What the....???

big10p(Posted 2005) [#1]
Here's a weird one. Run this (erroneous?) code and be amazed:
Data "hello" + Chr$(34)



WendellM(Posted 2005) [#2]
So that's how you make a file requester in B3D! ;)

And only after letting it load a .bb files does it pop up "Data expression must be constant." Weird indeed.


big10p(Posted 2005) [#3]
So that's how you make a file requester in B3D! ;)
lol.

This was actually my desperate attempt to add double quote characters to Data strings. I didn't think it would work but I didn't expect this! :P


puki(Posted 2005) [#4]
Heh, it works with 'sausage' too:

Data "sausage" + Chr$(34)


octothorpe(Posted 2005) [#5]
Compiler output:

BlitzCC V1.90
(C)opyright 2000-2003 Blitz Research Ltd
Compiling "c:\temp\data.bb"
Parsing...
Generating...
"":65536:65536:65536:65536:Data expression must be constant



Hotcakes(Posted 2005) [#6]
Hey wow, that's an ooooooooooold bug. Reminisence, man...


big10p(Posted 2005) [#7]
What does that tell us, octothorpe?


Hotcakes(Posted 2005) [#8]
It tells us it's an inelegantly handled compiler error.


big10p(Posted 2005) [#9]
I figured it was an inelegantly handled compiler error, Toby. You can't get much more inelegant than throwing up a file requester dialog. :P


Hotcakes(Posted 2005) [#10]
Humbug.


Rob Farley(Posted 2005) [#11]
Of course this is very easy to work around, simply use ~ (or whatever you're not going to use) instead of a " in your data statements and do a replace on reading them

ie

Data "~This is how you get round it~"

read a$
a$ = replace(a$,"~",chr(34))

print a$
waitkey


big10p(Posted 2005) [#12]
Neat idea, Rob - I hadn't thought of that.


Damien Sturdy(Posted 2005) [#13]
heh- This was new to you lot?


big10p(Posted 2005) [#14]
If it's so old, why hasn't it been fixed? :/


WolRon(Posted 2006) [#15]
Actually, BlitzPlus does this as well. I just ran across this about two days ago. Took me a bit to figure out what in the heck was going on...

I came up with the exact same solution Rob suggested too... (well, except I didn't use the tilde character)


Subirenihil(Posted 2006) [#16]
A Data statement (unless I am mistaken) only accepts string surrounded by double quotes or numbers. Because double quotes are used to begin or end strings, then cannot be used within strings except by the insertion of something like this:

txt$="Yada yada yada..."+Chr$(34)+"yada yada yada..."

So, if you want double quotes in text you need to use something like this:

txt$=Chr$(34)+"Just text with quotes."+Chr$(34)

...Not like this:

Data chr$(34)+"Just text with quotes."+Chr$(34)
Read txt$

Why does anybody really need Data statements anyway? It's easier than reading a data file, but why not just set the variable to begin with?

(If anyone disagrees with me, tell me. I am not the best, nor do I know everything about Blitz.)


Panno(Posted 2006) [#17]
its an old "bug" posted in the old bug bin


Sir Gak(Posted 2006) [#18]
Why does anybody really need Data statements anyway? It's easier than reading a data file, but why not just set the variable to begin with?



I use Data statements for test data, such as a map in which I read in numbers for a tilemap into an array. It's self-contained, especially if you want to let others see what you're doing (ie a bug-hunt) and don't want to fuss with having external files that they may have trouble finding/loading.


WolRon(Posted 2006) [#19]
Why does anybody really need Data statements anyway? It's easier than reading a data file, but why not just set the variable to begin with?
Because data files are just that, external (misplaceable, corruptable, erasable) files...

Data statements are never lost.


Ross C(Posted 2006) [#20]
How does one actually use the windows file requestor?


big10p(Posted 2006) [#21]
I think there's code in the archives that let's you use the Windows file requestor in B3D, Ross.


Ross C(Posted 2006) [#22]
Oh, thanks man!