Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Force 4.0 Reference - pickaddid() add an item to a string list with identifier http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 pickaddid()         Add an item to a string list with identifier
------------------------------------------------------------------------------
 Declaration
   pick.hdr

 Syntax
   proc pickaddid extern
   param value _SLIST pList, ;
         const char   cString, ;
         value uint   uId

 Arguments
   pList is a list pointer.
   cString is a string to add to the list.
   uId is an identifier number to associate with the newly added item.

 Return
   None.

 Description
   pickaddid() adds the string item in cString to the list
   structure specified with pList, and associates it with the
   identifier given in uId.

   Using pickaddid() instead of pickadd() allows to specify unique
   id numbers for all selectable items, where items containing separator
   lines can all get the same id (e.g. 0). This feature is also handy if
   you later decide to insert more items somewhere in the list. In this
   case, there is no need to change the case expressions which evaluate
   the return value from pickdisp(), as this function returns the item
   id numbers, and not their order numbers.

   This function can only be used with string lists, but not with generic
   lists that contain non-character data.

 Example
   #define EXAMPLE_LIST
   #include example.hdr

   // Initialize and execute a "file" sub-menu with hot-keys.
   //
   
   #define ID_OPEN         1
   #define ID_NEW          2
   #define ID_SAVE         3
   #define ID_SAVE_AS      4
   #define ID_PRINT        5
   #define ID_SETUP_PRINT  6
   #define ID_QUIT        99
   
   proc Test_pickaddid
   vardef
      _SLIST  pList
      uint    uSelectedId
      logical lFileInBuffer
   enddef
   pList := pickinit()
   
   // We call pickaddid, giving the selectable items unique id numbers
   //
   pickaddid( pList, "&Open",          ID_OPEN        )
   pickaddid( pList, "&New",           ID_NEW         )
   pickaddid( pList, "-",              0              )
   pickaddid( pList, "&Save",          ID_SAVE        )
   pickaddid( pList, "Save &as...",    ID_SAVE_AS     )
   pickaddid( pList, "-",              0              )
   pickaddid( pList, "&Print",         ID_PRINT       )
   pickaddid( pList, "Setup p&rinter", ID_SETUP_PRINT )
   pickaddid( pList, "-",              0              )
   pickaddid( pList, "&Quit",          ID_QUIT        )
   
   // Activate the "Print" item only if there is a text to print
   //
   lFileInBuffer := .f.
   picksetact( pList, 7, lFileInBuffer )
   
   savecolors()
   __syscolor[ CLR_STD ]       := WHITE_BLACK
   __syscolor[ CLR_INACT ]     := WHITE_DARK_GREY
   __syscolor[ CLR_INACT_SEL ] := GREEN_LIGHT_GREY
   __syscolor[ CLR_ENHCD ]     := GREEN_BLACK
   __syscolor[ CLR_UNSEL_CH ]  := WHITE_RED
   __syscolor[ CLR_SEL_CH ]    := GREEN_RED
   
   @ 9, 4 to 20, 18                     // frame
   uSelectedId := pickdisp( pList, 10, 5, 19, 17 ) // execute list
   
   restcolors()
   @ 22, 0
   do case
   case uSelectedId == ID_OPEN
      ? uSelectedId                     // execute function OpenFile()
   case uSelectedId == ID_NEW
      ? uSelectedId                     // execute function NewFile()
   case uSelectedId == ID_SAVE
      ? uSelectedId                     // execute function SaveFile()
   case uSelectedId == ID_SAVE_AS
      ? uSelectedId                     // execute function SaveFileAs()
   case uSelectedId == ID_PRINT
      ? uSelectedId                     // execute function PrintFile()
   case uSelectedId == ID_SETUP_PRINT
      ? uSelectedId                     // execute function SetupPrinter()
   otherwise
      ? uSelectedId                     // execute function HandleExit()
   endcase
   pickclear( pList )
   endproc

   proc main
   Test_pickaddid()
   endproc

See Also: pickadd()

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson