home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!gatech!usenet.ins.cwru.edu!agate!dog.ee.lbl.gov!ucbvax!NSCVAX.PRINCETON.EDU!dragon
- From: dragon@NSCVAX.PRINCETON.EDU (Mighty Firebreather)
- Newsgroups: comp.os.vms
- Subject: RE: DCL symbols from an image
- Message-ID: <0096583D.BF8F7E60.30520@nscvax.princeton.edu>
- Date: 23 Dec 92 16:27:53 GMT
- Sender: usenet@ucbvax.BERKELEY.EDU
- Organization: The Internet
- Lines: 71
-
-
- Steve Shoecraft <SHOECRAFT@mc.maricopa.edu> writes:
-
- >
- > I am writing an application which must not only get symbols, but set DCL
- >symbols. I am unable to use the LIB$GET_SYMBOL and LIB$SET_SYMBOL services
- >because I need to be able to work with integers as well. Does anyone have an
- >example (C or MACRO) that does this? I would also like to be able to determine
- >whether the symbol was/is global or local on the get, and to specify global or
- >local on the set.
- >
-
- There is no documented and supported way to set symbols with an
- integer value. You use strings and convert in DCL if necessary.
-
- Here is an example that I wrote a year and a half ago to answer a
- related question. It's in Fortran, sorry about that. It's excessively
- commented so the general scheme should be clear.
-
- PROGRAM GET_SYMBOL
- C
- C Obtain the value of a DCL symbol, perform arithmetic on the value
- C and set the symbol to the new value.
- C
- C Richard B. Gilbert
- C Princeton University
- C Department of Mechanical and Aerospace Engineering
- C Engineering Quadrangle
- C Princeton, NJ 08544-5263
- C
- C (609) 258-6217
- C
- IMPLICIT NONE ! All variables must be declared.
- CHARACTER*11 SYMBOL ! The name of the symbol
- CHARACTER*128 RET_BUF ! String to hold the value
- INTEGER*4 NUMBER, ! The integer value of the symbol
- 1 TBL_IND, ! Indicates which table symbol was in.
- 2 RET_STATUS, ! Return status value
- 3 LIB$GET_SYMBOL, ! Function returns integer
- 4 LIB$SET_SYMBOL ! Function returns integer
- INTEGER*2 RET_LEN ! Length of the string in RET_BUF
- PARAMETER (SYMBOL = 'TEST_SYMBOL') ! Makes 'TEST_SYMBOL' a const.
- C Get the value of SYMBOL as a string in RET_BUF.
- RET_STATUS = LIB$GET_SYMBOL (SYMBOL, RET_BUF, RET_LEN, TBL_IND)
- C Be sure we were successful. Bomb out with a traceback if not.
- IF (.NOT. RET_STATUS) CALL LIB$STOP(%VAL(RET_STATUS))
- C Print the value of the symbol.
- WRITE (6, *) RET_BUF
- C Use the internal file feature in Fortran I/O to convert the
- C string to integer.
- READ (RET_BUF, *) NUMBER
- C Do some arithmetic on our hard won value.
- NUMBER=NUMBER*3+1
- C Use internal files again to convert integer back to string.
- WRITE (RET_BUF, *) NUMBER
- C Now set the symbol to its new (string) value.
- RET_STATUS = LIB$SET_SYMBOL (SYMBOL, RET_BUF, TBL_IND)
- C Check status to be sure nothing horrible happened.
- IF (.NOT. RET_STATUS) CALL LIB$STOP(%VAL(RET_STATUS))
- STOP
- END
-
-
- *************************************************************************
- * *
- * Here, there be dragons! *
- * dragon@nscvax.princeton.edu *
- * *
- * Richard B. Gilbert *
- *************************************************************************
-
-