home *** CD-ROM | disk | FTP | other *** search
/ Otherware / Otherware_1_SB_Development.iso / amiga / audio / samples / showmenu.lha / ShowMenu.Rexx < prev   
Encoding:
OS/2 REXX Batch file  |  1992-04-06  |  4.3 KB  |  130 lines

  1. /*
  2. \    $VER: ShowMenuâ••Rexx 0.991 (AMG 920406)
  3.  \
  4.  /   Prints an overview of all the DLG menus. Refer to the DLG Manual
  5.  \   for the abbreviations of the flags.
  6.   \
  7.   /  To do:
  8.   \     better error checking
  9.   /     more elegant conversion of structs
  10.  /
  11. /    (C) 1992 by Arnout Grootveld, 2:281/100@FidoNet
  12. \
  13.  \   Freely distributable. Feel free to do the 'To do' things :-)
  14.  /
  15. /    Revision history:
  16. \
  17. /       0.01   initial version for private use only
  18. \       0.985  first released version; for use with DLG 0.985
  19.  \      0.991  updated to reflect changes in DLG 0.991
  20. */
  21.  
  22. parse arg ShowLevel
  23.  
  24. parse value sourceline(2) with . '$VER: ' name
  25. say name
  26. say
  27. if ShowLevel='' then say 'Showing menus for all levels.'
  28.                 else say 'Showing menus for level 'ShowLevel'.'
  29. say
  30.  
  31. if ~show('L','rexxsupport.library') then
  32.    if ~addlib('rexxsupport.library',0,-30,0) then do
  33.       say "I really need rexxsupport.library!"
  34.       exit 20
  35.       end
  36.  
  37. MENUDIR='DLGConfig:Menu/'
  38.  
  39. /* You might add some CSI codes here to make it more colourful... */
  40. CmdType. ='???'           ;Flags. ='???'       ;VisType. ='???'
  41. CmdType.1='Executable'    ;Flags.0='Chain'     ;VisType.0='Shown'
  42. CmdType.2='BatchFile'     ;Flags.1='BCPend'    ;VisType.1='Hidden'
  43. CmdType.3='SubMenu'       ;Flags.2='CLI'       ;VisType.2='Ghosted'
  44. CmdType.4='MenuScript'    ;Flags.3='Return'
  45. CmdType.5='CmdStack'      ;Flags.4='Ask'
  46. CmdType.6='ARexx'
  47. CmdType.7='Builtin'
  48.  
  49.  
  50. menus=showdir(MENUDIR,'f',':');
  51.  
  52. do until menus=''
  53.    parse var menus menu ':' menus
  54.    if upper(right(menu,6))~='.MENUN' then iterate  /* allow for other files */
  55.    call open('in',MENUDIR||menu,'R')
  56.    entry=readch('in',436)  /* struct MenuHeader */
  57.    MenuName=C2AStr(GetItem(61))
  58.    if MenuName='' then MenuName='< No menu name specified >'
  59.    MenuCols=c2d(GetItem(1))
  60.    MenuPrompt=C2AStr(GetItem(256))
  61.    if MenuPrompt='' then MenuPrompt='< No menu prompt specified >'
  62.    MenuNumEntry=GetItem(1)
  63.    if MenuNumEntry='0a'x then MenuNumEntry='\N'
  64.    if MenuNumEntry='00'x then MenuNumEntry='< None >'
  65.    MenuAction=C2AStr(GetItem(81))
  66.    if MenuAction='' then MenuAction='< No activity string specified >'
  67.    MenuModule=PadRight(C2AStr(GetItem(16)),16)
  68.    say 'Menu: 'left(menu,length(menu)-6)' - 'MenuName
  69.    say '   Module: 'MenuModule'  #Columns: 'MenuCols'  NumEntry: 'MenuNumEntry
  70.    say '   'MenuAction
  71.    say '   'MenuPrompt
  72.    say
  73.    do while ~eof('in')
  74.       entry=readch('in',256) /* struct MenuEntry */
  75.       if length(entry)~=256 then leave
  76.       command=GetItem(1)
  77.       if command='0a'x then command='\N'
  78.                        else command=command||' '
  79.       program=C2AStr(GetItem(71))
  80.       description=PadRight(C2AStr(GetItem(35)),35)
  81.       helpfile=PadRight(C2AStr(GetItem(17)),17)
  82.       type=c2d(GetItem(1))
  83.       llev=PadLeft(c2d(GetItem(1)),3)
  84.       ulev=PadRight(c2d(GetItem(1)),3)
  85.       visibility=c2d(GetItem(1))
  86.       flags=GetItem(1)
  87.       FlagString='Flags:'
  88.       do i=0 to 4
  89.          if bittst(flags,i) then FlagString=FlagString||' 'Flags.i
  90.          end
  91.       if FlagString='Flags:' then FlagString='Flags: <none>'
  92.       logvalue=PadRight(c2d(GetItem(1)),3)
  93.       action=C2AStr(GetItem(81))
  94.       if action='' then action='< No activity string specified >'
  95.       call GetItem(1) /* skip padbyte */
  96.       rate=PadRight(c2d(GetItem(2)),5)
  97.       cost=PadRight(c2d(GetItem(2)),5)
  98.       maxtime=PadRight(c2d(GetItem(2)),5)
  99.       priority=PadRight(c2d(GetItem(1)),3)
  100.       if ShowLevel='' | (ShowLevel>=llev & ShowLevel<=ulev) then do
  101.          say command' 'description'  'helpfile'  'llev'-'ulev'  'VisType.visibility
  102.          say '   'Program
  103.          say '   LogCode='logvalue'  Rate='rate'  Cost='cost'  MaxTime='maxtime'  Pri='priority'  Type='CmdType.type
  104.          say '   'action
  105.          say '   'FlagString
  106.          say
  107.          end
  108.       end
  109.    call close('in')
  110.    say
  111.    say
  112.    end
  113.  
  114. exit
  115.  
  116. C2AStr: procedure      /* Convert null-terminated C string to ARexx string */
  117.    str=arg(1)||d2c(0)
  118.    return left(str,pos(d2c(0),str)-1)
  119.  
  120. PadRight: procedure                /* Pad arg(1) on right so length=arg(2) */
  121.    return left(arg(1)||copies(' ',arg(2)),arg(2))
  122.  
  123. PadLeft: procedure                  /* Pad arg(1) on left so length=arg(2) */
  124.    return right(copies(' ',arg(2))||arg(1),arg(2))
  125.  
  126. GetItem: procedure expose entry  /* very ugly way to use kind of C structs */
  127.    tmp=left(entry,arg(1))
  128.    entry=delstr(entry,1,arg(1))
  129.    return tmp
  130.