how can I get the address of a string concatenation (after concatenation)?
Code: Select all
@" Hello, " + "world!"; error; type mismatch
@("Hello, " + "world!"); error; syntax errorThanks a lot!
Code: Select all
@" Hello, " + "world!"; error; type mismatch
@("Hello, " + "world!"); error; syntax error
Code: Select all
" Hello, " + "world!"Code: Select all
Dummy$ = " Hello, " + "world!"
debug @Dummy$
Code: Select all
; A PureBasic string variable is a memory address pointer to the actual string data in memory
; The string Manager assigns memory to string variable's data
Text$="Hello, "
Debug Text$
Debug @Text$
; The string manager has allocated some "extra memory" for the string data,
; so adding a small number of characters to the string variable does
; not change the string data's memory address.
Text$= "Hello, "+"World"
Debug Text$
Debug @Text$
; Adding more characters will result in the
; string Manager allocating more memory and moving the string data to another address
Text$ = Text$+ ", ABCDEFGHIJKLMNOPQRSTUVWXYZ"
Debug Text$
Debug @Text$
As HanPBF pointed out, '@' can also be applied to string literals.ElementE wrote:With regards to the specific original question.
It appears that the @ operator can only be applied to string variables, not to string expressions!
Code: Select all
DataSection
testString:
Data.s "Hello, " + "world!"
EndDataSection
Debug ?testString
Debug PeekS(?testString)Code: Select all
text$="Hello"
A.l=@(text$)Code: Select all
A.l=@("Hello")Code: Select all
@("Hello, " + "world!")Code: Select all
Debug PeekS(@"Literal") ; Valid syntax
;Debug PeekS(@("Literal1" + " Literal2")) ; Invalid syntax - not concatenated at compile-time
Debug ""
StringVar.s = "Var1" + " Var2"
Debug PeekS(@StringVar)
Debug ""
Debug "Hello" + " World!" ; Normal
Debug ("Hello" + " World!") ; All in parentheses
Debug ("Hello") + " World!" ; Bug???
;Debug "Hello" + (" World!") ; Invalid syntax
Debug ""
DataSection
StringData1:
Data.s "Data"
StringData2:
Data.s "Data1" + " Data2"
StringPtr:
Data.i @"DataPtr"
EndDataSection
Debug PeekS(?StringData1)
Debug PeekS(?StringData2) ; Valid syntax - concatenated at compile-time
Debug PeekS(PeekI(?StringPtr))Code: Select all
Debug ("Hello") + " World!"Code: Select all
debug @"Hello, world!"Code: Select all
debug @("Hello, " + "world!")