I wanted to understand the Script Dialog creation better. I have not written VB in a while so I decided to take some of the examples and convert them into JavaScript. I did and it helped, besides being stuck at one point. I wanted to share with other members so they can use if they understand JavaScript more than VB. However, I am stuck with one part. That being, it seems like there must be different ways the objects work in JavaScript to set properties. In the radio button example (p 566 in User Manual) I cannot set a property when it not preceded by a valid event (maybe) or I should say that I can set a property that is easily set in the same function. In the function radioSelected I cannot set dlg.Control("static" + 1).enabled to false.
function OnClick(clickData) {
var dlg = DOpus.Dlg
dlg.window = clickData.func.sourcetab
dlg.template = "testdlg"
dlg.detach = true
dlg.Show
// message loop
do {
var msg = dlg.GetMsg()
if (msg.event == "click" && msg.control.substr(0, 5) == "radio") {
radioSelected(dlg, msg)
} else if (msg.event == "editchange" && msg.control == "val") {
editChanged(dlg, msg)
}
}
while (msg);
}
function radioSelected(dlg, msg) {
if (msg.data) {
for (i=0;i<=5;i++) {
if (msg.control == "radio" + i){
dlg.Control("static" + i).enabled = true
dlg.Control("seltext").label = "You selected option #" + i
if(msg.focus) {
dlg.Control("val").value = i
}
} else {
dlg.Control("static" + i).enabled = false // cannot set this property back to flase?
}
}
}
}
function editChanged(dlg, msg) {
if (msg.focus && msg.value >= 1 && msg.value <= 5) {
dlg.Control("radio" + msg.Value).value = true
}
}