Page 1 of 1

Data.i @Procedure() is not resolved correctly > Debug output

Posted: Tue Sep 01, 2020 4:53 pm
by Kurzer
The address of a procedure is not resolved correctly when using in a Datasection.
The following code shows under PureBasic the correct memory address of the procedure:

Code: Select all

Procedure Output()
	Debug "Hallo Welt"
EndProcedure

DataSection
	Proc:
	Data.i @Output()
EndDataSection

Define.i iProc

Restore Proc
Read.i iProc
Debug iProc
However, under SpiderBasic the following is displayed in the debug window:

Code: Select all

function f_output() {
spider.debug.Print(_S1);
return 0;
}
Is there a Workaround available? Otherwise this would destroy my program concept. :shock:

EDIT:
Phew, the problem is not a showstopper for my project. Apparently only the debug output is not working correctly (or a JavaScript procedure cannot have an address by design. I am not that familiar with it). The value read by Read.i is correct.

The following code works for me.

Code: Select all

Procedure ButtonHandler()
	Debug "Button click event on gadget #" + EventGadget()
EndProcedure

OpenWindow(0, 100, 100, 200, 50, "Click test", #PB_Window_SystemMenu)
ButtonGadget(0, 10, 10, 180, 30, "Click me")

Define *Proc

Restore Proclist
Read.i *Proc
Debug *Proc
BindGadgetEvent(0, *Proc)

DataSection
	Proclist:
	Data.i @ButtonHandler()
EndDataSection
So maybe its not really a bug. Can anyone classify this better?

Markus

Re: Data.i @Procedure() is not resolved correctly > Debug output

Posted: Wed Oct 12, 2022 7:54 am
by Fred
I agree it's misleading, but it's kind of emulated here. You don't have a specific address as you found it, but a reference to a function. It allows the same manipulation, but display the object in the debug window does indeed a strange thing :). It's not a really bug, so I will move the topic to keep it around if anyone else wonder.