esrf

Beamline Instrument Software Support
SPEC Macro documentation: [ Macro Index | BCU Home ]

MENU.MAC
See other macros in category: Tools
Description:
    General menu handling macros.
Documentation:
    DESCRIPTION
    Provides macros developpers with a set of functions useful to create and handle a menu.

    OVERVIEW
    menu
    calls the user menu.
    menuoptskip - menuoptval - menuoptbutton - menuoptlist
    define an option.
    menuoptgroupselect1
    define several options formated in a particular way.
    menuvargetv - menuvaryeno - menuvartogg - menuvarbitw - menuvarlist - menuvardynl menuvar2lis
    define the way last defined option is to be assigned.
    menuaction
    associates an action to the last defined option.
    menuerror
    could be an action that would print a message after menu execution.
    menuprint menuprb menuprr menupru
    simply prints information in the menu body without considering it as an option.
    menuitemchk - menuexecchk
    help in debugging.


    EXAMPLE
    This menuexample macro is in that file. You can execute it.
    def menuexample 
      menu("\n  EXAMPLE","menu_example_display")
    
    def menu_example_display 
     global MENU_EX
    
     menuoptval  (0,"\n","ARBITRARY VALUE",MENU_EX[0])
     	menuvargetv ("MENU_EX[0]")
     menuoptval(0,"\n","TOGGLE 1/0",MENU_EX[1]?"NO":"YES")
     	menuvartogg ("MENU_EX[1]",25829) 
     menuoptval(0,"\n","TOGGLE bit no 2",MENU_EX[2]&4?"YES":"NO")
     	menuvarbitw ("MENU_EX[2]",4)
     menuoptval(0,"\n","LIST SELECTION",MENU_EX[3])
     	menuvarlist("MENU_EX[3]","CANNES  GRENOBLE  VALENCE",MENU_EX[3]) 
     print MENU_SEP
     menubutton(20,"\n","GO","G")
     	menuaction ("print \"Going ...\";sleep(3)")
    
    


    DEPENDENCIES
      - The file menu.mac has to be read in 
    


Macros:
    menuoptskip
    Usage: menuoptskip (no_of_option_to_skip)
    Allows to define temporarily unused options.

    menuoptval
    Usage: menuoptval (format,end,"text",value,"key")
    Defines an option which display is a description text and the corresponding value.
    format is the field-width for printf("%s") function. end is printed after the value, while text is printed before. key is eventually the highlighted letter (or string) to type, taken or not from text, for selecting that option. If there is no key specified, the option number is used instead.

    menuoptbutton
    Usage: menuoptbutton (format,end,"text","key",flag,arg1,arg2)
    Defines an option which is displayed as a button.
    format is the field-width for printf("%s",text) function. end is printed after the text. key is eventually the highlighted letter (or string) to type, taken or not from text, for activating that button. If there is no key specified, the option number is used instead.
    flag, arg2 and arg2 are not used at the moment. The idea is the Highlight the button under certain conditions defined through those 3 inputs.

    menuoptlist
    Usage: menuoptlist (format, end, "text", array, size, key, flag)
    Defines an option which displays a description text and the content of a single row array as value.
    format is the field-width for printf("%s") function. end is printed after the array content, while text is printed before. size is of the size of the array. key is eventually the highlighted letter (or string) to type, taken or not from text, for selecting that option. If there is no key specified, the option number is used instead. flag is 0 or 1, distinguishes between 2 flavours of display.

    menuoptgroupselect1
    Usage: menuoptgroupselect1 (format,end,"text",list,current,size,"variablename",flag)
    Defines as option each element of the list, held in an \"old fashion array\", and display them all, with the current selected one printed first, just after the text. Neither assignement nor actions can be associated with such option, because it is fixed internally. The action beyond it is the selection of one current item. This is usually the header of a menu that is common to several devices... format is the field-width for printf("%s",text) function. end is printed after each listed item, except 1st one. size is the size of the array containing the list. variablenam is the name of the global that holds current index value. flag distinguishes between various display flavours (0,1,2,4).

    menuaction
    Usage: menuaction ("action")
    Associates the action to the last option defined. It is to be executed after the option has been selected and eventually assigned a new value by the user.

    menuerror
    Usage: menuerror ("message")
    Stores a message in the error buffer that is flushed after each option execution. Could be inserted in any menu action.

    menuwarning
    Usage: menuwarning ("message")
    Stores a message in the warning buffer that is flushed after each option execution. Could be inserted in any menu action.

    menuvargetv
    Usage: menuvargetv ("varname","question")
    Associates to the last defined option the assignement of the global varname through getval() function. question is eventually the text displayed when prompting for the new value. Otherwise, the option description text is used.

    menuvaryeno
    Usage: menuvaryeno ("varname","question")
    Associates to the last defined option the assignement of the global varname through yesno() function. question is eventually the text displayed when prompting the user. Otherwise, the option description text is used.

    menuvartogg
    Usage: menuvartogg ("varname",val1,val2)
    Associates to the last defined option the assignement of the global varname by toggling itself. val1 and val2 are eventually the 2 value that the global can take. If none are specified, there are assumed to be 1 and 0.

    menuvarbitw
    Usage: menuvarbitw ("varname",bitmask)
    Associates to the last defined option the assignement of the global varname by bitwise toggling itself. bitmask is the mask used in the bitwise operation.

    menuvarlist
    Usage: menuvarlist ("varname","stringlist")
    Associates to the last defined option the assignement of the global varname by one of the elements of stringlist, 2 spaces-separated.

    menuvardynl
    Usage: menuvardynl ("currindex_name","list_arrayname","arraysize_varname","delmacro","addmacro")
    Associates to the last defined option the assignement of the global currindex_name to the selected item index through list_arrayname. This array-list is dynamic, what means it is also possible to change its content. The macros delmacro and addmacro are called respectively, after the delete request has been done, passed the index and size as arguments (prior to deletion, starting from 0), and after the addition request has been done, passed the new index as argument).

    menuvar2lis
    Usage: menuvar2lis ("arrayname","arraysizename","refarrayname","refarraysizename")
    Associates to the last defined option the assignement of the globals arrayname and arraysizename of the selected items out of the refarrayname reference array which size is also given as refarraysizename.

    menutabdef
    Usage: menutabdef (globalvar,lineoffset,linenum,columnoffset,columnnum,arg0,arg1,arg2)
    Records the information in a way that menutable display command understands.
    What consists of assigning the array globalvar suitably with the information held in arg0, arg1 and arg2 parameters, and at the position defined via lineoffset, linenum, columnoffset and columnnum parameters.
    arg0 can be :
    zero
    then, the globalvar array specified area would be filled with arg1+linenum+colnum, eventually multiplied by arg2.
    a non zero valued symbol
    then, arg1 and arg2 must not be specified and the globalvar area is filled with that non zero value.
    an array symbol name
    then, arg1 and arg2 are the line offset, and eventually the column offset of that array.
    initialiases globalvar as an array gv[0]=0 even if content is unknown, think to reserve some place by calling it.

    menuprint
    Usage: menuprint (format,end,"text",value)
    Prints text and value, like menuoptval, but without considering it as an option.

    menuprb
    Usage: menuprb ("text")
    Simply prints text in bold characters.

    menuprr
    Usage: menuprr ("text")
    Simply prints text in reversed video.

    menupru
    Usage: menupru ("text")
    Simply prints text in underligned characters.

    menuprbu
    Usage: menuprbu ("text")
    Simply prints text in bold and underligned characters.

    menusep
    Usage: menusep
    Prints 1 line through the screen.

    menutable
    Usage: menutable (globalvar,lines,cols,separator,flag)
    Displays the information held in globalvar array in a table format.
    The globalvar must be indexed by a string of the following form :"line@@col", or "col@@line".( This is what menutabdef macro does automatically ). lines and cols simply gives the whole table size. separator is a string printed between columns. flag distinguishes between several formats described here:
    • flag 0 : first line is the header separated by a line from the rest
    • flag&1 : twists lines and cols.
    • flag&2 : expands the table to use all the screen columns (80).
    • flag&4 : left justifies data.
    • flag&8 : no header. separates all lines by a line


    menuchb
    Usage: menuchb
    Turns bold character attribute on.

    menuchi
    Usage: menuchi
    Turns all special character attributes off.

    menuchr
    Usage: menuchr
    Turns reverse-video character attribute on.

    menuchu
    Usage: menuchu
    Turns underligned character attribute on.

    menuchsq
    Usage: menuchsq
    Prints ascii \374. (1 square).

    menu
    Usage: menu ("menutitle","displaymacro","updatemacro","exitmacro")
    Calls the menu.
    displaymacro is the name of the macro where the menu has been defined using this set of macros. updatemacro is the name of the macro that eventually reads in global settings to be displayed in the menu; it is run before the displaymacro. exitmacro is executed when exiting the menu loop. Put all what you want to do after the menu has been executed here. The menu must be the only command on its expansion level.

    menuitems
    Usage: menuitems [option_number]
    FOR DEBUGGING: Describes last run menu regarding internal registers.

    menuitemchk
    Usage: menuitemchk [option_number]
    FOR DEBUGGING: Dumps last run menu related internal registers.

    menuexecchk
    Usage: menuexecchk
    FOR DEBUGGING: Toggles a mode where menu registers are dumped at option selection, prior to execution.

Internal Macros:
    menuexample
    Usage: menuexample


    menu_example_display
    Usage: menu_example_display


    menu_initoption
    Usage: menu_initoption (no_of_option_fields_to_prepare)
    Increments option index and resets the related information.

    menuprintlist
    Usage: menuprintlist(fmt, end, text, selarr, size)


    menu_pr_button
    Usage: menu_pr_button (fmt,end,key,text,flag,arg1,arg2)
    Prints button style option.

    menu_pr_opt
    Usage: menu_pr_opt (fmt,end,opt,text,value)
    Prints basic style option, or any information.

    menu_pr_key
    Usage: menu_pr_key (fmt,end,key,text,value)
    Prints basic style option, but with a key.

    menusetup
    Usage: menusetup
    Sets some characters processing up. (Bold,Underlined,...)

    menu_doit
    Usage: menu_doit (title)
    The menu manager !

    menu_err_print
    Usage: menu_err_print
    Flushes error buffer.

    menu_war_print
    Usage: menu_war_print
    Flushes warnings buffer.

    menu_exec
    Usage: menu_exec (hkey)
    Sorts out what to do out of the selected option.

    menu_dynlist
    Usage: menu_dynlist (elem,nelem,init)
    Manages value selection through a dynamic list of values. Returns the selected element as the corresponding index to the array elem.

    menu_list
    Usage: menu_list (list,init)
    Manages selection through a fixed list of values. Returns the value selected.

    menu_2lists
    Usage: menu_2lists (list,sz,list0,sz0)
    Manages the selection of certain elements held in an array, to be held in another array. Returns the size (sz) of the second array.

Filename: menu.mac
Author: MENU.MAC - Marie-Claire LAGIER - 96/04/29
Last mod.: 11/09/2015 13:57 by domingue