Return multiple values on multiple stack lines - Printable Version +- HP Forums (https://www.hpmuseum.org/forum) +-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html) +--- Forum: HP Prime (/forum-5.html) +--- Thread: Return multiple values on multiple stack lines (/thread-891.html) |
Return multiple values on multiple stack lines - ahall - 03-13-2014 04:04 AM 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 RE: Return multiple values on multiple stack lines - JimS - 03-13-2014 06:15 AM 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 RE: Return multiple values on multiple stack lines - ahall - 03-13-2014 06:27 AM (03-13-2014 06:15 AM)JimS Wrote: Hi Andrew, Thanks Jim, I'll see if that works for me. |