Remember to call the makeDialog() and main() functions, and set the result variables as global. If you click Cancel, the main() function never runs.
makeDialog()
var getCn, getCsp
function makeDialog() {
var mm = 2.83465;
var theDialog = app.dialogs.add({ name: "CN and CSP settings", canCancel: true, minHeight: 600, minWidth: 400, });
with (theDialog.dialogColumns.add()) {
staticTexts.add({ staticLabel: "CN:" });
staticTexts.add({ staticLabel: "SP:" });
}
with (theDialog.dialogColumns.add()) {
getCn = integerEditboxes.add({ editValue: 4 });
getCsp = measurementEditboxes.add({ editValue: (6 * mm), editUnits: MeasurementUnits.millimeters });
}
if (theDialog.show() == true) {
getCn = getCn.editContents;
getCsp = getCsp.editValue / mm;
//run a function that uses the global results
//when OK is clicked
//if Cancel is clicked main() does not run
main()
theDialog.destroy();
}
}
function main(){
app.scriptPreferences.measurementUnit = MeasurementUnits.MILLIMETERS;
alert(getCn + "\r" + getCsp)
// CODE...
//reset units
app.scriptPreferences.measurementUnit = AutoEnum.AUTO_VALUE;
}
... View more