PDA

View Full Version : byref or not byref that is the question.



Michael Clease
18-09-2007, 17:48
When working with strings in PB does the ParseSTRING make a local copy or am I working from original data.

simple example of what i mean.


'----------------------------------------------------------------------------
FUNCTION Exec_TBZZ_String2String() AS LONG
' load a bitmap.
' Usage: n = TBZZ_String2String ( StringtoCopy, StringCOPY as STRING)
'----------------------------------------------------------------------------

LOCAL String1 AS STRING
LOCAL String2 AS STRING

IF thinBasic_CheckOpenParens() THEN
thinBasic_ParseSTRING String1
IF thinBasic_CheckComma() THEN
thinBasic_ParseSTRING String2
IF thinBasic_CheckCloseParens() THEN

string2 = string1


END IF
END IF
END IF

END FUNCTION

ErosOlmi
18-09-2007, 18:00
Abraxas,

in your example, all strings are local.



thinBasic_ParseSTRING String1


Get a string from the script and make a local module copy.
The same in



thinBasic_ParseSTRING String2



To return a modified string you can use the function name. Declare function AS STRING, define in your LoadLocalSymbols something like:



thinBasic_LoadSymbol "TBZZ_String2String" , %thinBasic_ReturnString , CodePtr(Exec_TBZZ_String2String ), %thinBasic_ForceOverWrite


and inside your function something like:



FUNCTION = String1


or whatever you want to return.

_________________________________________________
Instead, if you want to have a parameter passed BYREF to your module function, please have a look at this post here: http://community.thinbasic.com/index.php?topic=748.msg4452#msg4452

If you need more info, let me know and I will give all the info you need. I'm going home from work right now so please excuse me if I will reply a bit later.

Ciao
Eros

Michael Clease
04-11-2010, 02:55
Is this information still valid or has it been replaced with something new?

I was wanting to byref a string.

Mike