Jump to content
Sign in to follow this  
Guest

Eventhandlers qeustions and such.

Recommended Posts

Guest

Hey, i've been looking around for a explenation on these things for a while now, here are my qeustions:

1. What is the finddisplay command and what is a display?

2. What is the displayseteventhandler eventhandler, why are there multiple event handlers like displayaddeventhandler and ctrladdeventhandler?

3. Why is sometimes _nil = execvm blah blah blah used instead of just execvm?

Excuse me for the amount of qeustions but i cant seem to understand the explenations given on the official and unofficial websites, thankyou in advance.

Share this post


Link to post
Share on other sites

1 and 2, i have to look into. but 3,

well _nil = [] execvm "script.sqf".

"script.sqf" <- this will be the patch and location of our script

'[]' before 'execvm', this will send arguments to the script for example the name of a marker '_nil = ["marker1"] execvm "script.sqf"'.

and '_nil' will contain the result of the execution of the script, it will return a value once the script has been executed.

I reccomand taking a look at this page LINK

Share this post


Link to post
Share on other sites
Guest

So, _nil has to be used, what if you use another variable to return? a random one?

Share this post


Link to post
Share on other sites

Hey rata, good questions :)

  1. A display is a dialog, which is just a config construct containing controls (the parts that make up the display). The default interface, for example, is a display - with each section of it being a control within the display. Each display has an idd (identifying number) assigned to it in the config. So when you use findDisplay the command is looking for an open display which has the idd requested. If it finds it, the display is returned. Now that might be kind of confusing, but think of the difference between a physical object and a description of that object. The display is described in the config files, when it is created in memory an "object" is made from that description - which is what the findDisplay command returns. Also, if you imagine the display "object" is a container, then the controls are "objects" within the container. I hope that's easy enough to understand - it's not entirely accurate, but it should convey the concept.
  2. The displayAddEventHandler and CtrlAddEventHandler commands essentially serve the same purpose for different data types. You have the display "object" I mentioned before and control "objects" (remember controls are the pieces that make up a display). Generally they're used to run code when the user interacts with those "objects" in certain ways. (If you don't know what event handlers are then you should probably learn about object event handlers first).
  3. People do this in cases where code must not return a value (such as the init field of a unit). It assigns the return value of the execVM command to the variable, which stops it being a return value of the code.

I hope that answers your questions, the whole concept of displays and controls is hard to explain as I'm not sure of your current understanding of scripting concepts in general. It's just a knowledge that you build up over time :)

Share this post


Link to post
Share on other sites
Guest
Hey rata, good questions :)

  1. A display is a dialog, which is just a config construct containing controls (the parts that make up the display). The default interface, for example, is a display - with each section of it being a control within the display. Each display has an idd (identifying number) assigned to it in the config. So when you use findDisplay the command is looking for an open display which has the idd requested. If it finds it, the display is returned. Now that might be kind of confusing, but think of the difference between a physical object and a description of that object. The display is described in the config files, when it is created in memory an "object" is made from that description - which is what the findDisplay command returns. Also, if you imagine the display "object" is a container, then the controls are "objects" within the container. I hope that's easy enough to understand - it's not entirely accurate, but it should convey the concept.
  2. The displayAddEventHandler and CtrlAddEventHandler commands essentially serve the same purpose for different data types. You have the display "object" I mentioned before and control "objects" (remember controls are the pieces that make up a display). Generally they're used to run code when the user interacts with those "objects" in certain ways. (If you don't know what event handlers are then you should probably learn about object event handlers first).
  3. People do this in cases where code must not return a value (such as the init field of a unit). It assigns the return value of the execVM command to the variable, which stops it being a return value of the code.

I hope that answers your questions, the whole concept of displays and controls is hard to explain as I'm not sure of your current understanding of scripting concepts in general. It's just a knowledge that you build up over time :)

Thanks a ton, i'll read what you wrote over and over again until i fully understand it, I hate asking qeustions but sometimes i just simply can't understand anything about the subject...And yes i do know some stuff i guess, i've read the "Fockers arma scripting guide", thanks fockers ;)

Share this post


Link to post
Share on other sites

and '_nil' will contain the result of the execution of the script, it will return a value once the script has been executed.

execVM command returns handle to the script executed not the script result, please check BIKI next time before spreading misinformation.

To the OP. _nil doesnt have any significant meaning. It could be _lalalalalalhahahaha if you want will not make a difference. Sometimes you need to return NOTHING instead of value, assigning output of execVM to a variable will make sure that the whole expression returns NOTHING.

Share this post


Link to post
Share on other sites
Guest
execVM command returns handle to the script executed not the script result, please check BIKI next time before spreading misinformation.

To the OP. _nil doesnt have any significant meaning. It could be _lalalalalalhahahaha if you want will not make a difference. Sometimes you need to return NOTHING instead of value, assigning output of execVM to a variable will make sure that the whole expression returns NOTHING.

Thanks, can't you just make a new empty variable for that? Also, it seems like you're assigning nothing to the execvm command, how come it is able to run? Or rather, if you assign a variable to something, why would it automatically run?

Share this post


Link to post
Share on other sites

You would be assigning nothing to the return, not to the command itself. Yes, you could just make a new variable for each execVM call but most of the time you don't need to know the script handle, so assigning the script handle to nothing just saves some RAM and variable names.

You can just straight execVM without even declaring an output (depending on the execution environment):

[] execVM "script.sqf";//works fine

Or you can assign the script handle the value of "0", basically nothing:

0 = [] execVM "script.sqf";

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×