Script Help

 From:  Michael Gibson
7933.9 In reply to 7933.6 
Hi Barry, I've attached here an example that uses your UI.

So first I changed the UI file to use a <moi:NumericInput> control like I described above.

Then I added an #include to bring in the library function WaitForDialogDone(), you can look at the code for this in the WaitForDialogDone.js file in the commands folder - it spins an event loop until the user pushes Done or Cancel, so the command will not just run through and exit like it was doing in the previous version.

Then right below the wait line there's the line to retrieve the value of your input field to use for the script.


The other way you could set it up is if you wanted to make it more interactive with things updating every time you changed the input field, you would need to make your own event loop instead of using the prepackaged one in WaitForDialogDone(), and make it pay attention to an event named 'qty' (the id value of your control), and then go through the calculations at that time rather than doing it as a separate stage like it does now. That would involve a bit more changes to the script though.

Basically though in an event loop any controls with id values will trigger a UI event of that same id name so the script can respond to changed values immediately. But it tends to simplify the logic a bit when you gather values in a separate stage like this is doing now.

Hope this helps!

- Michael


EDIT: oops, forgot attachments - added them now.

EDITED: 27 Apr 2016 by MICHAEL GIBSON