Return multiple values on multiple stack lines
03-13-2014, 04:04 AM
Post: #1
 ahall Junior Member Posts: 3 Joined: Mar 2014
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.

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
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
03-13-2014, 06:15 AM
Post: #2
 JimS Junior Member Posts: 9 Joined: Feb 2014
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
03-13-2014, 06:27 AM
Post: #3
 ahall Junior Member Posts: 3 Joined: Mar 2014
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.
 « Next Oldest | Next Newest »

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