home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / os / vms / 19845 < prev    next >
Encoding:
Internet Message Format  |  1992-12-24  |  3.4 KB

  1. Path: sparky!uunet!gatech!usenet.ins.cwru.edu!agate!dog.ee.lbl.gov!ucbvax!NSCVAX.PRINCETON.EDU!dragon
  2. From: dragon@NSCVAX.PRINCETON.EDU (Mighty Firebreather)
  3. Newsgroups: comp.os.vms
  4. Subject: RE: DCL symbols from an image
  5. Message-ID: <0096583D.BF8F7E60.30520@nscvax.princeton.edu>
  6. Date: 23 Dec 92 16:27:53 GMT
  7. Sender: usenet@ucbvax.BERKELEY.EDU
  8. Organization: The Internet
  9. Lines: 71
  10.  
  11.  
  12.     Steve Shoecraft <SHOECRAFT@mc.maricopa.edu> writes:
  13.  
  14. >
  15. >    I am writing an application which must not only get symbols, but set DCL
  16. >symbols.  I am unable to use the LIB$GET_SYMBOL and LIB$SET_SYMBOL services
  17. >because I need to be able to work with integers as well.  Does anyone have an
  18. >example (C or MACRO) that does this? I would also like to be able to determine
  19. >whether the symbol was/is global or local on the get, and to specify global or
  20. >local on the set.
  21. >
  22.  
  23.     There is no documented and supported way to set symbols with an
  24. integer value.  You use strings and convert in DCL if necessary.
  25.  
  26.     Here is an example that I wrote a year and a half ago to answer a
  27. related question.  It's in Fortran, sorry about that.  It's excessively 
  28. commented so the general scheme should be clear.
  29.  
  30.       PROGRAM GET_SYMBOL
  31. C
  32. C     Obtain the value of a DCL symbol, perform arithmetic on the value
  33. C     and set the symbol to the new value.
  34. C
  35. C    Richard B. Gilbert
  36. C    Princeton University
  37. C    Department of Mechanical and Aerospace Engineering
  38. C    Engineering Quadrangle
  39. C    Princeton, NJ 08544-5263
  40. C
  41. C    (609) 258-6217
  42. C
  43.       IMPLICIT NONE        ! All variables must be declared.
  44.       CHARACTER*11 SYMBOL    ! The name of the symbol
  45.       CHARACTER*128 RET_BUF    ! String to hold the value
  46.       INTEGER*4 NUMBER,     ! The integer value of the symbol
  47.      1          TBL_IND,     ! Indicates which table symbol was in.
  48.      2        RET_STATUS,    ! Return status value
  49.      3         LIB$GET_SYMBOL,    ! Function returns integer
  50.      4        LIB$SET_SYMBOL    ! Function returns integer
  51.       INTEGER*2 RET_LEN        ! Length of the string in RET_BUF
  52.       PARAMETER (SYMBOL = 'TEST_SYMBOL') ! Makes 'TEST_SYMBOL' a const.
  53. C     Get the value of SYMBOL as a string in RET_BUF.
  54.       RET_STATUS = LIB$GET_SYMBOL (SYMBOL, RET_BUF, RET_LEN, TBL_IND)
  55. C     Be sure we were successful.  Bomb out with a traceback if not.
  56.       IF (.NOT. RET_STATUS) CALL LIB$STOP(%VAL(RET_STATUS))
  57. C     Print the value of the symbol.
  58.       WRITE (6, *) RET_BUF
  59. C     Use the internal file feature in Fortran I/O to convert the
  60. C     string to integer.
  61.       READ (RET_BUF, *) NUMBER
  62. C     Do some arithmetic on our hard won value.
  63.       NUMBER=NUMBER*3+1
  64. C     Use internal files again to convert integer back to string.
  65.       WRITE (RET_BUF, *) NUMBER
  66. C     Now set the symbol to its new (string) value.
  67.       RET_STATUS = LIB$SET_SYMBOL (SYMBOL, RET_BUF, TBL_IND)
  68. C     Check status to be sure nothing horrible happened.
  69.       IF (.NOT. RET_STATUS) CALL LIB$STOP(%VAL(RET_STATUS))
  70.       STOP
  71.       END
  72.  
  73.  
  74. *************************************************************************
  75. *                                                                       *
  76. *                        Here, there be dragons!                        *
  77. *                      dragon@nscvax.princeton.edu                      *
  78. *                                                                       *
  79. *                                                Richard B. Gilbert     *
  80. *************************************************************************
  81.  
  82.