HP Forums
User-defined functions in Free42 - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: Not HP Calculators (/forum-7.html)
+--- Forum: Not quite HP Calculators - but related (/forum-8.html)
+--- Thread: User-defined functions in Free42 (/thread-16153.html)

Pages: 1 2 3


RE: User-defined functions in Free42 - Thomas Okken - 01-25-2021 08:32 PM

Hmmm. Func does actually create variables "X" ... "L", but they are private and can't be accessed using RCL. The idea of making them private was to avoid cluttering up the regular variables namespace, and also to keep the way the backups are stored an implementation detail, so I can tinker with it and make it more efficient or whatnot.


RE: User-defined functions in Free42 - richmit - 02-23-2021 07:26 PM

First I want to say that I love the FUNC functionality! It has made my code so much better.

It would be even better if it could optionally restore other global resources like the alpha register, indexed matrix state, flags, & registers.


RE: User-defined functions in Free42 - richmit - 02-24-2021 03:59 AM

One extension that would be useful in the infinite stack mode would be to immediately RTNERR after FUNC if the stack has too few arguments for the function.


RE: User-defined functions in Free42 - kostrse - 11-21-2022 02:32 AM

Sorry, I cannot find FUN in the catalog. How to enter it in program mode?

UPDATE: Found in the Catalog -> PRGM submenu,


RE: User-defined functions in Free42 - Thomas Okken - 11-21-2022 10:25 AM

(02-23-2021 07:26 PM)richmit Wrote:  First I want to say that I love the FUNC functionality! It has made my code so much better.

It would be even better if it could optionally restore other global resources like the alpha register, indexed matrix state, flags, & registers.

Indexed matrix state is already saved and restored automatically when needed; specifically, when the currently indexed matrix is hidden by LSTO, or when a local matrix is indexed.

You can use local registers simply by creating a local REGS using LSTO: size 1 NEWMAT LSTO "REGS".

As for a local alpha register and local flags: I agree those would be nice to have, and they are on my to-do list. They are a bit tricky to implement because this will require new state types on the RTN stack an new logic in RTN, and this is going to collide with some other substantial work I want to do on FUNC. So, it is in the pipeline, but don't expect it soon.

(02-24-2021 03:59 AM)richmit Wrote:  One extension that would be useful in the infinite stack mode would be to immediately RTNERR after FUNC if the stack has too few arguments for the function.

It should do that already. If not, please let me know, that would be a bug.

UPDATE: What, those questions were posted nearly two years ago? My apologies, somehow I never noticed them until now.