# HP Forums

Full Version: Help Luiz, Please..
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

Having separated NE and 34.2345 from "N34.2345E" to get :
34.2345 "NE", I need a some more help.

I further need to do the following:

If NE then, leave as is;
if NW then NEG 360 HMS+;
if SW then 180 +;
if SE then NEG 180 +

How can I add all these clauses into one test clause. I am really having problems.

Actually, I am trying to write a program [with great difficulty] that converts quadrant bearings to Whole Circle bearings [ clockwise from north ].

Rick,

I don't know what you are trying to do but the conversation is interesting and reminds me of things done many years ago. I also don't know if you are in control of your environment but the use of N34.2345E for a bearing is rather inconvenient. NE34.2345 is easier because you only make one transfer from the alphabetic keyboard to the numeric, and most surveyors would prefer using numeric codes for the quadrants where 1 is NE, 2 is SE, 3 is SW, and 4 is NW. If numeric quadrants are used then you never have to use anything but the numeric keypad. This can simplify this whole process quite a lot. Since bearings only have degrees up to 90 (two digits) then they can be expressed as Q.ddmmss, where Q is the quadrant number. The quadrant can then be separated by using the interger portion of the number and assigning it to a variable (Q=1). The remaining fractional part of the number can be multiplied by 100 to get the bearing numbers (B)as you have listed them (B=34.2345). The bearing numbers can then be modified through a series of tests (if Q=2 then B=180-B, if Q=3 then B=180+B, if Q=4 then B=360-B). Of course if Q=1 then you don't have to do anything. This will result in a north azimuth in degrees, minutes, seconds clockwise format.

I wouldn't do it quite like this because I would also want to do some checking for an illegal quadrant number. I would also have an if statement for Q=1 and in all cases would transfer to a different part of the program so that if Q was not equal to 1-4 then I would continue into an error blocking statement.

Of course you can use the built in conversion to decimal degrees (HR) or the HMS+ and HMS- if you are going to do calculations with the angles.

Again maybe you don't have any control over the format of the bearings being input, in which case the testing will have to be done on an alphabetic character match instead. If you have control over the input then you will find the numeric quadrants much faster and more accurate.

Best Regards and don't give up.

Forrest

Hi, Rick; sorry taking too long (I just accessed www right now).

I remember dealing with Survey programs some time ago (about twelve years or more) and I am aware of what you want, I guess. There is a CASE structure that may be of help (any HP48 or HP49). The CASE is like this:

```CASE
test1 THEN action if test1 is true END
test2 THEN action if test2 is true END
.
.
.
default action if no test is true (optional)
END```
By using RPL and operations directly in stack contents is also easy, but demands a bit of "daring". So, using CASE, you can try this: (consider you have the resulting values from previous sequence, meaning number in level two and quadrant identifier in level 1)
```.
.
.
-> QI
« CASE QI "NW" == THEN NEG 360 HMS+ END
QI "SW" == THEN 180 + END
QI "SE" == THEN NEG 180 HMS+ END
END QI
» ```

After this, you'll have the quadrant identifier back to level 1 and the correct bearing in level 2. If you want to discard the quadrant identifier, simply suppres the las QI (after the last END).

Hope this helps. In fact, I did not test it, I just wrote it in a rush to answer you. If it does not work, please, post again.

Cheers.

Luiz (Brazil)

Edited: 4 Jan 2005, 10:42 p.m.

Thanks again Luiz. That's it as usual. Have a great day.

Hi, Rick; I'm glad it fit your needs (so far).

I'll write a no CASE...END, stack-only solution later so you can compare.

BTW, if you need more help/advice and want an off-line discussion for your program, be my guest: lcvieira at quantica dot com dot br (this avoids some SPAM engines...). Later you can share it as a final solution. I'm not entirely "on vacations", but I'll find some time to program. In fact, it's a relaxation time...

Best regards.

Luiz (Brazil)