home *** CD-ROM | disk | FTP | other *** search
- /*
- \ $VER: ShowMenuâ••Rexx 0.991 (AMG 920406)
- \
- / Prints an overview of all the DLG menus. Refer to the DLG Manual
- \ for the abbreviations of the flags.
- \
- / To do:
- \ better error checking
- / more elegant conversion of structs
- /
- / (C) 1992 by Arnout Grootveld, 2:281/100@FidoNet
- \
- \ Freely distributable. Feel free to do the 'To do' things :-)
- /
- / Revision history:
- \
- / 0.01 initial version for private use only
- \ 0.985 first released version; for use with DLG 0.985
- \ 0.991 updated to reflect changes in DLG 0.991
- */
-
- parse arg ShowLevel
-
- parse value sourceline(2) with . '$VER: ' name
- say name
- say
- if ShowLevel='' then say 'Showing menus for all levels.'
- else say 'Showing menus for level 'ShowLevel'.'
- say
-
- if ~show('L','rexxsupport.library') then
- if ~addlib('rexxsupport.library',0,-30,0) then do
- say "I really need rexxsupport.library!"
- exit 20
- end
-
- MENUDIR='DLGConfig:Menu/'
-
- /* You might add some CSI codes here to make it more colourful... */
- CmdType. ='???' ;Flags. ='???' ;VisType. ='???'
- CmdType.1='Executable' ;Flags.0='Chain' ;VisType.0='Shown'
- CmdType.2='BatchFile' ;Flags.1='BCPend' ;VisType.1='Hidden'
- CmdType.3='SubMenu' ;Flags.2='CLI' ;VisType.2='Ghosted'
- CmdType.4='MenuScript' ;Flags.3='Return'
- CmdType.5='CmdStack' ;Flags.4='Ask'
- CmdType.6='ARexx'
- CmdType.7='Builtin'
-
-
- menus=showdir(MENUDIR,'f',':');
-
- do until menus=''
- parse var menus menu ':' menus
- if upper(right(menu,6))~='.MENUN' then iterate /* allow for other files */
- call open('in',MENUDIR||menu,'R')
- entry=readch('in',436) /* struct MenuHeader */
- MenuName=C2AStr(GetItem(61))
- if MenuName='' then MenuName='< No menu name specified >'
- MenuCols=c2d(GetItem(1))
- MenuPrompt=C2AStr(GetItem(256))
- if MenuPrompt='' then MenuPrompt='< No menu prompt specified >'
- MenuNumEntry=GetItem(1)
- if MenuNumEntry='0a'x then MenuNumEntry='\N'
- if MenuNumEntry='00'x then MenuNumEntry='< None >'
- MenuAction=C2AStr(GetItem(81))
- if MenuAction='' then MenuAction='< No activity string specified >'
- MenuModule=PadRight(C2AStr(GetItem(16)),16)
- say 'Menu: 'left(menu,length(menu)-6)' - 'MenuName
- say ' Module: 'MenuModule' #Columns: 'MenuCols' NumEntry: 'MenuNumEntry
- say ' 'MenuAction
- say ' 'MenuPrompt
- say
- do while ~eof('in')
- entry=readch('in',256) /* struct MenuEntry */
- if length(entry)~=256 then leave
- command=GetItem(1)
- if command='0a'x then command='\N'
- else command=command||' '
- program=C2AStr(GetItem(71))
- description=PadRight(C2AStr(GetItem(35)),35)
- helpfile=PadRight(C2AStr(GetItem(17)),17)
- type=c2d(GetItem(1))
- llev=PadLeft(c2d(GetItem(1)),3)
- ulev=PadRight(c2d(GetItem(1)),3)
- visibility=c2d(GetItem(1))
- flags=GetItem(1)
- FlagString='Flags:'
- do i=0 to 4
- if bittst(flags,i) then FlagString=FlagString||' 'Flags.i
- end
- if FlagString='Flags:' then FlagString='Flags: <none>'
- logvalue=PadRight(c2d(GetItem(1)),3)
- action=C2AStr(GetItem(81))
- if action='' then action='< No activity string specified >'
- call GetItem(1) /* skip padbyte */
- rate=PadRight(c2d(GetItem(2)),5)
- cost=PadRight(c2d(GetItem(2)),5)
- maxtime=PadRight(c2d(GetItem(2)),5)
- priority=PadRight(c2d(GetItem(1)),3)
- if ShowLevel='' | (ShowLevel>=llev & ShowLevel<=ulev) then do
- say command' 'description' 'helpfile' 'llev'-'ulev' 'VisType.visibility
- say ' 'Program
- say ' LogCode='logvalue' Rate='rate' Cost='cost' MaxTime='maxtime' Pri='priority' Type='CmdType.type
- say ' 'action
- say ' 'FlagString
- say
- end
- end
- call close('in')
- say
- say
- end
-
- exit
-
- C2AStr: procedure /* Convert null-terminated C string to ARexx string */
- str=arg(1)||d2c(0)
- return left(str,pos(d2c(0),str)-1)
-
- PadRight: procedure /* Pad arg(1) on right so length=arg(2) */
- return left(arg(1)||copies(' ',arg(2)),arg(2))
-
- PadLeft: procedure /* Pad arg(1) on left so length=arg(2) */
- return right(copies(' ',arg(2))||arg(1),arg(2))
-
- GetItem: procedure expose entry /* very ugly way to use kind of C structs */
- tmp=left(entry,arg(1))
- entry=delstr(entry,1,arg(1))
- return tmp
-