It is currently Wed Jun 19, 2013 3:14 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Passing ByRef at second call level
PostPosted: Sun Mar 18, 2012 11:25 am 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Tue Sep 23, 2008 11:38 pm
Posts: 702
Location: Belgium (& Luxembourg)
Hello all
I have a problem here. I am not sure how to pass the variable *v\s to a second call. I know that when I need to pass a variable, I should use @v.....
What should I change in the program so the final result is tvar\s="change #1 and change #2" ?
Code:
; This is how to use ByRef with string variables, which are in fact pointers

Procedure change2(*v.string)
    *v\s+" and change #2"
    Debug *v\s
EndProcedure

Procedure change1(*v.string)
    *v\s="change #1"
    Debug *v\s
    change2(@v); this is my problem <<<<<<<<<<
EndProcedure



Define.string tvar ; or Define tvar.string
tvar\s="initial-value"
Debug "before call: "+tvar\s
Debug "================================"
change1(@tvar)
Debug "================================"
Debug "after call: "+tvar\s

Thanks in advance!

_________________
- Future conversation forecasting not yet implemented.
- If the future had copied a program from now, they would have called it version -1.


Top
 Profile  
 
 Post subject: Re: Passing ByRef at second call level
PostPosted: Sun Mar 18, 2012 11:35 am 
Offline
Addict
Addict

Joined: Sun Aug 08, 2004 5:21 am
Posts: 1109
Location: Netherlands
Pass the pointer
Code:
; This is how to use ByRef with string variables, which are in fact pointers

Procedure change2(*v.string)
    *v\s+" and change #2"
    Debug *v\s
EndProcedure

Procedure change1(*v.string)
    *v\s="change #1"
    Debug *v\s
    change2(*v)
EndProcedure



Define.string tvar ; or Define tvar.string
tvar\s="initial-value"
Debug "before call: "+tvar\s
Debug "================================"
change1(@tvar)
Debug "================================"
Debug "after call: "+tvar\s


Top
 Profile  
 
 Post subject: Re: Passing ByRef at second call level
PostPosted: Sun Mar 18, 2012 12:20 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Tue Sep 23, 2008 11:38 pm
Posts: 702
Location: Belgium (& Luxembourg)
Thank you Wilbert.
It was too simple... we all have (many?) holes in the head, and the needed info is exactly there :mrgreen:

_________________
- Future conversation forecasting not yet implemented.
- If the future had copied a program from now, they would have called it version -1.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: LuCiFeR[SD] and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye