based subroutine, get the address of the target sub ?

Discussion about the ZBasic language including the System Library. If you're not sure where to post your message, do it here. However, do not make test posts here; that's the purpose of the Sandbox.
Post Reply
ndudman
Posts: 79
Joined: 25 December 2008, 14:00 PM

based subroutine, get the address of the target sub ?

Post by ndudman »

Hi

Perhaps Iḿ misunderstanding how to use based subroutines, however I have the following code, but am trying to set the runSubOnYesAddr with the address of the sub i want to be called when I call runSubOnYes()... what I am doing wrong, or misunderstanding ?

Code: Select all

Declare Sub runSubOnYes () Based runSubOnYesAddr
private runSubOnYesAddr as UnsignedInteger

sub UploadData() Attribute(Used)
	'~ register the subroutine to handle y key press
	runSubOnYesAddr = UploadDataDOIT.DataAddress	
	'~ displayMsgConfirmYN("upload")
end sub

private sub UploadDataDOIT()

end sub

sub keyYPressed()
	call runSubOnYes()
end sub

Sub Main()
End Sub
Thanks
Neil
dkinzer
Site Admin
Posts: 3120
Joined: 03 September 2005, 13:53 PM
Location: Portland, OR

Re: based subroutine, get the address of the target sub ?

Post by dkinzer »

ndudman wrote:what I am doing wrong, or misunderstanding ?
You need to use the .CodeAddress property to get the address of a subroutine or function.

Code: Select all

runSubOnYesAddr = CUInt(UploadDataDOIT.CodeAddress)
- Don Kinzer
ndudman
Posts: 79
Joined: 25 December 2008, 14:00 PM

Post by ndudman »

Thanks Vmuch, now Ive found it in the ZBasicRef.pdf

Neil
Post Reply