HP Forums

Full Version: HP 50g Format Sexagesimal Output
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello,

This post is meant to correct my erroneous code posted on 06-29-2014, thread
HP 50g Surveyor's Stuff. The code does not cover all situations where there are
sixty seconds displayed, which is not allowed in sexagesimal measurement. I
would appreciate any help concerning my thought process and code.

// Format sexagesimal output
\<< 4 RND \->STR DUP
SIZE
\<< "59" SAME // check for 59 minutes
\<< STR\-> CEIL \->STR // add 1 degree
\>>
\<< STR\-> .01 + \->STR // add 1 minute
\>> IFTE
\>> \-> str size Degmin
\<<
CASE size 6 ==
THEN str 5 6
SUB "60" SAME // check for 60 seconds
\<< str 5 "00"
REPL DUP 3 4 SUB
Degmin EVAL
\>>
\<< str
\>> IFTE
END size 7 ==
THEN str 6 7
SUB "60" SAME // check for 60 seconds
\<< str 6 "00"
REPL DUP 4 5 SUB
Degmin EVAL
\>>
\<< str
\>> IFTE
END size 8 ==
THEN str 7 8
SUB "60" SAME // check for 60 seconds
\<< str 7 "00"
REPL DUP 5 6 SUB
Degmin EVAL
\>>
\<< str
\>> IFTE
END
END
\>>
\>>

checksum: # A374h
bytes: 508.5

Regards,

Mark
With [code ] tags around the listing, the text looks nicer.

(04-26-2015 02:59 PM)MNH Wrote: [ -> ]Hello,

This post is meant to correct my erroneous code posted on 06-29-2014, thread
HP 50g Surveyor's Stuff. The code does not cover all situations where there are
sixty seconds displayed, which is not allowed in sexagesimal measurement. I
would appreciate any help concerning my thought process and code.

Code:
// Format sexagesimal output
\<< 4 RND \->STR DUP
SIZE
  \<< "59" SAME   // check for 59 minutes
      \<< STR\-> CEIL \->STR   // add 1 degree
      \>>
      \<< STR\-> .01 + \->STR   // add 1 minute
      \>> IFTE
  \>> \-> str size Degmin
  \<<
      CASE size 6 ==
        THEN str 5 6
SUB "60" SAME   // check for 60 seconds
        \<< str 5 "00"
REPL DUP 3 4 SUB
Degmin EVAL
        \>>
        \<< str
        \>> IFTE
      END size 7 ==
      THEN str 6 7
SUB "60" SAME   // check for 60 seconds
        \<< str 6 "00"
REPL DUP 4 5 SUB
Degmin EVAL
        \>>
        \<< str
        \>> IFTE
      END size 8 ==
      THEN str 7 8
SUB "60" SAME   // check for 60 seconds
        \<< str 7 "00"
REPL DUP 5 6 SUB
Degmin EVAL
        \>>
        \<< str
        \>> IFTE
      END
    END
  \>>
\>>

checksum: # A374h
bytes: 508.5

Regards,

Mark
Thanks for your reply! Is there an FAQ that describes the use of code tags?
(04-26-2015 05:12 PM)MNH Wrote: [ -> ]Is there an FAQ that describes the use of code tags?

The Help button (top right) should give you some clues.
Reference URL's