Just starting out? Need help? Post your questions and find answers here.
skywalk
Addict
Posts: 4003 Joined: Wed Dec 23, 2009 10:14 pm
Location: Boston, MA
Post
by skywalk » Fri May 21, 2021 1:23 pm
Code: Select all
Debug "Global"
Define.s s$
Debug @s$ ; [0] <-- Bug? I thought all defined variables are set to 0 or #Empty$?
s$ = Chr(0)
Debug @s$ ; [37882020]
s$ = #Empty$
s$ + s$ + s$
Debug @s$ ; [37882020]
Debug Len(s$) ; 0 = Correct
;Debug @Chr(10) ;[08:04:38] [COMPILER] Line 3: Chr() is not declared.
;Debug @#Empty$ ;[08:05:23] [COMPILER] Line 4: Constant not found: #.
Debug @"" ; Ok
Procedure Do1()
Debug "Do1()"
Protected.s s$
Debug @s$ ; [0] <-- Bug? I thought all defined variables are set to 0 or #Empty$?
s$ = Chr(0)
Debug @s$ ; [37882020]
s$ = #Empty$
s$ + s$ + s$
Debug @s$ ; [37882020]
Debug Len(s$) ; 0 = Correct
;Debug @Chr(10) ;[08:04:38] [COMPILER] Line 3: Chr() is not declared.
;Debug @#Empty$ ;[08:05:23] [COMPILER] Line 4: Constant not found: #.
Debug @"" ; Ok
EndProcedure
Do1()
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
mk-soft
Always Here
Posts: 5409 Joined: Fri May 12, 2006 6:51 pm
Location: Germany
Post
by mk-soft » Fri May 21, 2021 3:17 pm
No bug ...
A not yet used string variable points to nothing (NIL = 0)
The constant #Empty$ is the same as the assignment "".
To get the pointer to a string constant is unfortunately not possible "@#String".
Code: Select all
s1 = "Hello"
Debug @s1
s1 = #Null$ ; Set String to Nothing (Repaired since v5.73)
Debug @s1
skywalk
Addict
Posts: 4003 Joined: Wed Dec 23, 2009 10:14 pm
Location: Boston, MA
Post
by skywalk » Fri May 21, 2021 3:57 pm
It is a bug if PB states all variables are set to 0 or "".
I have compiler errors when using macros that receive defined strings that have no address or null address.
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
Fred
Administrator
Posts: 16687 Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:
Post
by Fred » Sat Apr 08, 2023 12:00 pm
It's not a bug, variables can be null when they are just defined (and not allocated)
Lunasole
Addict
Posts: 1091 Joined: Mon Oct 26, 2015 2:55 am
Location: UA
Contact:
Post
by Lunasole » Sun Apr 09, 2023 7:07 am
Code: Select all
Structure TEST
S$
EndStructure
Define T.TEST
Procedure$ Test(S$)
ProcedureReturn PeekS(@S$)
EndProcedure
Debug Test(#Empty$) + "OK"
Debug Test("") + "OK"
Debug Test(#Null$) + "IMA 0"
Debug Test(T\S$) + "IMA 0"
T\S$ = ""
Debug Test(T\S$) + "OK"
I also encountered that recently in some older code, maybe in older versions that was handled differently, now it's like in C also.
"W̷i̷s̷h̷i̷n̷g o̷n a s̷t̷a̷r"
mk-soft
Always Here
Posts: 5409 Joined: Fri May 12, 2006 6:51 pm
Location: Germany
Post
by mk-soft » Sun Apr 09, 2023 10:40 am
Added: 16th October 2015 : Version 5.40 LTS
- Added: #Null$ special string constant to affect a real null value to a string (to free it completely). It can be used as well for API function which sometimes accept NULL instead of a string address.
- Added: #Empty$ constant
----
Works from v5.40 to v5.62
Failed with v5.70, v5.71
Repaired with v5.72