Help - call a Procedure with Variable$

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Franco.

Hi all, need a function to call a procedure, something like:

CallProcedure Variable$

If anybody has a solution or a thought please respond!
If not:
Fred, can you tell me if a command like that is possible?

Sure I'm not the only one that need something like this, for instance
when somebody want to program a little bit object oriented.
(...I mean not full oop - only for some event handling)
What are the users thoughts?
Desperately searching for a solution
Franco


Have a nice day...
Franco
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Skully.

Couldn't you do something like a select case?

Skully
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Mr.Skunk.

Hi,
You can try to enable the assembly option when you compile your source and you can use the "?" (?MyVariable) to get the address of the variable, and you can jump to it using an assembly jump.

Sorry i can give you a complete example as i'm in hollidays and not on my computer.

Hope it can help you...


Mr Skunk

Mr Skunk's PureBasic Web Page
http://www.skunknet.fr.st
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by fred.
Hi all, need a function to call a procedure, something like:

CallProcedure Variable$

If anybody has a solution or a thought please respond!
If not:
Fred, can you tell me if a command like that is possible?

Have a nice day...
Franco
As Mr Skunk suggested, you can enable the inline ASM switch and use the following code :

CALL MyVariable (will jump to the address than MyVariable contain
CALL ?MyLabel (will jump to the label (but need a Return, like a subroutine
JMP ?MyLabel (jump to the label (and don't return)

...
Assembly isn't the point here I guess :)



Fred - AlphaSND
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by ricardo.
CALL MyVariable (will jump to the address than MyVariable contain
CALL ?MyLabel (will jump to the label (but need a Return, like a subroutine
JMP ?MyLabel (jump to the label (and don't return)
Can you explain it a little more Fred?
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Franco.

Sorry Mr.Skunk, sorry Fred,
I don't get it. Tryed to add the asm stuff to the code but nothing worked.
(I'm not a asm coder, sorry...)

OK. Maybe it is better to explain what I intended to do:

IMHO it is not very up to date to code for every Gadget or Menu a Select/Case combination.
If a program gets bigger and bigger it can be very messy.
This can be solved better.
(for example look at http://www.lanset.com/dcuny/wxbasic.htm)


So I wrote some code and now only 1 Select/Case combination is needed for howmuch Gadgets exists:

...snip...
For Event_Case = 0 To Gadget_Maximum
Select EventMenuID()
Case Event_Case
MessageRequester("Show Gadget:", "Event Gadget value : "+str(Event_Case), 0)
EndSelect
Next
...snip...
This works but if I try to involve a Linked List [with the GadgetNumber and GadgetFunction in it] inside a Select or a If loop PureBasic crashes:
...snip...
MessageRequester("Show Gadget :", "Event Gadget value : "+Str(EventMenuList()\Number), 0)
...snip...
BTW: the ResetList(ListName) command is missing in the help files.

Exploring the PB examples I saw the command: CreateGadgetList(WindowID()).
How can I use this list? In the example the list is created but not used in any way.
How the Structure of the list looks like? Can I add Functions behind the Gadgets to these list?

After that I have still the problem to use the selected Function [string from the List] to call a procedure to make some actions.

OK probably something like that is not possible at this time with PB.
So I have to add a command in the wishlist...





Have a nice day...
Franco
Post Reply