Post Reply 
Returning multiple numbers onto the stack
11-10-2014, 03:37 PM (This post was last modified: 11-11-2014 05:26 AM by jayhawk.)
Post: #4
RE: Returning multiple numbers onto the stack
(10-30-2014 02:42 PM)Jm9301 Wrote:  I have what I am sure may seem like a rather simple question to most of you I am sure.

I am a surveyor, and am working on several different ways of calculating points with my prime. I love the calculator, and it is quite the discussion piece amongst surveyors to say the least.

An example of my problem is outlined here:

EXPORT Traverse (n, e, ang, dist)

BEGIN
LOCAL a,b;

a:= cos(ang)*dist;

b:= sin(and)*dist;

return (n+a,e+b);

END;


Now this returns me Coordinates in the format (xxxxxx.xxx , yyyyyy.yyy) Which is ok, but i would like to have them as separate numbers on the stack for traversing forward. I have tried using multiple Return statements, tried all kinds of things but i cannot seem to get it down. please help!

Until HP updates the firmware of the Prime to give access to he stack, this might be helpful:
You want to pass N, E, Ang and Dist to Your program for calculating a new N and E.
And You want to only have to enter a new Ang and Dist to Traversing.

Try this:

Code:

EXPORT Traverse(ne,ang,dist)
BEGIN
  LOCAL n,e;

  n:=ne(1)+cos(ang)*dist;
  e:=ne(2)+sin(ang)*dist;
  return {n,e};
END;

Hope this helps
[edit]
NB! Be sure to be in RPN mode, so your program takes its arguments from the stack.
Also read Han's post below on handling lists and how to enter lists from keyboard.
An example running the program:
First run:
n=0
e=0
ang=45
dist=100

enter this
{0,0} <enter>
45 <enter>
100 <enter>
Traverse <enter> (You can define a user key for this)

now {new n, new e} wil be on stack level 1, so to traverse just enter:
next ang <enter>
next dist <enter>
Traverse <enter>

and so on...
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Returning multiple numbers onto the stack - jayhawk - 11-10-2014 03:37 PM



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