Please tell me how can I return information about choosing one of the optionButtons. For example, write 1 to a variable if the first optionButton is selected, or write 2 to this variable if the second optionButton is selected? To then return this variable to the main function. Buttons can be used instead of optionButtons, but the question remains the same.
function myDialog() { this.switchVariable = 1; this.getPages = function() { var iDialogTemplate1 = Dialogs.createNewDialogTemplate(600, 200, "Only page"); iDialogTemplate1.OptionGroup("OG_1"); iDialogTemplate1.OptionButton(35, 5, 80, 15, "Press 1") iDialogTemplate1.OptionButton(35, 25, 80, 15, "Press 2") return [iDialogTemplate1]; } this.getResult = function() { return this.switchVariable; } this.OG_1_selChanged = function(indexOfNewSelection){ this.switchVariable = indexOfNewSelection + 1; } } var result = Dialogs.showDialog(new myDialog(), Constants.DIALOG_TYPE_ACTION, "A dialog"); Dialogs.MsgBox(result)
Basically what you want to do is add a variable to your Dialog object with "this.WhateverItIsSupposedToBeCalled = 0", then add a method that is called whenever the selection within your option group is changed. The name of this method has to start with the field name of the option group, then you append "_selChanged" (without quotation marks). If the method is not named like this, it won't be called when the selection changes. This reaction method should change the previously added variable. To return the value of the variable, use the this.getResult function.
Doing the same with normal buttons, instead of an option group requires two reaction methods instead of one reaction method. Each button has to have its own reaction method, with the following name sceme: start with the field name of the individual button, append "_pressed" (without quotation marks) to that. The method then switches the variable to the desired value. To return the variable after normal buttons are pressed, use the same this.getResult function you would have used with the option group.
Edit: made a tiny mistake within my script (initialized the switchVariable with 0 instead of 1). Corrected it.