The Museum of HP Calculators

HP Forum Archive 08

[ Return to Index | Top of Index ]

Programming trouble
Message #1 Posted by ResO on 22 June 2002, 7:36 a.m.

hello can t save any programmed program. simple example: << -> A B 'A-B'>> STO TEST errormessage: "A" Invalid Syntax

why doesnt work that? i hope anybody can help me

      
Re: Programming trouble
Message #2 Posted by Christof (Davis, CA) on 22 June 2002, 2:03 p.m.,
in response to message #1 by ResO

If I'm reading you properly, you are pressing buttons in the wrong order.

<<

->

a

b

( <<operation of some sort>> )

ENTER

TEST

STO

>>

-Christof

      
Re: Programming trouble
Message #3 Posted by Vieira, Luiz C. (Brazil) on 22 June 2002, 8:46 p.m.,
in response to message #1 by ResO

Hi;

Try this sequence:

<< -> A B 'A-B' >>

[ENTER] 'TEST' [STO]

If you want, try also this:

<< -> A B << A B - >> >>

[ENTER] 'TEST' [STO]

Both should work.

I believe you forgot a 'TEST' in your typing, betwen >> and [STO]. Anyway, before executing your program (TEST) you should supply A and B values: say, 2 [ENTER] 3 [TEST].

One point I did not get: the "A" Invalid Syntax message. Does it appear when you try to store the program or whern you execute it? If you store it successefuly, there are no syntax errors. If the message appears when you try using it, the only reasonable explanation is the previous existence of an A-variable with some object already stored in it. And it must be in the "working" directory OR IN ANY UPPER (FATHER) ONE. Check for its existence!

Hope it helps.

Cheers.

            
Re: Programming trouble
Message #4 Posted by ResO on 23 June 2002, 5:15 a.m.,
in response to message #3 by Vieira, Luiz C. (Brazil)

thanx for answering my question.

i ve found the problem. if i programm it in the RPN Mode, it will work... but why doesnt work it on algebraic mode???

                  
Re: Programming trouble
Message #5 Posted by Ellis Easley on 23 June 2002, 7:51 a.m.,
in response to message #4 by ResO

I just happened to stumble on the answer to your question - shows how to do it in RPN and algebraic. Here is the link to hp.com - HP 48G Series and HP 49G Calculators - Storing and Recalling an Equation. The HP website has a few things in FAQs for each calculator, but if you use the search with a model (like "hp49g") and a keyword (I used "solver" to get this one) there are more articles.

                        
Re: Programming trouble - the other half
Message #6 Posted by Ellis Easley on 25 June 2002, 12:58 p.m.,
in response to message #5 by Ellis Easley

I'm just learning to use my new 49G and I see that the info I pointed to on the HP website only tells how to save something in RPN or algebraic mode. Even though the article is written for an equation the instructions for saving apply to a program as well. To figure out how to execute the program in either RPN or algebraic mode, I had to resort to reading the manual. It is very brief but if I keep in mind what the manual says it is at the beginning - a wide ranging INTRODUCTION to features and functions - it's pretty good. Anyway, section 10 - Programming tells in the first few pages how to write, save, and run a program, but only in algebraic mode. Since Christof and Luiz showed how to do it in RPN mode (the manual tells you to look on the internet for RPN instructions!), now I think I have a good start. It seems peculiar compared to RPN but to run a program in algebraic mode you have to treat it like a Basic function - put the parameters in parentheses separated by commas. Undoubtedly the algebraic interpreter is pushing the parameters on the stack "for you". So to run the example in algearaic mode:

TEST(x,y)[enter]

in RPN mode:

x [enter] y [enter] TEST [enter]

or, if "TEST" is in the menu line:

x [enter] y [TEST]

Algebraic is more work especially because parentheses and comma are shifted keys.

I think the reason I never made any progress with the 28 or the 48 is I never got straight in my mind what type of object each of the different delimiters is for. I'm going to make myself a 3X5 card spelling it out and then see how I do with the 49G. (Now that I think of it, the 28 might have had that printed on the left keyboard - but writing it is a good way to impress it on the memory.)

                              
Re: Programming trouble - the other half
Message #7 Posted by Ellis Easley on 25 June 2002, 1:14 p.m.,
in response to message #6 by Ellis Easley

I used "x" and "y" out of habit in my examples but now I wonder: assuming that in algebraic mode, the 49g is pushing the parameters on the stack, does it start with the parameter on the left or the right? And how does that relate to the list of local variables in the program? That doesn't seem to be spelled out in the first few pages of section 10 of the manual, although page 10-5 does tell the difference in how you run a program in RPN vs. algebraic mode.

                                    
Re: Programming trouble - the other half
Message #8 Posted by Christof (Davis, CA) on 25 June 2002, 1:31 p.m.,
in response to message #7 by Ellis Easley

I haven't gotten into the 49g much yet- I'm sort of going in a combination of history and power as I sit through a mostly boring summer term.

(I'm about done playing with the 20s, it's programmable, but limited almost painfully. The 32sii will be put on the shelf as a backup in about another week and I'll just use a 42s for pocket. for RPL I'm mostly using the 28s right now instead of the 48sx. I suppose I'll move on to the 49g for actual carrying around sooner or later- it runs emacs, after all)

Delimiters I somehow just used until I knew them insternally- I guess this is what me constantly writing dozens of "useless" little programs is for :)

There may be some info on area48.com, though I think the best bet would be to put the questions on the newsgroup. I'll keep an eye out as I haven't looked at the algebraic programming at all.

-C

                                          
Algebraic, RPN... Pick one.
Message #9 Posted by Vieira, Luiz C. (Brazil) on 25 June 2002, 10:25 p.m.,
in response to message #8 by Christof (Davis, CA)

Hi;

may I point some things out?

Since the very appearance of the HP28 (C, remember?), the algebraic X RPN/RPL quiz became one of my personal battles. Which one to use? (a bit off topic, but more than that, defining our own unit as a new algebraic object amused me, too)

When I write programs for any RPL calc I use as much algebraic as comprehension is required, so I myself am able to understand my own programs later. Using algebraic expressions as program resource is, sometimes, a must. I completely agree with many contributors in here that state that extensive use of RPL, mostly stack manipulations, will cause a program to be unreadable and hard to understand. I have programs written some years ago I cannot easily change or add features, because I simply do not remember what the h... that ROLLD or PICK use as parameter, so I must step through almost all the program to get to the point and find out the parameter value. Gee!

And when previous stack contents are needed and the programmer (me) did not use local variables? Who in Heaven can tell? If a simple

 << -> A B C << .... >>  >>
is there, no matter at all! In this case, using
value [ENTER] value [ENTER] value [ALPHA] [ALPHA] program_name [ENTER]
is easy. Also, using algebraic feature (since the HP28), we have:
[ALPHA] [ALPHA] program_name[(] value [SPC] value [SPC] value [ALPHA] [ENTER]
. Both will work fine. What matters is, for me, how to handle them inside the inner << and >>.

When only 4-plus-1 level RPN calcs were available, anything should "chronometrically" fit in the stack. Debugging was easier, mostly because T-values were simply lost OR duplicated (how I miss this duplication sometimes...). Some new RPL features for handling objects in the stack are very important tools, but also more data to process (in our brain).

Wanna know? The fact is that programming them all is still funny. After all.

Comments? Corrections? All wellcome.

Cheers.

(Hey, Mr. Belillo; proud of me?)

                                                
Re: Algebraic, RPN... Pick one.
Message #10 Posted by Ellis Easley on 26 June 2002, 12:54 p.m.,
in response to message #9 by Vieira, Luiz C. (Brazil)

I am a little confused because the manual says it only covers algebraic mode usage but (thankfully!) throws in a little RPN mode.

I followed your suggestions and experimented with simple programs that do the same thing in RPN or algebraic. I see that the syntax of elementary operations as well as functions like SIN depend on whether they are inside ' ' or << >>. I also see that I can run either type of program with the calculator in algebraic or RPN mode, as long as I pass the parameters correctly. Is it correct to think that while a program is running, the calculator essentially switches to algebraic mode when it encounters the ' ' delimiters, and switches to RPN mode for << >> delimiters?

                                                      
Re: Algebraic, RPN... Pick one.
Message #11 Posted by Vieira, Luiz C. (Brazil) on 26 June 2002, 4:44 p.m.,
in response to message #10 by Ellis Easley

Hi;

I work with computer architecture (no deep knowledge, only enough to teach elementary structure) and I know Von Newman's based machines essentially work in a RPN-fashion arithmetic, say, operands first, operation last (even if the mnemonics predicts ADD A,#200 the addition is the last thing to be performed). I read here, at this very Forum and more than once, that even Algebraic-only calculators (Casio, TI, and others) must stack algebraic tokens first (Katie mentioned this technique in previous recent threads), so error checking and performing operations take place.

The HP49 is not an exception, mostly because it uses both operative paradigms. Dealing with operands and operations in RPN fashion is natural for the processor. I would go farther (but I am not completely confident) if telling you that the O.S. disassembles algebraic objects into RPN procedures, and never switches to an algebraic internal mode. But I'll wait for the guys who can tell it better.

Hope it helps.

(Suggestions, comments, always welcome)

                                          
Re: Programming trouble - the other half
Message #12 Posted by Ellis Easley on 26 June 2002, 12:15 p.m.,
in response to message #8 by Christof (Davis, CA)

Christof wrote:

"I guess this is what me constantly writing dozens of "useless" little programs is for :)"

I know that's what it takes - practice makes perfect - and the Forum provides plenty of examples to try.

                                                
Re: Programming- the other half
Message #13 Posted by Christof (Davis, CA) on 27 June 2002, 12:43 p.m.,
in response to message #12 by Ellis Easley

And I've gone insane!

Some parts of my current classes are just boring enough that I've written a working low grade (*extremely* low grade, like late 19th century) crypto handler for the 20S, as well as a decently useful multi-sided die roller.

I'd almost be embarrassed to post them, it's such simple stuff.

-C


[ Return to Index | Top of Index ]

Go back to the main exhibit hall