Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!mips!spool.mu.edu!cs.umn.edu!uc!noc.MR.NET!gacvx2.gac.edu!hhdist From: TDSTRONG%MTUS5.BITNET@VM1.NoDak.EDU (Tim Strong) Newsgroups: comp.sys.handhelds Subject: RE: HP-48 programming problem Message-ID: Date: 9 Apr 91 18:00:38 GMT Lines: 52 Return-path: <@VM1.NoDak.EDU:TDSTRONG@MTUS5.BITNET> In-reply-to: Your message of Tue, 9 Apr 1991 09:20 CST To: handhelds@gac.edu > >I had a problem debugging a program today, and I was wondering if anyone >had encountered the same problem before. The problem isn't a bug, but >it is annoying behavior. > >Suppose you have the following variables: > >P1: \<< \-> a \<< 'a' INC \>> \>> >INC: \<< \-> a \<< a INCR DROP \>> \>> > >Executing 5 P1 gives INCR Error: Bad Argument Type. >If you change the local variable in either of the programs to something >different, you get 6, as you would expect. Apparently, INC thinks >that the 'a' on the stack refers to the innermost local variable, >rather than the one belonging to P1. If this behavior is documented >in the manuals, I haven't seen it. It looks like all you are tying to do is pass the current value of 'a' in P1 to the 'a' in INC. If that is what you're doing whats wrong with P1: /<< /-> a /<< a INC />> removing the ''s around the a the 48 recalls the value of a to the stack where the second program picks it up. The problem is not that the machine thinks you are referring to the value of 'a' in P1 it thinks you are referring to the name 'a' you have put on the stack. Thus in the second program the machine sees 1: 'a' -> a thats like saying 'a' 'a' STO. Store 'a' into itself doesn't make much sense. Incidentally if you rename one of the two local variables its fine because the HP sees 1: 'b' -> a So 'b' gets stored into 'a' and the EVAL works down the chain and eventually recalls the value of 'b'. I hope that explains the problem. And I hope I've understood the problem If not (and since I'm kinda dense sometimes I probably haven't) just scream. And I or someone else will give another shot. ====================================================================== ___ I__) _ _I _ _ TIM STRONG I \ (_I (_I (_I I MICHIGAN TECH. HOUGHTON, MICHIGAN ======================================================================