Programming on i41CX+

Programming on i41CX+

Postby dvm@onemedicine.ca » Sat May 08, 2021 8:59 pm

I am completely new to HP41CX & it's programming language (does it have an official name?) via i41cx+. I kindly ask for help with the keystrokes for branching which tests alpha characters; I do understand branching when using numbers or data but I have not been able to figure out how to branch with alpha characters. (I would like add that I do not have an engineering or coding background and therefore learned basic programming via the HP manuals. I am a veterinarian an using the i41cx+ (iPhone) for calculating Intravenous fluid rates, constant rate infusions, tricky drug dosing for managing blood pressure etc in an ICU setting).

Knowing that the Prompt command can take alpha input, how does one test the alpha input. For Example this is how far I can get:

Cat ? Y or N?
AON
Prompt
AOFF
ASTO 01

How does one get the x=y command to test the alpha response, either Y or N? If the input is Y, the calculations would be done for cats and if the Input was N, the calculations would be for dog. (Dogs and cat parameter values are different).

Or may be there another to accomplish this type of branching without using alpha characters? I ask this, because these steps could suck a lot of memory. When I view other posts, I see people cutting down on steps to make program so frugal it isn't funny, likely similar to programming the AGC, aka Apollo Guidance Computer where, of course, memory was super limited.

I have gone pretty much done my best to figure this out -- searching programs for examples, reading several HP41* manuals -- before resorting to ask for help on this form. This query is likely 'trivial' for pro-HP41 users, so please be gentle on me for I do feel inadequate for engineers like yourselves have programmed Ingenuity to fly on Mars completely autonomously, send back images and sound (Perseverance recording Ingenuity's rotor blade whirling sound) and I can't figure how to handle alpha character branching sitting at my desk on Earth.

Sincerely, AJ
dvm@onemedicine.ca
...
...
 
Posts: 8
Joined: Sat May 08, 2021 7:53 pm
Location: Penticton, BC, Canada

Re: Programming on i41CX+

Postby mike-stgt » Sun May 09, 2021 1:39 am

dvm@onemedicine.ca wrote:How does one get the x=y command to test the alpha response, either Y or N?
Huge bandwidth for such a tiny question.

Simple but silly solution: You saved the answer with ASTO 01, so why not GTO IND 01 next to jump to LBL "Y" or LBL "N"? Bad idea, only one single Y/N prompt would be possible on your HP41.

What denote X and Y in X=Y? This in mind you'll grasp immediately following:
Code: Select all
 01 "Y"
 02 ASTO Y
 03 "CAT? Y/N?"
 04 AON
 05 STOP
 06 AOFF
 07 ASTO X
 08 X=Y?
 09 GTO A
 10▶LBL B
...
 nn▶LBL A
...
Can't believe similar examples not to be given in the HP41 manuals.
/M.
mike-stgt
.........
.........
 
Posts: 179
Joined: Tue Dec 24, 2019 12:12 pm

Re: Programming on i41CX+

Postby Garth » Sun May 09, 2021 3:03 am

There are several ways to accomplish the purpose. One I like to use is put the prompt in the display and use GETKEY. The following is part of a program I wrote decades ago and still use frequently. (I write them on the PC with a text editor, with comments, before keying the programs into the 41.)

Code: Select all
LBL 41   "F,X,C,L, OK ESC"   AVIEW     \ ENTER key was hit. Display the number-entry menu.  Key numbers 21, 64, 13, 33, 42, & 15.
LBL 01   GETKEY   1 +                  \ Label 01 is not actually in the program below, since it's not needed.
         SF 25   GTO IND X   GTO 41    \ If no key was pressed, GETKEY gives 0, you add 1, and loop again.  Invalid key will
                                       \ flash display once and repeat.  GTO 41 (not 01) because of LCD rotate bug.


I don't remember why I used label 41 for this, but the 1 + after GEYKEY will suit your purpose fine if you happen to use 41 like I did. If your prompt line says "CAT?", then GEYKEY would return a 71 for the Y key, and 41 for the N key; then you could SF 25, GTO IND X, to go to label 72 or label 42 (since we added 1). If you press a key that returns a number you don't have a label for, or if you don't press a key at all within the ten seconds GETKEY allows such that it returns 0 and you don't have a label 01, the GTO 41 will take you back to try again.

A little quirk is that if you let it time out and then press a key in the short time it takes it to loop back and get back into the GEYKEY, that keypress won't register; so just press it again and by that time GETKEY will be executing and do the job. The SF 25 is good for one error condition. If there's no numerical label of the number in X when it tries to GTO IND X, it would normally stop and say "NONEXISTENT". SF 25 lets it continue executing, but the flag will be cleared for the next potential error condition. The display line is re-executed above because otherwise the error condition you told it to ignore with SF 25 rotates what's in the display. The bug is otherwise harmless.

The program I took this from has nearly 30 numerical labels, and some are re-used (especially the lower-numbered ones 00-14 which only take one byte of program space). When the calc looks for a numerical label, it starts the search from the current place in the program, not the beginning. This means you could have additional places that want a yes/no answer, and the GTO can go to the appropriate place after each question, as long as the appropriate place is the first label 72 or 42 after that particular question's GTO IND X.
Garth
Moderator
Moderator
 
Posts: 290
Joined: Tue Jan 20, 2009 1:31 am

Re: Programming on i41CX+

Postby dvm@onemedicine.ca » Sun May 09, 2021 5:48 am

Thank you both Mike and Garth. Much appreciated. Thank you for your patience. I'm going with Mike's solution; I can follow it along with my limited amount of HP41 programming experience and knowledge. (The GETKEY command freaks me out, sorry Garth). When I worked through it, I went, "why didn't I think of that?" which is often the case with a good idea. I came up with a non elegant solution in the meantime, after learning branching and subroutines; there are a crazy amount of basic concepts to know/learn to write programs for the simple calculations I use for my work. They are pretty much linear sequences with some branching (decision making), nothing like the programs you folks are writing.
Using the clumsy:

CAT=1 DOG=0?
PROMPT
X=0?
GTO 02
GTO 03
LBL 02
Parameters for dog
GTO 04 [for output]
LBL 03
Parameters for cat
LBL04 [for output]

What is the HP41 language called and is there a method to calculate how many bytes a series of steps is?

Cheers, AJ
dvm@onemedicine.ca
...
...
 
Posts: 8
Joined: Sat May 08, 2021 7:53 pm
Location: Penticton, BC, Canada

Re: Programming on i41CX+

Postby Garth » Sun May 09, 2021 7:01 am

dvm@onemedicine.ca wrote:(The GETKEY command freaks me out, sorry Garth).

What part? The GTO INDirect? It does at least partly take care of the case of keys that were not one of the choices.

Code: Select all
CAT=1 DOG=0?
PROMPT
X=0?
GTO 02
GTO 03
LBL 02
Parameters for dog
GTO 04 [for output]
LBL 03
Parameters for cat
LBL04 [for output]


In that case, why not omit one of the GTO's and make it fall through to the desired routine if it fails the test, like eliminating the GTO 03 and just put label 03 immediately after that GTO 02 (or just eliminate the label 03 also). Then parameters for cat will come before the dog. You'll have something like:
Code: Select all
"CAT=1 DOG=0?"
PROMPT
X=0?
GTO 02
Parameters for cat
GTO 04 [for output]
LBL 02
Parameters for dog
LBL04 [for output]

With the 41's limited memory, we're always out to save a byte anywhere we can. I have my main memory is mostly full, with 20 programs I frequently use. Angel Martin has several excellent modules out, one being the WarpCore which can make programs in virtually any discipline faster and more compact. I also like my ZENROM which makes all the synthetic instructions, able to be directly keyed in like they were not synthetic at all.

What is the HP41 language called and is there a method to calculate how many bytes a series of steps is?

Sometimes it's called FOCAL, for Forty-One CAlculator Language, but soon after that was suggested and quickly caught on, someone pointed out that there was already an unrelated language with that name. So I suppose we're still without a name, unless you just want to call it something like HP-41 RPN.
Garth
Moderator
Moderator
 
Posts: 290
Joined: Tue Jan 20, 2009 1:31 am

Re: Programming on i41CX+

Postby mike-stgt » Sun May 09, 2021 8:21 am

dvm@onemedicine.ca wrote:Using the clumsy:

CAT=1 DOG=0?
PROMPT
...

De-clumsy it:
Code: Select all
SF 27  [set USER mode]
"CAT=A DOG=B?"
PROMPT
LBL A
Parameters for cat
GTO 04 [for output]
LBL B
Parameters for dog
LBL04 [for output]
This way no need for R/S after input, just hit A or B.
Drawback: keys A and B must not be assigned to do something else.
mike-stgt
.........
.........
 
Posts: 179
Joined: Tue Dec 24, 2019 12:12 pm

Re: Programming on i41CX+

Postby dvm@onemedicine.ca » Sun May 09, 2021 9:49 pm

Garth:
Thank you so kindly for your suggestions and addressing my queries. Your program structure is waaay sleeker than my original. I have been brute forcing these programs (which are super bloated with insufficiencies) but since I have been on the HP41 URL and HP41 forum, as well analyzing your suggesting, I'm getting ideas how to save those precious bytes.

Just to be clear I'm using a 41 emulator, the mighty i41CX+. Your story about getting into the HP4 was excellent and parallels how I came to the i41cx+. Some day, if The Forum might be interested in my journey to the HP41 via the i41, I may post it.
As an aside, in grad school I used a HP71 for my mathematical modelling course to avoid walking across the campus to get prints-outs. I learned HP Basic and how to use the machine for that course and then it all completely faded and 71 gathered dust until I gifted it to (Dr.) Antoni Lagana 'cause he help me out a lot in the beginning when I got the i41cx. And that's a great story how that came to be.

As I learn more and more about programming the i41, which is essentially the HP41, it was a truly incredible machine. Unreal the vision, creativity and engineering that device embodies. This devise must have freaked-out engineers, engineering students at the time. What happened? What out-competed it? Judging from what I hear from Antoni Lagana and engineers like yourself, on the forum, the 41 has become a bit of a subculture. With that in mind, what is the present and newer generation engineers using? My colleagues consider me crazy for program my own stuff. But when the internet or a desktop glitches, I have everything on my hip. It's truly is a great feeling to be self-sufficient.

Cheers, AJ
dvm@onemedicine.ca
...
...
 
Posts: 8
Joined: Sat May 08, 2021 7:53 pm
Location: Penticton, BC, Canada

Re: Programming on i41CX+

Postby Garth » Mon May 10, 2021 2:10 am

dvm@onemedicine.ca wrote:As an aside, in grad school I used a HP71 for my mathematical modelling course to avoid walking across the campus to get prints-outs.

Should I assume you had the math module? No 71 is complete without it. Outstanding. And you must've had the HPIL module too, and perhaps the Thinkjet printer? I wish I knew what's wrong with mine, why all at once it stopped printing anything at all even though it goes through the motions; but I have interface adapters to use my Epson parallel printer.

I learned HP Basic and how to use the machine for that course

The users' groups, especially the Paris users' group, contributed loads of wonderful LEX files to extend the BASIC and make it way, way better than any other BASIC I've ever seen. I have 177K of RAM in mine which was all I could budget for at the time, but still plenty for that and large files. It's a shame that HP's marketing didn't do it justice. It was made for technical professionals; and out of those, I don't think one in ten knew it existed, and out of those, I don't think one it ten had any idea how much power it had.

and then it all completely faded and 71 gathered dust

I have two, but it's a rare thing now that I use one. I still am not ready to sell either one though, even though I could get a fortune for the works.

This devise must have freaked-out engineers, engineering students at the time.

It truly was revolutionary.

What happened? What out-competed it?

I think initially TI saw they could not compete with HP for the technical market, so they turned to the school market (somehow I hesitate to call it the 'education' market), and that turned out to be super profitable, and graphing calculators were cool. Our sons who were in high school in the early 2000's however said the kids mostly used their required TI84's to play games. I personally have no use for color, and almost no use for graphing, and I hate touch screens (the grime, the moiré effects, the lack of tactile feel, etc.); but I guess a calc that could control equipment on the workbench wasn't cool enough. I think HP was foolish to drop HPIL. It was a great system, and if they wanted more speed or whatever, they could have made faster versions like USB has been upgraded. It was already much faster than the fastest standard RS-232 speed of the day.

Judging from what I hear from Antoni Lagana and engineers like yourself, on the forum, the 41 has become a bit of a subculture. With that in mind, what is the present and newer generation engineers using?

The HP50g was popular, but although it executed much faster, it didn't have the power of HPIL. Now the 50g has been discontinued too. I suppose people now mostly use their PCs and phones and tablets. I like the fact that my 41 has been reliable for decades, never having to upgrade OSs or re-install anything, etc.. I like stability rather than the newest thing. I think the calculator department of HP should have gone with Agilent (later Keysight) when it was spun off, and that Agilent should have keep the HP name and the other part should have gotten the new name.
Garth
Moderator
Moderator
 
Posts: 290
Joined: Tue Jan 20, 2009 1:31 am

Re: Programming on i41CX+

Postby dvm@onemedicine.ca » Mon May 10, 2021 3:58 am

Yes. the Math module, HPIL and the Thinkjet as well as the statistic and curve fitting modules. It was (and remains) a great machine. Antonio is getting an interface that allows connecting to an iPad to speed up typing. He told me that he 'built' the i41 to protect his HP41 by not having to take it in to work; he was concerned he might drop it or spill coffee on it; it was a labour of love for him he said. By the way, he's a quantum physicist. When the 71 finally arrived, he shot me an email photo of it along side his 41. Antonio build in a feature where it would give the key sound when activated. All us HP keeners know the feel and sound of those keys. Programming the i41 for me is a labour of love too. There are Apps out there that do similar things, but I know the formulas behind mine and often the developers take short cuts like using linear forms for power, saturating power and log functions. Drives me crazy; there are significant errors at low and high patient weights. I can relate to your comment about stability. The Palm Pilot I used for 22 years, never crashed and survived drops galore as well as been chewed, partially, by a dog. I stopped using it completely a few months ago, switching over to an iphone - 12 mini. On the Pilot I used the programmable RPN MathUPro, by Creative Creek, Clay Thompson. Switch to iphone 'cause the Desktop version (for backups) did not work with OS's greater than Mountain Lion. On a different note, the teaching manuals on the HP41 URL have been very helpful for a non-engineering type like me. I am grateful for those HP keeners out there ! I continue to use a 11C. Cheers, AJ
dvm@onemedicine.ca
...
...
 
Posts: 8
Joined: Sat May 08, 2021 7:53 pm
Location: Penticton, BC, Canada

Re: Programming on i41CX+

Postby Garth » Mon May 10, 2021 4:14 am

dvm@onemedicine.ca wrote:[For the 71,] Antonio is getting an interface that allows connecting to an iPad to speed up typing.

I got the 71B-TALK communications program in about 1986 to use a PC's full keyboard and monitor for a 71 over an RS-232 link using the HP82164A or FSI164A HPIL-to-RS232 interface adapter. I never did use it much, and now PCs don't have COM ports anymore, nor 5¼" floppy-disc drives. My fingers are pretty narrow and I was able to type 30wpm on the 71's own keyboard (50-60% of my speed on a full-size keyboard), although I quit typing so much on it when they discontinued it and I thought, "If I wear it out and need a replacement, I'll be out of luck!" Later I got a brand-new backup 71 for $25 :o before there was eBay. I had written myself a very nice, rather full-featured text editor using LEX files from the Paris users' group and functions in the Forth/Assembler module, specifically to be able to move my work around in the 22-character display very nimbly.
Garth
Moderator
Moderator
 
Posts: 290
Joined: Tue Jan 20, 2009 1:31 am

Re: Programming on i41CX+

Postby dvm@onemedicine.ca » Mon May 10, 2021 6:45 am

Mike:

Thank you ! That's pretty darn slick. Where is that in the manual? I do have A assigned but that's easy to adjust...even I can do that ! :D

Thanks for your generosity for sharing cool ideas. Programming is fun (with your and Garth's help)

Cheers, AJ
dvm@onemedicine.ca
...
...
 
Posts: 8
Joined: Sat May 08, 2021 7:53 pm
Location: Penticton, BC, Canada

Re: Programming on i41CX+

Postby dvm@onemedicine.ca » Mon May 10, 2021 7:17 am

Mike:

Before I hit the hay, can this be done?

SF 27 [set USER mode]
"CAT=C DOG=D?"
PROMPT
LBL C
Parameters for cat
GTO 04 [for output]
LBL D
Parameters for dog
LBL04 [for output]
dvm@onemedicine.ca
...
...
 
Posts: 8
Joined: Sat May 08, 2021 7:53 pm
Location: Penticton, BC, Canada

Re: Programming on i41CX+

Postby mike-stgt » Tue May 11, 2021 12:30 pm

dvm@onemedicine.ca wrote:Before I hit the hay, can this be done?

...
"CAT=C DOG=D?"
PROMPT
LBL C
...

What do you expect me to reply? We could start a "funny answers to silly questions" contest. My input: No-no-no -- how dare you! LBL C directly after the PROMPT makes CAT the default if you hit R/S. That is a serious, scandalous, stupid, outrageous, objectionable, and abhorrent breaching of our great, amazing and terrific DOGS FIRST! doctrine. What a dangerous thing, tremendous, all our dogs being so badly mistreated.
mike-stgt
.........
.........
 
Posts: 179
Joined: Tue Dec 24, 2019 12:12 pm

Re: Programming on i41CX+

Postby Garth » Tue May 11, 2021 7:38 pm

LOL, I know some people love their dogs more than anything. I'm sure glad our neighbor with his noisy dog moved though. AJ, maybe you could pull some secret trick with your patients that would make the barks a lot quieter and gradually disappear completely, slowly enough that the owners don't realize you're the cause. We've had camping trips ruined by the noise of dogs at neighboring campsites, put up with a few years of extreme stress from an inconsiderate neighbor, etc.. I'm just a tad autistic, and this neighbor's dog's barking made it like there were little lightning bolts shooting through my head with every bark. I finally understand why more-autistic children panic and cry when there's too much noise. We had another neighbor across the street with a huge dog with a monstrous bark that would stand at the front gate and bark at everything going by, while I was trying to talk to customers on the phone in my home office while this dog was rattling my closed windows. The owner was seldom home. I called animal control several times, and several times saw them put warnings and citations in the screen door, and this neighbor finally moved too because he was not willing to get rid of the dog or teach it to be quiet.

We have fish in an aquarium in the living room. Beautiful, never kept us up with their barking, never peed on the rug, never got hair on anything, didn't turn the back door into a pile of toothpicks, etc.. :D
Garth
Moderator
Moderator
 
Posts: 290
Joined: Tue Jan 20, 2009 1:31 am

Re: Programming on i41CX+

Postby dvm@onemedicine.ca » Tue May 11, 2021 9:20 pm

Mike: I apologize. Sincerely AJ
Garth: Rigorous and consistent positive training will help manage barking dogs not completely eliminate it; sometimes certified trainers may resort to negative reinforcement - non-shock barked collars first. Sorry to hear about vacations and life in general has been negatively impacted by barking dogs and owners not doing something concrete make your time off and neighbourhood more enjoyable.
Cheers, AJ
dvm@onemedicine.ca
...
...
 
Posts: 8
Joined: Sat May 08, 2021 7:53 pm
Location: Penticton, BC, Canada

Re: Programming on i41CX+

Postby ve3oat » Sat Jul 03, 2021 1:40 am

FOCAL :
someone pointed out that there was already an unrelated language with that name


In case anyone cares :
(From memory) FOCAL was the BASIC/FORTRAN-like high-level interpretive language developed by Digital Equipment Corp (DEC) for their PDP-8 and PDP-11 series computers. I spent many hours solving analytical problems and doing digital simulations by writing and running programs in FOCAL on a PDP-8 with paper tape and teletype input/output during the early 1970s. It was challenging, stimulating and invigourating. Those were the days!
ve3oat
......
......
 
Posts: 20
Joined: Thu Sep 15, 2016 8:50 pm
Location: Canada

Re: Programming on i41CX+

Postby dvm@onemedicine.ca » Sat Jul 03, 2021 7:45 pm

Thank you kindly for getting back to me on the name of the HP41 language. You old school engineers are great and a special bunch of folks. You were the guys and gals that got Us to the Moon! For my not-so old school anecdote: we backed-up physiological data during my PhD on tape in this big, AC'd positive pressure room. Going in the room was like going back in time. By the end of PhD, we were using desktop PC's and that massive computer whose name I can't recall was dismantled and the room converted into another lab. Cheers.
dvm@onemedicine.ca
...
...
 
Posts: 8
Joined: Sat May 08, 2021 7:53 pm
Location: Penticton, BC, Canada


Return to Programming

Who is online

Users browsing this forum: Ahrefs [Bot] and 1 guest

cron