Everything else that doesn't fall into one of the other PB categories.
Bisonte
Addict
Posts: 1324 Joined: Tue Oct 09, 2007 2:15 am
Post
by Bisonte » Sat Jun 11, 2016 9:22 pm
Hello...
As i read in the announcement :
Code: Select all
- Added: @#StringConstant$ syntax support, to get the address of a string constant
I ask me one Question :
"What happens if someone do this ?"
Code: Select all
#StringConstant$ = "Hello"
PokeS(@#StringConstant$, "PureBasic")
Debug #StringConstant$
Legal ? Memory Errors (cause the poked string is longer/shorter..) ?
Is this a bug or a feature ?
P ureB asic 6.21 (Windows x64) | Windows 11 Pro | AsRock B850 Steel Legend Wifi | R7 9800x3D | 64GB RAM | RTX 5080 | ThermaltakeView 270 TG ARGB | build by vannicom
English is not my native language...
(I often use DeepL .)
DontTalkToMe
Enthusiast
Posts: 334 Joined: Mon Feb 04, 2013 5:28 pm
Post
by DontTalkToMe » Sat Jun 11, 2016 10:37 pm
Variable constants are a reality finally. PB is pushing the boundaries
Code: Select all
#StringConstant$ = "Hello"
#Horror$ = "Horror"
Debug #StringConstant$
Debug #Horror$
PokeS(@#StringConstant$, "PureBasic")
Debug #StringConstant$
Debug #Horror$
The offset of #Horror$ is constant (just after the end of the original #Hello$ ) and so the result is what you would expect.
Derren
Enthusiast
Posts: 318 Joined: Sat Jul 23, 2011 1:13 am
Location: Germany
Post
by Derren » Sat Jun 11, 2016 11:39 pm
I need to get me the beta soon, this looks "interesting".
What about this? oO
Code: Select all
#const$ = "hello"
Dim myArray.i(10)
For i = 0 To 10
myArray(i) = i * (10000) + 999
Next
PokeS(@#const$, "PureBasic Beta Stuff")
For i = 0 To 10
Debug myArray(i)
Next
DontTalkToMe
Enthusiast
Posts: 334 Joined: Mon Feb 04, 2013 5:28 pm
Post
by DontTalkToMe » Sat Jun 11, 2016 11:47 pm
What about it ?
I need to get me the beta soon, this looks "interesting".
If you didn't have the beta, how can you test the above code ?
Last edited by
DontTalkToMe on Sat Jun 11, 2016 11:51 pm, edited 1 time in total.
skywalk
Addict
Posts: 4264 Joined: Wed Dec 23, 2009 10:14 pm
Location: Boston, MA
Post
by skywalk » Sat Jun 11, 2016 11:50 pm
Kinda confusing? #World$ does not always appear next to #Hello$ in the memory viewer?
Code: Select all
#Hello$ = "Hello"
#World$ = "World"
Debug "#Hello$ = " + #Hello$
Debug "#World$ = " + #World$
ShowMemoryViewer(@#Hello$-128, 256)
;Debug @#Hello$ ;<-- Without these, #World$ does not appear in Memory Viewer?
;Debug @#World$ ;<--
CallDebugger
Debug "PokeS(@#Hello$, '12345', 5, #PB_String_NoZero)"
Debug PokeS(@#Hello$, "12345", 5, #PB_String_NoZero)
ShowMemoryViewer(@#Hello$-128, 256)
Debug "#Hello$ = " + #Hello$
Debug "#World$ = " + #World$
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
Derren
Enthusiast
Posts: 318 Joined: Sat Jul 23, 2011 1:13 am
Location: Germany
Post
by Derren » Sun Jun 12, 2016 12:45 am
DontTalkToMe wrote: What about it ?
I need to get me the beta soon, this looks "interesting".
If you didn't have the beta, how can you test the above code ?
I can't. That's why I asked^^
DontTalkToMe
Enthusiast
Posts: 334 Joined: Mon Feb 04, 2013 5:28 pm
Post
by DontTalkToMe » Sun Jun 12, 2016 1:01 am
Looked like you were saying "see what this program does!" oO
In that case, your program runs fine for what I can see.
If you were expecting for the array to be overwritten, that doesn't happen.
If that's what you were thinking because you didn't say.
oh well ....
Fred
Administrator
Posts: 18396 Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:
Post
by Fred » Sun Jun 12, 2016 6:44 am
Bisonte wrote: Hello...
As i read in the announcement :
Code: Select all
- Added: @#StringConstant$ syntax support, to get the address of a string constant
I ask me one Question :
"What happens if someone do this ?"
Code: Select all
#StringConstant$ = "Hello"
PokeS(@#StringConstant$, "PureBasic")
Debug #StringConstant$
Legal ? Memory Errors (cause the poked string is longer/shorter..) ?
Is this a bug or a feature ?
It's the same as patching a literal string constant: you can do it, but it's strongly not recommanded.
Code: Select all
PokeS(@"Hello", "World")
Debug "Hello" ; Wooooot
To avoid this, we could put the literal string datasection in read only so it would raise a IMA, but I don't know if it worths it.
sq4
User
Posts: 98 Joined: Wed Feb 26, 2014 3:16 pm
Contact:
Post
by sq4 » Sun Jun 12, 2016 8:17 am
Fred wrote:
To avoid this, we could put the literal string datasection in read only so it would raise a IMA, but I don't know if it worths it.
Please don't. It would break backward compatibility.
Bisonte
Addict
Posts: 1324 Joined: Tue Oct 09, 2007 2:15 am
Post
by Bisonte » Sun Jun 12, 2016 9:14 am
Fred wrote:
To avoid this, we could put the literal string datasection in read only so it would raise a IMA, but I don't know if it worths it.
This is not necessary !
I only wanted to know, what happened... so we have
NOT! do something like that...
P ureB asic 6.21 (Windows x64) | Windows 11 Pro | AsRock B850 Steel Legend Wifi | R7 9800x3D | 64GB RAM | RTX 5080 | ThermaltakeView 270 TG ARGB | build by vannicom
English is not my native language...
(I often use DeepL .)