 |
KiXforms The Forum for the KiXforms Community
|
|
View previous topic :: View next topic |
Author |
Message |
Glen KiXforms Novice

Joined: 24 Aug 2005 Posts: 2
|
Posted: Thu Aug 25, 2005 12:10 am Post subject: How Does KiXforms Call An Event Function ? |
|
|
Hello,
I wonder if anyone could give me a basic programming overview of how KiXforms calls a script function on an event trigger. I am interested in learning the technique but I do not know where to start looking for information on how to achieve it.
For example, if a script contains a function called 'SomeFunction' and I set a button's OnClick event = SomeFunction, what programming mechanism enables the KiXforms.DLL to execute 'SomeFunction' ? My understanding is it is not something specific to KiXtart as I can achieve the same result using VBscript (and presumably JavaScript as well).
I am not expecting a step by step guide complete with program listings and examples (most of which would probably be over my head anyway) ... a list of terms I could google for would be more than enough to get me started.
Thanks in advance for any replies.
Glen |
|
Back to top |
|
 |
Shawn KiXforms Developer


Joined: 22 Feb 2003 Posts: 1983 Location: Canada
|
Posted: Thu Aug 25, 2005 12:30 am Post subject: |
|
|
There is no magic involved really. Lets say you have a button and you setup a function like this:
$Button = $Form.Button()
Function Button_Click()
?"Hello World"
EndFunction
What connects the two together ?
1) First, we pass a string containing the function to call to the Buttons OnClick event like this:
$Button.OnClick = "Button_Click()"
Nothing fancy, all your doing at this point is simply assigning the string "Button_Click()" to the property called OnClick.
2) Run the DoEvents / Execute loop, like this:
While $Form.Visible
$= Execute($Form.DoEvents)
Loop
This is where the "how" of what happens really happens. $Form.DoEvents waits for events to happen. When you click the button, Kixforms takes the string that you supplied in OnClick, and returns this string from DoEvents - then, because you have wrapped the DoEvents in an Execute statement, the string that is returned gets "Executed" as Kixtart code (this is the real trick) - under the covers, the Execute is processing something like this:
$= Execute("Button_Click()")
This statement instructs Kixtart to call the Button_Click() function - in a very dynamic fashion - Execute parses script statements on-the-fly. When the Execute function returns, the loop is done again and again and again - executing the strings returned from DoEvents. When the forms goes not visible, the loop is terminated.
Make a little sense ?
-Shawn |
|
Back to top |
|
 |
Glen KiXforms Novice

Joined: 24 Aug 2005 Posts: 2
|
Posted: Thu Aug 25, 2005 9:50 am Post subject: |
|
|
Ah yes .... that makes perfect sense. KiXforms.DLL creates and displays the form, waits for events to occur (DoEvents) and then passes a string associated with the trapped event back to the calling script. The calling script, expects this string to be the name of a user defined function and calls the Execute function to run this function.
I was obviously overthinking the solution when I asked this question (I was expecting a reply involving COM objects, callback functions, IDispatch interfaces and the like).
Thank you for clearing that up for me Shawn.
Regards
Glen |
|
Back to top |
|
 |
|
|
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 vote in polls in this forum You cannot attach files in this forum You can download files in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|