I would rather write:

if {[info exists ::vTcl(sourcing)]} {
     ## project is being loaded by vTcl
...
}

This variable exists when Visual Tcl is loading a project.

Future versions of Visual Tcl will make use of the ::vTcl
namespace (it's already the case for tooltips in the CVS),
so it is safer to use the above test.

CG



|--------+------------------------------------->
|        |          Rick Macdonald             |
|        |          <[EMAIL PROTECTED]>            |
|        |          Sent by:                   |
|        |          [EMAIL PROTECTED]|
|        |          eforge.net                 |
|        |                                     |
|        |                                     |
|        |          08/17/2001 08:43 PM        |
|        |          Please respond to vtcl-user|
|        |                                     |
|--------+------------------------------------->
  
>-----------------------------------------------------------------------------------------------------------|
  |                                                                                    
                       |
  |       To:     [EMAIL PROTECTED]                                      
                       |
  |       cc:                                                                          
                       |
  |       Fax to:                                                                      
                       |
  |       Subject:     Re: [vtcl-user] Operational problem                             
                       |
  |                                                                                    
                       |
  
>-----------------------------------------------------------------------------------------------------------|




On Mon, 13 Aug 2001, John Coppens wrote:

> Hi all.
>
> I'm just starting to get a hang of some of the beautifull things of vTcl.
Here's
> a problem though:
>
> I've made a small editor which loads macros from a default file and adds
them
> to one of the menu items in the menu bar. Not knowing better, I put this
code
> in the 'init' proc. It works just fine.
>
> Except, that when I load the code into vTcl, this code also executes, and
as such
> modifies the menu item. vTcl then wants to save this as a program
modification to
> disk.
>
> Any idea how to avoid this?

You can detect when you're in the vTcl environment:

proc init {argc argv} {

   # Init stuff goes here...

   if {[info exists ::vTcl]} {
       # The code following this point isn't meant to be runable within
vTcl
       return
   }

   # Your macros go here...

}
...RickM...


_______________________________________________
vtcl-user mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/vtcl-user




_______________________________________________
vtcl-user mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/vtcl-user

Reply via email to