Thread Closed 
Reading one or two arguments
03-13-2021, 08:40 PM
Post: #2
RE: Reading one or two arguments
(03-13-2021 04:18 PM)HillyBoy Wrote:  Hi,

This is my first post on this forum. I have been using a HP-48GX for some 30 years now, but that died on me a few days ago. I replaced it with a HP-Prime and try to understand the current PPL language.

On my 48GX I had a small program that allowed me to convert a vector to its two arguments and vice versa. These vectors I use a lot in land-surveying: by switching from and to polar mode I can easily convert a coordinate-pair to distance and argument and vice versa (and add sets to each other). On the Prime I can do the same using a complex in the following notation: (a,b).

Starting point is one or two arguments on the stack.
The problem I now have is that after testing the first argument on the stack I need to make a decision:
IF TYPE(Arg1) == 0... I need to read to read Arg2 and return them as complex (Arg1, Arg2)
IF TYPE(Arg1) == 3... there is only one complex argument available, all I need to do is return its length and argument to the stack.

Reading two arguments is easy, provided they are available:
EXPORT MyProg(Arg1, Arg2)

But as I do not know in advance whether I can get 1 or 2 arguments, I need to start my program as

EXPORT MyProg(Arg1)

and test Arg1 first, before reading Arg2 when TYPE(Arg1)==0.

The other problem I have is how to return two arguments to the stack...

thanks in advance for your suggestions,
Nicolàs

If your calculator settings are in RPL mode, then a program can read stack values
with Ans(N). Where N is the stack number. This work in RPL mode only. The RPL mode
on the Prime is humbug. So if your are going continue with Prime, I strongly advice you to set it in Algebraic mode, if not buying a dedicated RPL calculator. Input to your Prime program when it is in algebraic mode should be done programmatically via the Input() function. Read up on this command in help.

The TYPE() and type() functions are unreliable to use. Because, they change as
the wind blows. Not only changes from shifting CAS/HOME, but also changes in
interaction with other functions in a program. And sometimes it spits out some
numbers and names than given in the help menu. For example, if your program
expects 0 for a float number, it sometimes give you a name; DOM_FLOAT.
Do this, EVAL(TYPE(MyARG)). By this a type name gets evaluated to a number.
This will ease type decision making in the program.

I' m trying out this calculator myself. It's a failure
Find all posts by this user
Thread Closed 


Messages In This Thread
Reading one or two arguments - HillyBoy - 03-13-2021, 04:18 PM
RE: Reading one or two arguments - essen - 03-13-2021 08:40 PM
RE: Reading one or two arguments - Han - 03-14-2021, 05:20 AM
RE: Reading one or two arguments - essen - 03-14-2021, 11:54 AM
RE: Reading one or two arguments - essen - 03-14-2021, 10:08 PM
RE: Reading one or two arguments - essen - 03-15-2021, 12:27 PM
RE: Reading one or two arguments - essen - 03-16-2021, 09:00 PM
RE: Reading one or two arguments - Gene - 03-17-2021, 08:55 PM



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