Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / BUG in variable$ (Not usual)

Author
Message
ICERGB
21
Years of Service
User Offline
Joined: 8th Nov 2002
Location: Canada
Posted: 5th Dec 2002 04:16
If you do not declare a string to be something...

it does not = "" to start with, as I think it maybe should.

rapscaLLion
21
Years of Service
User Offline
Joined: 29th Aug 2002
Location: Canada
Posted: 5th Dec 2002 05:19
lol, your right
that's wierd. I guess you have to declare the variable as being "" when your proggy starts.

Wierd that...

Alex Wanuch
aka rapscaLLion
Kousen Dev Progress >> Currently Working On Editors
AsylumHunter
21
Years of Service
User Offline
Joined: 3rd Oct 2002
Location: United States
Posted: 5th Dec 2002 06:41
If you don't declare a variable you run the risk of that variable pointing to data in uncleared memory.

AsylumHunter

still falling out of my binary tree most evenings (hicup!)
Thade!
21
Years of Service
User Offline
Joined: 11th Sep 2002
Location: Austria
Posted: 5th Dec 2002 13:51
Its not usual to declare variables in Basic. That's one thing the Interpreter or in this case (DBPro) the Compiler has to manage.
MrTAToad
21
Years of Service
User Offline
Joined: 26th Aug 2002
Location: United Kingdom
Posted: 5th Dec 2002 15:01
I believe a compare with "" and a non-initialise variable are different, ie

a$="":if a$="" then print "Yes", will print yes, because a$ has been initialised with nothing, however,
if b$="" then print "yes" will not print yes, because at the time of the compare, b$ has to be created and seems to be initialised to NULL (which appears to be different from "").

This may be a bug, or may not be...

Good news everybody! I really am THAT good...
xtom
21
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Ireland
Posted: 6th Dec 2002 01:35
I emailed Lee about this after patch 3.1 but haven't heard back from him yet. Probably busy with other bugs but hopefully it gets fixed.
Thade!
21
Years of Service
User Offline
Joined: 11th Sep 2002
Location: Austria
Posted: 6th Dec 2002 15:29
Thats not quite right MrTAToad. The Compiler which produces the EXE has to "see" on its first pass, that there is a String Variable to declare - and has to set the declaration at the right place. DBPro is no Interpreter- or Script-Language.
And if it would initialize a $!!! String Variable to NULL it would be a Bug anyway.
MrTAToad
21
Years of Service
User Offline
Joined: 26th Aug 2002
Location: United Kingdom
Posted: 6th Dec 2002 20:24
It might see the variables during compilation, but it would create the memory space for the variable during the running of the program (because it wont know how much to allocate during compilation).

Good news everybody! I really am THAT good...
IanM
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 6th Dec 2002 21:56
There is a bug here, but it's not the string pointer being NULL - that's there by design (why allocate memory to hold nothing - memory allocation is slowwwww).

The bug is in the string comparison functions that should equate NULL to an empty string, in exactly the same way that an uninitialised integer is set to zero.
Thade!
21
Years of Service
User Offline
Joined: 11th Sep 2002
Location: Austria
Posted: 7th Dec 2002 14:31
Hey MrTAToad - it seems you are really not THAT good...
Your answer is one of those I just say - believe what you want - it is wasted time to discuss it any further.
MrTAToad
21
Years of Service
User Offline
Joined: 26th Aug 2002
Location: United Kingdom
Posted: 7th Dec 2002 20:32
What are you on about ?

Good news everybody! I really am THAT good...
Thade!
21
Years of Service
User Offline
Joined: 11th Sep 2002
Location: Austria
Posted: 7th Dec 2002 21:59
I am nothing on about.
It is my way not to tell you that the answer was stupid.
An empty string has the same length in run or compile or nirvana space time.
The compiler has to make sure that there is (to keep ICERGBs example) a Stringvariable called Fuzzy$ and that it is empty (="") in case its not referred to or changed. If it doesn't do that and the line If fuzzy$="" then print "works" produces whatever result but not the awaited then its a bug - so easy. And no discussion can change that.
MrTAToad
21
Years of Service
User Offline
Joined: 26th Aug 2002
Location: United Kingdom
Posted: 8th Dec 2002 01:09
I still can't see how your comments are relevent...

Good news everybody! I really am THAT good...

Login to post a reply

Server time is: 2024-04-30 18:39:02
Your offset time is: 2024-04-30 18:39:02