It is currently 01 Jan 2010, 07:53

Welcome
Welcome to the SDB Engine Forum!
You are currently viewing our boards as a guest, which gives you limited access to view most discussions and access our other features. By joining our free community, you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content, and access many other special features. Registration is fast, simple, and absolutely free, so please, <a href="/profile.php?mode=register">join our community today</a>!


Post a new topicPost a reply Page 1 of 1   [ 9 posts ]
Author Message
 Post subject: ... give parameter to OnPushed function
PostPosted: 25 Oct 2008, 23:41 

Joined: 27 May 2008, 19:38
Posts: 67
Location: Dresden / Germany
Hi Fabio,

is it possible to give a parameter to a function, that I call on the OnPushed (respectively OnChanged ...) event? Sth like
Code:
...
{ OnPushed = myFunc("My Text") }

or
Code:
...
{ OnPushed = myFunc(myVar$) }

If yes - how do I do that? :-)

Thanks a lot! ... and dig out your soul! :-)

Micha

_________________
CD32 + SX1; AmiKit (WinUAE) + OS3.9


Top
 Profile  
 
 Post subject: Re: ... give parameter to OnPushed function
PostPosted: 26 Oct 2008, 21:48 
Site Admin
User avatar

Joined: 22 Mar 2007, 22:50
Posts: 112
Hi Micha,
if I've understood what you mean, you want to assign to an event a function with a variable parameter... well, actually it's not supported but is easy to implement this feature.
Actually the function you assign is called with only one parameter, a table containing the member <id> and <event>, respectively the numeric id of the activated gadget and the event that has generated the function call, I can add another parameter that can be a custom table with your personal parameters.
In the meantime you can handle your functions using global variables and/or switching the right value checking the <id> of the activated gadget.

Supposing you have planned something like:
Gadget "ButtonA"
Code:
{ OnPushed = fPrintSomething("Something") }

Gadget "ButtonB"
Code:
{ OnPushed = fPrintSomething("Something else...") }


You can use this code:
Gadget "ButtonA"
Code:
{ OnPushed = fPrintSomething() }

Gadget "ButtonB"
Code:
{ OnPushed = fPrintSomething() }

Code:
function fPrintSomething(msg)
   Local ButtonA_id = scui.GetIFOID("ButtonA")
   Local ButtonB_id = scui.GetIFOID("ButtonB")
   Local MyString = ""
   Switch msg.id
      Case ButtonA_id
         MyString = "Something"
      Case ButtonB_id
         MyString = "Something else..."
   EndSwitch

   Print(MyString)
EndFunction


This is just an example, hope it can helps :D

Good coding :wink:
Fabio


Top
 Profile  
 
 Post subject: Re: ... give parameter to OnPushed function
PostPosted: 26 Oct 2008, 21:56 

Joined: 27 May 2008, 19:38
Posts: 67
Location: Dresden / Germany
Allanon wrote:
Supposing you have planned something like:
...

Yep, that's exactely what I wanna to do!!! Would be great, if you could add that, but necessarly for version 0.6 (as we are waiting eagerly :-D).

But yeah, your expample is great, logical and very useful for me! Thanks a lot for that!

Your support and work is really great! Soldier on! :-)

Cheers,
Micha

_________________
CD32 + SX1; AmiKit (WinUAE) + OS3.9


Top
 Profile  
 
 Post subject: Re: ... give parameter to OnPushed function
PostPosted: 26 Oct 2008, 23:36 
Site Admin
User avatar

Joined: 22 Mar 2007, 22:50
Posts: 112
Thank you Micha, I'm happy to help in any way and even more happy to see that you like my work :)

btw I'm not sure if I can include this feature in the 0.6, I'd like to close the next version with Menus, Image and Virtual Area classes, some example to show their use and updated documentation.

cya around mate :)


Top
 Profile  
 
 Post subject: Re: ... give parameter to OnPushed function
PostPosted: 27 Oct 2008, 13:51 

Joined: 27 May 2008, 19:38
Posts: 67
Location: Dresden / Germany
Yep, not necessary to include it to 0.6. Would be better to publish it soon. :-) Any concrete dates available? :-) Or just "when it's done"? ;-)

Cheers

_________________
CD32 + SX1; AmiKit (WinUAE) + OS3.9


Top
 Profile  
 
 Post subject: Re: ... give parameter to OnPushed function
PostPosted: 27 Oct 2008, 21:00 
Site Admin
User avatar

Joined: 22 Mar 2007, 22:50
Posts: 112
Well, all depends on my RL work I've estimated 2/3 weeks, if I cannot be able to update the documentation (this is the last work I will do) I will publish the new version without it, but I will include for sure some examples showing the new function in action.


Top
 Profile  
 
 Post subject: Re: ... give parameter to OnPushed function
PostPosted: 27 Oct 2008, 21:10 

Joined: 27 May 2008, 19:38
Posts: 67
Location: Dresden / Germany
Sounds very good! But no hectic, RL first!

PS: You've got a PM ...

_________________
CD32 + SX1; AmiKit (WinUAE) + OS3.9


Top
 Profile  
 
 Post subject: Re: ... give parameter to OnPushed function
PostPosted: 28 Oct 2008, 16:24 

Joined: 27 May 2008, 19:38
Posts: 67
Location: Dresden / Germany
Ok, I just want to correct the following code:
Allanon wrote:
Code:
function fPrintSomething(msg)
   Local ButtonA_id = scui.GetIFOID("ButtonA")
   Local ButtonB_id = scui.GetIFOID("ButtonB")
   Local MyString = ""
   Switch msg.id
      Case ButtonA_id
         MyString = "Something"
      Case ButtonB_id
         MyString = "Something else..."
   EndSwitch

   Print(MyString)
EndFunction


This does not work, because the case branch always as to be a constant value, not a varible in Hollywood ... :-(

So, in order to get it work you have to write the following:
Code:
If msg.id = Case ButtonA_id
         MyString = "Something"
      ElseIf msg.id = ButtonB_id
         MyString = "Something else..."
EndIf

Hope, that helps other people around here ...

Greetings,
Micha

_________________
CD32 + SX1; AmiKit (WinUAE) + OS3.9


Top
 Profile  
 
 Post subject: Re: ... give parameter to OnPushed function
PostPosted: 28 Oct 2008, 18:11 
Site Admin
User avatar

Joined: 22 Mar 2007, 22:50
Posts: 112
Yup, you are right ;)


Top
 Profile  
 
Display posts from previous:  Sort by  
Post a new topicPost a reply Page 1 of 1   [ 9 posts ]


Who is online

Users browsing this forum: No registered users and 0 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
You cannot post attachments in this forum

Search for:
Jump to:  
cron