Conditional Programming

Conditional Programming

Postby eroeder » Mon Mar 28, 2022 9:54 pm

Hello!
I am new to the site, but a big fan of the HP-41CX. I am trying to brush up on my old programming, but stuck. I see that some conditionals are on the keyboard, while others are in blue. I have completely forgotten the keystrokes to put in the line of code X<0?

How do you code ASCII letters while you are programming? Old brain has hit a brick wall, and the manuals I have don't step you through the exact keystrokes, I guess we all just knew back in the day...
eroeder
..
..
 
Posts: 5
Joined: Mon Mar 28, 2022 3:16 pm

Re: Conditional Programming

Postby Garth » Mon Mar 28, 2022 10:42 pm

Welcome.

Whether in program mode mode or not, you'll press:

XEQ ALPHA X shift I shift 0 3 ALPHA

The X is on the 6 key. Shift-I is the less-than symbol, shift-0 is the text 0, and 3 gives you the question mark.
Garth
Moderator
Moderator
 
Posts: 290
Joined: Tue Jan 20, 2009 1:31 am

Re: Conditional Programming

Postby eroeder » Mon Mar 28, 2022 10:46 pm

Wow, I feel so stupid!
Is there a cheat sheet to show the unlabeled characters below when in ALPHA? Oh wait, found it on page 25 of the manual. Ugh!

Thanks!
eroeder
..
..
 
Posts: 5
Joined: Mon Mar 28, 2022 3:16 pm

Re: Conditional Programming

Postby Garth » Mon Mar 28, 2022 10:53 pm

It's on the back of the calculator too.
Garth
Moderator
Moderator
 
Posts: 290
Joined: Tue Jan 20, 2009 1:31 am

Re: Conditional Programming

Postby eroeder » Tue Mar 29, 2022 2:18 am

Ugh! Why didn’t I remember that???
eroeder
..
..
 
Posts: 5
Joined: Mon Mar 28, 2022 3:16 pm

Re: Conditional Programming

Postby floppy_stuttgart » Sun Apr 10, 2022 6:50 pm

eroeder wrote:Ugh! Why didn’t I remember that???

Looks like a person need an on-site training. Have a look at upcoming meetings in your country and you will meet and you will speed(catch)-up.
From south-germany.
floppy_stuttgart
.........
.........
 
Posts: 112
Joined: Mon Mar 29, 2021 2:36 pm

Re: Conditional Programming

Postby eroeder » Sun Apr 10, 2022 10:10 pm

:D
eroeder
..
..
 
Posts: 5
Joined: Mon Mar 28, 2022 3:16 pm

Re: Conditional Programming

Postby jamhaley » Fri Jan 26, 2024 4:49 am

Can’t believe I found my 1987 HP41CX in a storage box, ordered a 3D printed battery case and VOILA! It’s alive! Just one problem. I tried this sample looping program from p. 305 of manual. It should count down to zero, beep and end, but instead just keeps going into negative numbers. Both my iOS emulator and calculator do the same thing. Any ideas? Fixes?
Attachments
IMG_1404.jpeg
jamhaley
...
...
 
Posts: 7
Joined: Fri Jan 26, 2024 4:32 am

Re: Conditional Programming

Postby Garth » Fri Jan 26, 2024 5:17 am

It works for me.  What number did you start with?  If you start with a really high number, it will take a long time to reach 0 and beep.  I'm surprised they used a global label to branch to though.  If you put LBL 01 after LBL "ABC", then put GTO 01 instead of GTO "ABC", it will run much faster, because the branch distance gets compiled.
Garth
Moderator
Moderator
 
Posts: 290
Joined: Tue Jan 20, 2009 1:31 am

Re: Conditional Programming

Postby jamhaley » Fri Jan 26, 2024 6:20 am

Hmmm…I started with 100. I tried your suggestion of LBL 01 & GTO 01, although it executed faster, it still just kept going past zero into negative numbers. Could I have some syntax error in my X>0?

I literally haven’t programmed it since the eighties. Although just spherical trig and arithmetic, I used it to calculate my cargo on a tanker and celestial navigation.

If I can’t get this simple thing to work I’m beyond pathetic! Help me Mr. Wizard!
jamhaley
...
...
 
Posts: 7
Joined: Fri Jan 26, 2024 4:32 am

Re: Conditional Programming

Postby Garth » Fri Jan 26, 2024 6:50 am

If you single-step it, can you see the number going down?
Garth
Moderator
Moderator
 
Posts: 290
Joined: Tue Jan 20, 2009 1:31 am

Re: Conditional Programming

Postby jamhaley » Fri Jan 26, 2024 6:54 am

Yes, it does…
jamhaley
...
...
 
Posts: 7
Joined: Fri Jan 26, 2024 4:32 am

Re: Conditional Programming

Postby Garth » Fri Jan 26, 2024 7:14 am

The calc does seem to be working, so I doubt there's a problem with its hardware.  It'll probably be one of those forehead slappers when you figure it out.  Now I'm interested.
Garth
Moderator
Moderator
 
Posts: 290
Joined: Tue Jan 20, 2009 1:31 am

Re: Conditional Programming

Postby jamhaley » Fri Jan 26, 2024 7:32 am

Yep, I’ll get back to you when I finally figure it out. How hard could a 7 step program be?
Thanks,
JH
jamhaley
...
...
 
Posts: 7
Joined: Fri Jan 26, 2024 4:32 am

Re: Conditional Programming

Postby jamhaley » Fri Jan 26, 2024 5:26 pm

Getting out the cobwebs…still working on that 7 step program, but wanted to test hardware. HP41CX will “beep” if I SF 11 and power cycle, but does not beep when I run this:

LBL BP
“BEEP”
PSE
GOTO BP
END

It just loops but never beeps???

Is there a command to test everything?

Thanks,
JH
jamhaley
...
...
 
Posts: 7
Joined: Fri Jan 26, 2024 4:32 am

Re: Conditional Programming

Postby Garth » Fri Jan 26, 2024 7:35 pm

Flag 26 is the audio-enable flag.  It sounds like it's clear.  If you do a SF 26, the beep should work again.  It's strange though, as flag 26 should be set when you first power up.  Also, I don't think that would affect the test and branch in your original problem.

Is there a command to test everything?

There's no command for that, but there is a module that does that.  I have no idea where, or even if, you could get one anymore.  Serious users these days are using something like Diego's Clonix or NoV-64 hardware plug-in modules (I have the Clonix-D) that hold lots of ROM module images in their flash memory, or a 41CL transplant board which has hundreds of modules pre-installed and runs up to 50 times as fast as the original, or the MAXX module which should be available soon (see https://www.systemyde.com/pdf/maxx-4d_manual.pdf for the manual), or maybe another option or two I might be forgetting.  There's also SwissMicros' DM41x which is a modern replacement that's better in nearly every way but the huge drawback for me is that there's no option for HP-IL.

As you figure out and post more of what does and does not work, hopefully another member here who knows more about the insides than I do will be checking in soon and give you some better guidance than I can. 
Garth
Moderator
Moderator
 
Posts: 290
Joined: Tue Jan 20, 2009 1:31 am

Re: Conditional Programming

Postby jamhaley » Fri Jan 26, 2024 8:16 pm

Thanks Garth,I’ll post any progress worth mentioning.
JH
jamhaley
...
...
 
Posts: 7
Joined: Fri Jan 26, 2024 4:32 am

Re: Conditional Programming

Postby jamhaley » Sun Jan 28, 2024 6:27 am

Ah Hah…head smacking complete!

When entering my X>0?, I was merely typing ALPHA X>0? instead of XEQ ALPHA X>0?, so it was just an ALPHA string not a command! It looked right on the display, but had that telltale little “T” character in front, and still looped due to the GOTO line, but had no proper conditional test to exit the loop.

Sorry to have bugged you Garth for such a dumb error. Shows how much one can forget since 1980-something. Hail HP for building a machine that would sleep in a storage box for 36 years and then spring to life again!

Humbly,
JH
jamhaley
...
...
 
Posts: 7
Joined: Fri Jan 26, 2024 4:32 am

Re: Conditional Programming

Postby Garth » Sun Jan 28, 2024 6:39 am

Yeah, forehead slapper for sure.  Obviously I hadn't thought of that.  I'm glad all is fine now.
Garth
Moderator
Moderator
 
Posts: 290
Joined: Tue Jan 20, 2009 1:31 am


Return to Programming

Who is online

Users browsing this forum: No registered users and 1 guest