Post Reply 
Return multiple values on multiple stack lines
03-13-2014, 04:04 AM
Post: #1
Return multiple values on multiple stack lines
Hi all,
I've recently bought an HP Prime as a replacement for my aging 48GX. I have quite a number of small programs on the 48 that I would like to implement on the Prime.
My question is, how do I return multiple values to multiple lines on the stack (I use RPN mode)? So far, programs only return the result of the last line of code.

Here's my example, it's to calculate coordinates of the tangent point and intersection point for a conveyor belt layout. I'd like to return both TP and IP to lines 1 and 2 of the stack.

EXPORT TPIP(alpha1, alpha2, Radius)
BEGIN

LOCAL TP, IP, shift, TPx, TPy, IPx, IPy;

// Determine of radius is concave or convex
IF alpha2 > alpha1 THEN shift:=270
ELSE
shift:= 90
END;

// Determine coordinates of the tangent point and the intersection points
TPx:= Radius*(COS(alpha2+shift)-COS(alpha1+shift));
TPy:= Radius*(SIN(alpha2+shift)-SIN(alpha1+shift));
IPx:= (TPy-TAN(alpha2)*TPx)/(TAN(alpha1)-TAN(alpha2));
IPy:=IPx*TAN(alpha1);

// Return the values to the stack
TP:=(TPx,TPy);
IP:=(IPx,IPy);

END;

any help appreciated,
Andrew
Find all posts by this user
Quote this message in a reply
03-13-2014, 06:15 AM
Post: #2
RE: Return multiple values on multiple stack lines
Hi Andrew,

The only way I know of is to use a list.

RETURN({TP,IP});

There are other posts on this board discussing this so you might want to do a
search for them. Maybe this will looked into for a possible update.

Hope this helps.
Jim
Find all posts by this user
Quote this message in a reply
03-13-2014, 06:27 AM
Post: #3
RE: Return multiple values on multiple stack lines
(03-13-2014 06:15 AM)JimS Wrote:  Hi Andrew,

The only way I know of is to use a list.

RETURN({TP,IP});

There are other posts on this board discussing this so you might want to do a
search for them. Maybe this will looked into for a possible update.

Hope this helps.
Jim

Thanks Jim,
I'll see if that works for me.
Find all posts by this user
Quote this message in a reply
Post Reply 




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