Custm menu ambiguity

Post here to share useful tips and tricks, to ask questions about using your DM42 or to report software-related problems
Post Reply
User avatar
pica
Posts: 32
Joined: Fri Mar 30, 2018 9:36 am
Location: eSwatini

Custm menu ambiguity

Post by pica » Fri Jan 31, 2020 8:01 pm

If I have a variable with the same name as a function and assign the fuction to a custom menu, the menu will recall the variable, rather than execute the function. For example

3 STO SIN
ASSIGN FCN SIN
CUSTOM SIN

will display 3 rather than sin(3). Is this normal hp42 behavior? The manual (p68-69) does not mention any ambiguity. Free42 android does the same thing.

rprosperi
Posts: 632
Joined: Mon Apr 24, 2017 5:48 pm
Location: New York

Re: Custm menu ambiguity

Post by rprosperi » Fri Jan 31, 2020 8:46 pm

A real 42S behaves this way, so Free42/DM42 behavior is correct.

Hard to say for certain why HP chose that, but if you decide to use variable names which are the same as predefined functions and then further assign them to a custom menu you created, then you are presumably doing it for a reason and would recall so.
--bob p

DM42: β00071 & 00282, DM41X: β00071, DM10L: 071/100

User avatar
Guenter
Posts: 136
Joined: Wed May 24, 2017 4:26 pm
Location: Germany

Re: Custm menu ambiguity

Post by Guenter » Fri Jan 31, 2020 9:09 pm

To add to the confusion, enter this small programme:

Code: Select all

01 LBL "SIN"
02 123456
03 END
Now press the "SIN" in your CUSTOM menu. Huh!
Conclusion:
When assigning something to the custom menu the choice of Functions, Programs etc. just lets you select easily what you want to assign to a specific key. It does not inherit where the resulting string comes from. Thus the "SIN" assigned to the key is just this, a specific string. Now, when pressing this custom key, the system is obviously looking with some precedence where it finds that string. In this example - first a program name then a variable name and last a built in function.

Günter
Günter
DM42 SN:00004 and SN:00184 -- DM41X SN:00013

Thomas Okken
Posts: 668
Joined: Tue May 02, 2017 3:48 pm
Contact:

Re: Custm menu ambiguity

Post by Thomas Okken » Fri Jan 31, 2020 9:33 pm

That's exactly right. It looks up CUSTOM keys by name; labels first, then variables, then built-in functions. But there is one scenario where the origin of the string matters:

Assign ENTER from the FCN catalog: Shift ASSIGN ▼ ▼ ▼ ▼ ▼ ▼ ▼ ▼ ▼ ▼ ▼ ENTR Σ+. Now create a variable named ENTER, spelling out the name using the ALPHA menu.

Now if you do Shift CUSTOM and then press and hold Σ+, you will see ENTER, not RCL "ENTER".

This is because the second E of ENTER in the FCN catalog has its high bit set, indicating it should not be shown when the name is displayed in a menu label. This character-suppression trick is used when function names don't fit in a menu label, to create better abbreviations than you would get by simply cutting them off at the end. Hence, ENTR instead of ENTE for ENTER, CPLX instead of COMP for COMPLEX, and so on. And that high bit makes ENTER from the FCN catalog a different string than ENTER spelled out using the ALPHA menu.

rprosperi
Posts: 632
Joined: Mon Apr 24, 2017 5:48 pm
Location: New York

Re: Custm menu ambiguity

Post by rprosperi » Sat Feb 01, 2020 1:16 am

Thomas Okken wrote:
Fri Jan 31, 2020 9:33 pm
This is because the second E of ENTER in the FCN catalog has its high bit set, indicating it should not be shown when the name is displayed in a menu label. This character-suppression trick is used when function names don't fit in a menu label, to create better abbreviations than you would get by simply cutting them off at the end. Hence, ENTR instead of ENTE for ENTER, CPLX instead of COMP for COMPLEX, and so on. And that high bit makes ENTER from the FCN catalog a different string than ENTER spelled out using the ALPHA menu.
Clever solution! Is this your design to handle these cases, or does the real 42S use the same technique internally? If so, it must have been frustrating to track down, but oh, so satisfying once you figured it out. :D
--bob p

DM42: β00071 & 00282, DM41X: β00071, DM10L: 071/100

Thomas Okken
Posts: 668
Joined: Tue May 02, 2017 3:48 pm
Contact:

Re: Custm menu ambiguity

Post by Thomas Okken » Sat Feb 01, 2020 4:10 am

rprosperi wrote:
Sat Feb 01, 2020 1:16 am
Clever solution! Is this your design to handle these cases, or does the real 42S use the same technique internally? If so, it must have been frustrating to track down, but oh, so satisfying once you figured it out. :D
I noticed the ENTER/ENTE/ENTR thing very early on, when I was looking at a hex/ascii dump of the 42S ROM while looking for the font bitmaps, and copied the technique in the function table in Free42. But I didn't figure out how this affected the CUSTOM menu until much later. I don't remember how I finally figured it out, but it is mentioned in the 1.1.12 release notes. Despite the satisfaction of solving the puzzle, I do remember being a bit disappointed, because I thought handling assignments of built-in functions by function ID rather than by name was more elegant, but I went with the lookup-by-name approach anyway, for the sake of compatibility.

User avatar
pica
Posts: 32
Joined: Fri Mar 30, 2018 9:36 am
Location: eSwatini

Re: Custm menu ambiguity

Post by pica » Sat Feb 01, 2020 7:34 am

Thanks for the discussion. The issue came up for me as I have a downloaded program, I forget which, that has a variable called TIME. Of course, the DM42 now has a function called TIME which I find very useful and was taken aback by the erratic results when it was assigned to a menu. It is useful to know that the order of priority is generally label, variable, function.

Post Reply