Post Reply 
Program not working in newer firmwares
08-25-2022, 02:18 AM
Post: #1
Program not working in newer firmwares
Hello, i had the following program in my calculator that would show a customizable menu screen whenever i typed shift+alpha+math. But in the current firmware it doesnt work anymore. I didnt create the program, in fact i dont know anything about HPPPL... Does anyone know how to fix it?It indicates a syntax error in the line 49: "EXPORT menuList :="


// --------------------------------------------------------------------------
//
// Originally intemded to display "Program"->"Edit"->"Cmds" tree
// directly in CAS or HOME without program editing.
//
// usage:
// - called with <Shift>+<User> plus <Alpha><Shift><Space>
// (2 times <Shift>+<User> keeps user key mode active)
// - <enter>, <OK> or touch on a command in main or sub menu returns selected item
// - <Esc> in main menu will close popup
// <Esc> in sub menu will return to main menu entry
// - <up>, <down> and swipe to move in popup (<left><right> are NOT usable)
// - starts with last returned sub- or mainmenu entry selected
// starts last visited submenu selected when ended with <Esc>
// - adopt 'menuList' to your needs. Remove 'menuAct' and 'menuList' from this code,
// when you want to use different menus in different Apps.
//
// 'menuList' contains the menu definition in a list. Each entry is described by a
// sub list with text to display as the 1st and text to return as 2nd entry.
// When the 2nd value is again a list, the entry is interpreted as a submenu containing
// the sublist entries to display and return. A sample:
// EXPORT menuList :=
// { { "display_text1", "output_text1" },
// { "display_text2", "output_text2" },
// { "submenu1" , { "menu1_display_and_output1",
// "menu1_display_and_output2",
// "menu1_display_and_output3"
// }
// },
// { "submenu2" , { "menu2_display_and_output1",
// "menu2_display_and_output2"
// }
// }
// };
//
// Stay healthy!
// Frank P. Mar 2021
// hisory:
// V 0.01 Feb 2019 - initial
// V 1.0 Mar 2021 - menuAct added to remember last choose
// - menuList both display and return text as list of lists
// (inspired by ramon_ea1gth CSTMENU)
//
// --------------------------------------------------------------------------
// { "km/l <-> l/100km", "kml()" },

EXPORT menuAct := {1,0};
EXPORT menuList :=
{ { "evalc" , "evalc()"
},{ "re" , "re()"
},{ "im" , "im()"
},{ "csolve" , "csolve()"
},{ "rectangular to polar" , "RectangularPolar()"
},{ "polar to rectangular" , "PolarRectangular()"
}
};

KEY KSA_Math

BEGIN
LOCAL choose_list, choose_title, ch, ret, i;
/////////////////////////// check the menu entries ///////////////////////////////////
FOR i FROM 1 TO SIZE(menuList) STEP 1 DO
// 1st entry is a string and 2nd entry is a string or a list and 2nd entry not empty
IF ( TYPE(menuList(i,1)) == 2 ) AND ( (TYPE(menuList(i,2)) == 2) OR ( TYPE(menuList(i,2)) == 6 ) ) AND SIZE(menuList(i,2)) THEN
// OK
ELSE
MSGBOX(" INVALID MENU ENTRY: " + STRING(menuList(i)) );
RETURN "";
END;
END;

WHILE 1 DO
//////////////////////// prepare the choose arguments //////////////////////////////
// string as 2nd argument => in main or a submenue entry and that is not active
IF (TYPE(menuList(menuAct(1),2)) == 2) OR ( (TYPE(menuList(menuAct(1),2)) == 6) AND (menuAct(2) == 0) ) THEN
choose_list := MAKELIST(menuList(X,1), X,1,SIZE(menuList));
choose_title := "Commands";
ch := menuAct(1);
END;
// at a submenue entry and it is active
IF ( TYPE(menuList(menuAct(1),2)) == 6 ) AND (menuAct(2) > 0) THEN
choose_list := menuList(menuAct(1),2);
choose_title := menuList(menuAct(1),1);
ch := menuAct(2);
END;

////////////////////////////// choose a menu entry //////////////////////////////////
ret:=choose(ch,choose_title,choose_list);

IF menuAct(2) == 0 THEN
///////////////////////////// handle main level ///////////////////////////////////
menuAct(1) := ch; // remember main selection
IF ret==0 THEN // choose ended with esc
RETURN "";
ELSE
IF TYPE(menuList(menuAct(1),2)) == 2 THEN // a string as 2nd entry
RETURN menuList(menuAct(1),2); // return selected entry
END;
IF TYPE(menuList(menuAct(1),2)) == 6 THEN // a list as 2nd entry
menuAct(2) := 1; // activate submenu
END;
END; // something selected?
ELSE
//////////////////////////////// and sub level ///////////////////////////////////
menuAct(2) := ch; // remember sub selection
IF ret==0 THEN // no entry selected
menuAct(2) := 0; // back to main level
ELSE
RETURN choose_list(menuAct(2)); // return with selection
END;
END; // in sub menu?
END; // while choosing
END; // menu
Find all posts by this user
Quote this message in a reply
08-25-2022, 12:08 PM
Post: #2
RE: Program not working in newer firmwares
Change this:


KEY KSA_Math

to this:


KEY KSA_Math()

and it should compile.
Find all posts by this user
Quote this message in a reply
08-26-2022, 01:23 AM
Post: #3
RE: Program not working in newer firmwares
Still wont compile... It says syntax error in the line 49
Find all posts by this user
Quote this message in a reply
08-26-2022, 09:03 AM (This post was last modified: 08-26-2022 09:07 AM by toml_12953.)
Post: #4
RE: Program not working in newer firmwares
(08-26-2022 01:23 AM)pedrodebem Wrote:  Still wont compile... It says syntax error in the line 49

I put in the () and still got a syntax error. Then I changed the line to this:

KEY KSA_Math();

and the syntax error moved to the next BEGIN.

Then I removed the semi-colon and did another check. No errors!

Somehow there was a fix triggered by the syntax error. The program doesn't run, though. All I get is a white exclamation point in an orange circle.

BTW, on line 38, the spelling should be history.

Tom L
Cui bono?
Find all posts by this user
Quote this message in a reply
08-26-2022, 09:27 AM (This post was last modified: 08-26-2022 09:28 AM by matalog.)
Post: #5
RE: Program not working in newer firmwares
I have changed what you posted (on the right) to the code on the left on this diff checker.

I basically only added the () in line 58 I think.

To test the program you cannot use Run, Tom, as the menu only appears when Shift, Alpha and Catalog (Math?) have been pressed.

https://www.diffchecker.com/q92CTuEB

And this works on latest Calculator software available, on my G2.
Find all posts by this user
Quote this message in a reply
08-26-2022, 12:24 PM
Post: #6
RE: Program not working in newer firmwares
(08-26-2022 01:23 AM)pedrodebem Wrote:  Still wont compile... It says syntax error in the line 49

I copied the entire program as posted and made that one change indicated above and it worked fine for me. I see nothing wrong with line 49. Don't name the program file KSA_math; that could cause issues. Also make sure you don't have any variables named menuList on the calculator.

-road
Find all posts by this user
Quote this message in a reply
08-28-2022, 08:08 PM (This post was last modified: 08-28-2022 08:21 PM by pedrodebem.)
Post: #7
RE: Program not working in newer firmwares
I dont understand exactly what i m doing wrong... The programm works just fine on the android app. I attached some photos of the calculator screen when the error shows. For what i know, i should be able to access the menu by clicking shift+alpha+toolbox while in user mode, right?
               

Thanks in advance.
Find all posts by this user
Quote this message in a reply
08-29-2022, 12:51 PM
Post: #8
RE: Program not working in newer firmwares
Make sure lines 47, 48, and 49 look exactly like this:

EXPORT menuAct := {1,0};
EXPORT menuList :=
{ {"evalc" , "evalc()"

If you tap Check while in the program editor the curser will jump to where the compiler thinks the error is located. Just one character out of place (they are sometimes hard to notice) will cause an error. Sometimes a mistake above that point is the actual cause of the error though, so look above line 49 for mistyped characters as well.

-road
Find all posts by this user
Quote this message in a reply
08-30-2022, 08:06 PM
Post: #9
RE: Program not working in newer firmwares
Found the issue, i had the comma for decimal mark, making all kinds of confusion.
Find all posts by this user
Quote this message in a reply
09-02-2022, 05:14 PM
Post: #10
RE: Program not working in newer firmwares
(08-30-2022 08:06 PM)pedrodebem Wrote:  Found the issue, i had the comma for decimal mark, making all kinds of confusion.

Be sure to use the #pragma mode header in your source code to avoid such issues.
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 1 Guest(s)