• Welcome to Valhalla Legends Archive.
 

Running in IDE or NOT?

Started by TheMinistered, November 29, 2003, 10:32 PM

Previous topic - Next topic

TheMinistered

I have two methods of determining wether or not the application is running in IDE or not, and please feel free to post your own methods.  Here they are:


Function IsIDE() As Boolean
   On Error Goto IDE
   
   Debug.Print 1 / 0
   IsIDE = FALSE
   Exit Function

IDE:
   IsIDE = TRUE
   Exit Function
End Function


This function uses the known fact that the Debug.Print statement will not be executed in a compiled program, thus the Divide by Zero error is not triggered.  In conclusion, it's short and to the point.

However, it has one small drawback, sometimes the programmer may want to run a program in the IDE with the Break on ALL errors option.  The error will obviously be triggered when a call to this function is made.


Function IsIDE() As Boolean
   IsIDE = (App.EXEName = App.Title)
End Function


This function is yet another simple but effective method of testing if the program is in the IDE or NOT, and it avoids using error traps!

However, it requires that the programmer makes sure he compiles to an EXE name that is different from that of the Project name.

iago

hmm, in c/c++ you can do this:
#ifdef DEBUG
// we're in ide
#else
// we aren't
#endif

There might be a similar predefined variable in VB?  


And VB actually lets you compile a program that has an obvoius 1/0 in it?  Most compilers won't even let you try!
This'll make an interesting test for broken AV:
QuoteX5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*


Skywing

Quote from: iago on November 29, 2003, 10:37 PM
hmm, in c/c++ you can do this:
#ifdef DEBUG
// we're in ide
#else
// we aren't
#endif

There might be a similar predefined variable in VB?  


And VB actually lets you compile a program that has an obvoius 1/0 in it?  Most compilers won't even let you try!

Actually, it's

#ifndef NDEBUG
/* debug build */
#endif

This is unrelated to actually having a debugger attached.

iago

That's true, but generally you'll have a debug build well testing and a release bulid otherwise.
This'll make an interesting test for broken AV:
QuoteX5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*


Eibro

Eibro of Yeti Lovers.