[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference vaxaxp::vmsnotes

Title:VAX and Alpha VMS
Notice:This is a new VMSnotes, please read note 2.1
Moderator:VAXAXP::BERNARDO
Created:Thu Jan 23 1997
Last Modified:Fri Jun 06 1997
Last Successful Update:Fri Jun 06 1997
Number of topics:703
Total number of notes:3722

187.0. "Global symbol question in DCL" by CSC32::WATERS (The Agony of Delete) Wed Feb 12 1997 16:30

    I have a question on global symbols.
     
     If I define a global symbol, X==1 at the local command prompt,
    then spawn and redefine that symbol to a new value, X==2, upon
    logout the global symbol is at it's orginal value of 1.
    
    $ x==1                or           $ spawn
    $ spawn                            $ x==2
    $ x==2                             $ logout
    $ logout                           $ sho sym x
    $ sho sym x                          %DCL-W-UNDSYM
      x==1
    
    I tried to find any documentation about this behavior. All I found is
    in "Writing Real Programs in DCL" that global symbols should be
    used within procedures, because of the procedure levels with local
    symbols.
    
    Is it that lower level global symbols are not inherited/passed back
    to upper process levels ??
    
    Any ideas, how to get global symbol definitions back to the parent 
    process ?  
    Thanks  -  Mark
T.RTitleUserPersonal
Name
DateLines
187.1Seperate Process...XDELTA::HOFFMANSteve, OpenVMS EngineeringWed Feb 12 1997 17:2120
   It's a seperate process -- symbols and logicals are (usually) copied
   from parent process to the child process when the spawn is performed,
   but are not copied (back) when the process logs out.

   The mechanism used to copy the symbols and logicals into the new
   subprocess is one of the reasons why the OpenVMS process creation can
   take so long...

   Also see EPS::COMMAND_PROCEDURES for DCL questions.

:    I tried to find any documentation about this behavior. All I found is
:    in "Writing Real Programs in DCL" that global symbols should be
:    used within procedures, because of the procedure levels with local
:    symbols.

   I'd be happy to get any text in this book that confuses you updated
   for the second edition -- send me the page number, and the confusion,
   via e-mail.

187.2MILORD::BISHOPThe punishment that brought us peace was upon HimWed Feb 12 1997 17:2214
    yes you're right...all symbols (local and global) are inherited by the
    subprocess (unless you specificallysay you don't want that to happen).
    No symbols are propagated back to the parent process when you logout
    the subprocess.
    
    global symbols are useful for making symbols visible to an outer
    command level (procedure or $-prompt) within the same process. But
    there are gotchas even then if you mix local and global symbols of the
    same name (been there, done that).
    
    For what you want, I'd suggest a job logical name. Probably other ways
    too, but that is the simplest I think.
    
    - Richard.
187.3OUCH!WHOS01::BOWERSDave Bowers, NSIS/IMWed Feb 12 1997 18:5416
    >> there are gotchas even then if you mix local and global 
    >> symbols of the same name
    
    I've still got a hole in my foot from a recent excursion down that
    path. The inner command level may create a global symbol, but a local
    symbol at the outer level hides it. You can easily create this masking
    symbol by simply assigning a value to the name with a single equal
    sign. For instance:
    
    	foo = f$edit(foo,"UPCASE")  !where foo is (or was) a global symbol
    
    Once you've done this, ALL references to "foo" in the outer command
    level yield the same value, regardless of changes to the global symbol
    by an inner command level.
    
    \dave