Nested IF bug

Discuss OrbForms Designer and PocketC Architect

Postby FrankG on Fri Jun 02, 2006 12:54 am

I ran into an error in a program in a part of the code that has worked for a long time. I suspect I had updated the program and recompiled with OrbForms 4.0.1 and the new PRC suddenly had this problem:

I got a "butIOK.onselect butIOK not in current form" type error in this handler in a modal form. Code was:
Code: Select all
handler butIOK.onselect() {
  if (LstIGame.selitem >= 0) {
    if (pbIh.checked) {
      if (ReadRoster(true)) {
        frmImport.close();
      } 
    } 
    if (pbIv.checked) {
      if (ReadRoster(false)) {
        frmImport.close();
      } 
    }
  }
  else
    alert("Before importing blah blah blah.");
}

and I changed it to
Code: Select all
handler butIOK.onselect() {
  if (LstIGame.selitem >= 0) {
    if (pbIh.checked) {
      if (ReadRoster(true)) {
        frmImport.close();
      } 
    } 
    else {
      if (pbIv.checked) {
        if (ReadRoster(false)) {
          frmImport.close();
        } 
      }
    } 
  }
  else
    alert("Before importing blah blah blah.");
}

and now it works. I think once there was a similar problem I encountered with IF nesting with unnecessary braces (?)

Anyhow, FYI.

Frank
FrankG
 
Posts: 210
Joined: Thu Jan 23, 2003 7:58 pm

Postby dewey on Fri Jun 23, 2006 2:28 am

This isn't a compiler issue, it is a runtime issue. If the first condition succeeds, you close the form. When you go to evaluate the second "if (pbIv.checked)", the form is already closed, so pbIv is no longer in the current form.
dewey
Site Admin
 
Posts: 749
Joined: Sun Oct 21, 2007 5:12 am

Postby FrankG on Fri Jun 23, 2006 1:24 pm

> This isn't a compiler issue, it is a runtime issue.

Dewey,

I guess I have to disagree. I don't think it's a runtime issue it's a programmer issue: Me. Duh -- sorry about that; I should have seen that!

Thank you,
Frank
FrankG
 
Posts: 210
Joined: Thu Jan 23, 2003 7:58 pm


Return to OrbForms Designer and PocketC Architect

Who is online

Users browsing this forum: No registered users and 2 guests

cron