Post Reply 
Softmenu - DrawMenu wrapper
12-05-2014, 10:47 AM (This post was last modified: 12-05-2014 01:04 PM by Angus.)
Post: #1
Softmenu - DrawMenu wrapper
For convenience with my user keyboard I ended up with the Softmenu function. Many might use something similar, but somebody might find the following helpful.
In the example I use the different assignments CR Haeger suggested in the plotting from cas thread to SHIFT+D.

Code:
[/quote]
SoftMenu();

///////////////////////////////////////////////////////////////////////////////////////////
//re-usable soft menu. return 1 through 6 for buttons clicked
///////////////////////////////////////////////////////////////////////////////////////////
SoftMenu(buttons) //buttons is list(6) of strings - names of Softkeys
BEGIN
 DRAWMENU(buttons);          //no typechecking or args checking
 LOCAL inp:=WAIT(-1);
 IF TYPE(inp)!=6 THEN RETURN inp; END; //need list, keystrokes returned
 IF inp(1)!=#0d AND
    inp(1)!=#3d AND
    inp(1)!=#7d THEN RETURN ""; END;
 IF inp(3)<#220d THEN RETURN ""; END; //mouseclicks only on FKeys
 LOCAL btn:=1+IP(inp(2)*6/320);  //calculate button id of x-coordinate
 RETURN btn;
END;


KEY KS_Xttn()
BEGIN
 LOCAL content:={"f(x):=","f->F","F->f",":=","-","-"};
 LOCAL btn:=SoftMenu(content);    

  CASE
    IF btn=1 THEN "f(x):=" END;
    IF btn=2 THEN "Function.F1:=f" END;
    IF btn=3 THEN "f(x):=Function.F1(x)" END;
    IF btn=4 THEN "f(x):="+CAS.Ans END;
    DEFAULT "";    
  END;
END;

Quick and dirty, I know. but I do use this kind a lot. Personally I am happy with the results - if we got some kind of autoexecute for the returned Strings (think about rpn) I would be pleased.

In an other thread I asked if it is possible to distinguish between cas and home: I still could not figure out how that is done.
Find all posts by this user
Quote this message in a reply
12-08-2014, 09:11 AM
Post: #2
RE: Softmenu - DrawMenu wrapper
Hello Angus,
i use pretty much the same code to display a menu.
I only added a STARTVIEW(-1); before the DRAWMENU command.

i like to see the home screen when displaying the menus and not see the list of programs.

My 2 cents,

Giancarlo
Find all posts by this user
Quote this message in a reply
12-08-2014, 11:50 AM
Post: #3
RE: Softmenu - DrawMenu wrapper
The way I use the DRAWMENU command is with the user keyboard. The View Button is abused to display the Softmenu for a specific key. So I had no need to switch to home view.

As stated before I would love to be able to 'autoexecute' anything on the entry line. That would solve many aspects and, correct me if I am wrong, it sounds realizable.
Find all posts by this user
Quote this message in a reply
12-08-2014, 01:15 PM
Post: #4
RE: Softmenu - DrawMenu wrapper
Hello,
Unfortunately i don't remember the name of each program i write hence i always go to the program list and then click on the run soft button.

This doesn't means that i like the way the programs are listed. If the menu directories like the hp48 won't be available, i'd like to have them anyway separated by subject or domain.

At the moment i write one program, test it and once completed i paste it in another program which contains all the procedures written for the same argument.

This is not very efficent but it prevent me from having dozens of programs mixed up...

Thanks

Giancarlo
Find all posts by this user
Quote this message in a reply
12-08-2014, 02:22 PM
Post: #5
RE: Softmenu - DrawMenu wrapper
Hello Giancarlo,

just a suggestion:
put special (to You) comments on top of each program and also above some EXPORTed functions/variables defining a menu location (e.g. //!menu: category subcategory ...) and/or some descriptive help text (e.g. //!purpose: hello world prog).

Then write a starter program which uses these lines by utilizing the Programs() variable:
1. get all program names,
2. read each program's source and search for your special comments,
3. build an appropriate menu structure (with menus, submenus, ..., help texts),
4. let the user select an item and return the program.function name (with additional "()" if in non-rpn mode)
Let a user key execute your starter.
If the parsing takes too long, save the once built structure in a program-local variable and rebuild only if manually requested.
Find all posts by this user
Quote this message in a reply
Post Reply 




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