Define.s s$ ;addr[0], @#Empty$ ;Err

Just starting out? Need help? Post your questions and find answers here.
User avatar
skywalk
Addict
Addict
Posts: 3972
Joined: Wed Dec 23, 2009 10:14 pm
Location: Boston, MA

Define.s s$ ;addr[0], @#Empty$ ;Err

Post by skywalk »

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
User avatar
mk-soft
Always Here
Always Here
Posts: 5334
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: [BUG-v573] Define.s s$ ;addr[0], @#Empty$ ;Err

Post by mk-soft »

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
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
User avatar
skywalk
Addict
Addict
Posts: 3972
Joined: Wed Dec 23, 2009 10:14 pm
Location: Boston, MA

Re: [BUG-v573] Define.s s$ ;addr[0], @#Empty$ ;Err

Post by skywalk »

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
Administrator
Posts: 16616
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: [BUG-v573] Define.s s$ ;addr[0], @#Empty$ ;Err

Post by Fred »

It's not a bug, variables can be null when they are just defined (and not allocated)
User avatar
Lunasole
Addict
Addict
Posts: 1091
Joined: Mon Oct 26, 2015 2:55 am
Location: UA
Contact:

Re: Define.s s$ ;addr[0], @#Empty$ ;Err

Post by Lunasole »

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"
User avatar
mk-soft
Always Here
Always Here
Posts: 5334
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: Define.s s$ ;addr[0], @#Empty$ ;Err

Post by mk-soft »

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
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
Post Reply