Post Reply 
50g multiple output
12-06-2021, 05:59 PM
Post: #9
RE: 50g multiple output
Hi oierpa,

(12-05-2021 06:23 PM)oierpa Wrote:  ... Can you suggest me some readings, article, manual or website that explain a little more how variables are used inside program? ...

My answer to this was going to be very similar to the one from John Keith above, although his is more detailed. Smile

If you want to limit the amount of reading you need to do initially, I would say that the "Chapter 1: RPL Programming" and possibly "Chapter 2: Programming Examples" in the "HP 50g / 49g+ / 48gii Graphing Calculator Advanced User's Reference Manual" are essential reading.

I agree with John that the "HP 50g Graphing Calculator User's Manual" [and also the "HP 50g Graphing Calculator User's Guide"] are somewhat infuriating and that going back to a manual to a less evolved calculator in the line can be better. But rather than the manuals for the 48G, I would suggest that the manuals for the 48SX cannot be beaten for clarity and simplicity even though the calculator is less similar to the 50g.

(12-05-2021 06:23 PM)oierpa Wrote:  ... I understood that syntax I used is really wrong. ...

Not "really" wrong. I'd say you are more than 90% of the way there. Smile

(12-06-2021 02:36 PM)oierpa Wrote:  Hi all.
I made some test and I understood something more.
Here there is my program list:
Code:
<<"Ins C t A n" {
    ":C:
     :t:
     :A:
     :n:" {1 0} V} INPUT OBJ-> -> C t A n
     << t 100 / 'n' RCL / DUP 1+ 'n' RCL 
     'A' RCL * NEG ^ NEG 1 + / 'C' RCL * 
     'R' STO>>
      'n' RCL 'A' RCL *
      'R' RCL * "M" -> TAG 
      ->STR "
      " ->STR + 'R' RCL "R" -> TAG 
      ->STR +
      MSGBOX 'R' PURGE
       >>
With this syntax I can calculate and display 2 different result (obtained with the same input data). I used RPN and not Algebraic because when I try use this notation variables are changing.
Thanks to all that read and can suggest me something to do better programs.

* You don't need all those RCL statements. Instead of 'n' RCL just use n. ('n' (with quotes) evaluates to the name of the object and n (without quotes) evaluates to the value of the object.)

* You can still use your algebraic objects if you like. In a formula an algebraic can sometimes be more readable. Just remember that the scope of local variables is the following algebraic or program object so if you want the scope of you local variables to extend beyond one algebraic then you need an enclosing program object. Along these lines:

[NOTE: The calculator sadly does not support comments in programs, but I have sprinkled comments here introduced by semicolon characters.]

Code:
<<
; This section is usually used to set up the stack so that the local variables can be assigned from it.
-> a b c <<
    ; Your local variables a, b, and c are defined here.
    'some-algebraic'         ; Your local variables are still defined inside your algebraic.
    ; And they're still defined here.
    'another-algebraic'      ; And they're defined inside this algebraic too.
    ' And they're still defined here.
>> ; End of scope of local variables a, b, and c.
>> ; End of program

* You can avoid having 'R' being a global variable (which might overwrite an existing variable 'R' that you have outside your program) by introducing a new (inner) local variable scope for 'R'.

Code:
<<
; Get C, t, A, and n on the stack by whatever means (e.g. by your INPUT OBJ-> approach).
-> C t A n <<
    ; Code calculating R, using an algebraic or otherwise.
    -> R <<
        ; Code using C, t, A, n, and R goes here.
    >> End of scope of local variable R.
>> ; End of scope of local variables C, t, A, and n.
>> ; End of program

Or more simply, put a dummy value for R on the stack (such as 0) and create R in your initial set of local variables,

Code:
<<
; Get C, t, A, and n on the stack by whatever means (e.g. by your INPUT OBJ-> approach).
0                              ; Dummy value for R
-> C t A n R <<
    ; Code calculating R, using an algebraic or otherwise.
    'R' STO                    ; Replace value of the local variable R
    ; Code using C, t, A, n, and R.
>>  ; End of scope of local variables C, t, A, n, and R.
>>  ; End of program

N.
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
50g multiple output - oierpa - 12-03-2021, 03:43 PM
RE: 50g multiple output - DA74254 - 12-03-2021, 09:44 PM
RE: 50g multiple output - Joe Horn - 12-03-2021, 10:42 PM
RE: 50g multiple output - oierpa - 12-04-2021, 08:13 AM
RE: 50g multiple output - nlj - 12-05-2021, 02:35 PM
RE: 50g multiple output - oierpa - 12-05-2021, 06:23 PM
RE: 50g multiple output - John Keith - 12-06-2021, 12:39 PM
RE: 50g multiple output - oierpa - 12-06-2021, 02:36 PM
RE: 50g multiple output - nlj - 12-06-2021 05:59 PM
RE: 50g multiple output - oierpa - 12-10-2021, 06:53 PM
RE: 50g multiple output - nlj - 12-11-2021, 02:18 AM
RE: 50g multiple output - DavidM - 12-11-2021, 02:45 PM
RE: 50g multiple output - oierpa - 01-10-2022, 11:45 AM
RE: 50g multiple output - DavidM - 01-10-2022, 12:16 PM



User(s) browsing this thread: 1 Guest(s)