realbasic-nug
[Top] [All Lists]

Error loop prevention?

To: REALbasic Network Users Group <realbasic-nug@lists.realsoftware.com>
Subject: Error loop prevention?
From: Markus Winter <markus_winter@online.de>
Date: Thu, 30 Apr 2009 08:20:47 +0200
Authentication-results: mx.google.com; spf=neutral (google.com: 74.124.194.228 is neither permitted nor denied by best guess record for domain of realbasic-nug-bounces@lists.realsoftware.com) smtp.mail=realbasic-nug-bounces@lists.realsoftware.com
Delivered-to: listarchive@realsoftware.com
Reply-to: REALbasic NUG <realbasic-nug@lists.realsoftware.com>
Sender: realbasic-nug-bounces@lists.realsoftware.com
Thread-index: AcnJW8yvC0BOrDVPEd6dRAAX8sP4eQ==
Thread-topic: Error loop prevention?
User-agent: Microsoft-Entourage/11.4.0.080122
Hi all,

I have some checkboxes which result in the execution of shell commands. Now
if for whatever reason the shell can¹t execute the command then an error
should be reported and the checkbox state set back to it¹s previous state.
To prevent the creation of an endless error loop I do it with the help of a
boolean property called ResetState

  if ResetState then  // otherwise an error will cause the code to run again
causing another error -> error loop trap
    
    ResetState = false
    
  else
    
    dim s as Shell = new Shell
    
    s.Mode = 0
    
    
    if me.Value then
      s.Execute "something"
    else
      s.Execute "something else"
    end if
    
    
    if s.errorCode <> 0 then  // didn't work
      MsgBox kErrorCode    // give an error
      ResetState = true
      me.Value = not me.Value  // reset checkbox
    end if
    
  end if

But this seems kind of inelegant. Is there a better way?

Thanks

Markus
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>


<Prev in Thread] Current Thread [Next in Thread>
  • Error loop prevention?, Markus Winter <=