PJS@NAIF.JPL.NASA.GOV (Peter Scott) (04/23/88)
Okay, so I started to get into subroutines, everything was going great until I ran up against a problem that I boiled down to this: if I run the following command procedure: ------------------------------------------------------------------------ $ CALL a $ EXIT $ ! $ a: SUBROUTINE $ d = 1 $ loop: $ CALL c $ d = d + 1 $ GOTO loop $ EXIT $ ENDSUBROUTINE $ ! $ b: SUBROUTINE $ EXIT $ ENDSUBROUTINE $ ! $ c: SUBROUTINE $ EXIT $ ENDSUBROUTINE ------------------------------------------------------------------------ then after the line "CALL c", both d and loop are undefined (you can take loop out if you want, I was just illustrating that labels are affected too). However, if I remove subroutine B, everything goes swimmingly. (In the original file, B was called later on.) What is going on??? How can I lose the scope of my pseudo-procedure just by calling subroutine c? Should I write an SPR? Peter Scott (pjs%grouch@jpl-mil.jpl.nasa.gov)
bob@trojan (Bob Firestine) (05/03/88)
In article <880422114821.0000009E131@naif.JPL.NASA.GOV> PJS@NAIF.JPL.NASA.GOV (Peter Scott) writes:
+Okay, so I started to get into subroutines, everything was going
+great until I ran up against a problem that I boiled down to this:
+if I run the following command procedure:
+------------------------------------------------------------------------
+$ CALL a
+$ EXIT
+$ !
+$ a: SUBROUTINE
+$ d = 1
+$ loop:
+$ CALL c
+$ d = d + 1
+$ GOTO loop
+$ EXIT
+$ ENDSUBROUTINE
+$ !
+$ b: SUBROUTINE
+$ EXIT
+$ ENDSUBROUTINE
+$ !
+$ c: SUBROUTINE
+$ EXIT
+$ ENDSUBROUTINE
+------------------------------------------------------------------------
+then after the line "CALL c", both d and loop are undefined (you can
+take loop out if you want, I was just illustrating that labels are
+affected too). However, if I remove subroutine B, everything goes
+swimmingly. (In the original file, B was called later on.)
+
+What is going on??? How can I lose the scope of my pseudo-procedure
+just by calling subroutine c? Should I write an SPR?
+
+Peter Scott (pjs%grouch@jpl-mil.jpl.nasa.gov)
+
I had a similar problem in 7/87 so I called DEC. If you call a subroutine,
and there is another subroutine between the caller and callee, then you lose
the local symbols in the calling routine. I was told that the problem
still existed in 4.6. We aren't running 4.7 yet so I don't know if it's
fixed yet. The workaround I used: Put the subroutines at the top of my
command procedure.
-------------------------------------------------------------------------------
Bob Firestine firestine@M_sjs.sdr.slb.com
Schlumberger Technologies bob%sjsca4@spar.slb.com
1601 Technology Drive
San Jose CA 95115
408-437-5216