- Joined
- Aug 25, 2019
- Messages
- 6,198
- Reaction score
- 4,390
Okay, so I'm a MUMPS geek. Been programming in it since 1983. Recently was looking into putting together a motor test stand and needed to convert between grams of force and Newtons. Got tired of having to constantly type "xxxx / 101.97" in my calculator, so I wrote a quick and dirty routine in MUMPS to do it for me. Then I wanted to figure out what class of motor I could use on that test stand, so I wrote another routine to return the letter code for the motor based upon the Newtons. I'll probably add more functions as I go along, but I thought I'd share the code with the TRF community. Free to use and modify, just tell folks where you got it from. I'd appreciate any new code added being sent to me to include in my library. I use Reference Standard M (RSM) on my Linux box. You can run it under Linux, Windows (using Cygwin), MacOS and other UNIX and UNIX-like operating systems. Find RSM here.
To call G2N:
It's not quite as easy to use as my APL workspace to get Newtons from grams, but I haven't figured out how to write a SELECT or CASE in APL
(can't get the APL division sign to display on here)
Code:
ROCKET ;;Utilities for Rocketry;JK3;26Jan2024
;;
write !,"Not an entry-point!",!
quit
;
G2N(gms) ;;Grams to Newtons
new newtons
set newtons=gms/101.97
quit newtons
;
N2A(n) ;;Newtons to Alphabetic Code
new code
set code=$select(n'>0.3125:"1/8A",n'>0.625:"1/4A",n'>1.25:"1/2A",n'>2.5:"A",n'>5:"B",n'>10:"C",n'>20:"D",n'>40:"E",n'>80:"F",n'>160:"G",n'>320:"H",n'>640:"I",n'>1280:"J",n'>2560:"K",n'>5120:"L",n'>10240:"M",n'>20480:"N",n'>40960:"O",1:">0")
quit code
;
To call G2N:
Code:
ROU> write $$G2N^ROCKET(100000)
9806.80592331077767971
ROU> write $$N2A^ROCKET($$G2N^ROCKET(1000000))
M
ROU>
It's not quite as easy to use as my APL workspace to get Newtons from grams, but I haven't figured out how to write a SELECT or CASE in APL
Code:
▿newtons[⎕]▿
▿c←newtons grams
[1] c←grams+101.97
▿
(can't get the APL division sign to display on here)