home *** CD-ROM | disk | FTP | other *** search
/ Otherware / Otherware_1_SB_Development.iso / amiga / audio / samples / showmen.lha / ShowMenu.Rexx < prev   
Encoding:
OS/2 REXX Batch file  |  1992-03-17  |  2.9 KB  |  104 lines

  1. /*
  2. \    $VER: ShowMenu.Rexx 0.985 (AMG 920317)
  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 struct MenuEntry
  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.  
  16. parse value sourceline(2) with . '$VER: ' name
  17. say name
  18. say
  19.  
  20. if ~show('L','rexxsupport.library') then
  21.    if ~addlib('rexxsupport.library',0,-30,0) then do
  22.       say "I really need rexxsupport.library!"
  23.       exit 20
  24.       end
  25.  
  26. MENUDIR='DLGConfig:Menu/'
  27.  
  28. CmdType. ='???'
  29. CmdType.1='Exe'
  30. CmdType.2='Bat'
  31. CmdType.3='Sub'
  32. CmdType.4='DLG'
  33.  
  34. /* Some bit indirection and layout for the flags */
  35. Bit.1 = 6;Spc.1 =' '
  36. Bit.2 =13;Spc.2 ='  '
  37. Bit.3 = 1;Spc.3 =' '
  38. Bit.4 = 0;Spc.4 ='  '
  39. Bit.5 = 8;Spc.5 ='  '
  40. Bit.6 = 9;Spc.6 ='  '
  41. Bit.7 =18;Spc.7 =' '
  42. Bit.8 =14;Spc.8 =' '
  43. Bit.9 = 2;Spc.9 =' '
  44. Bit.10=12;Spc.10=' '
  45. Bit.11=19;Spc.11='  '
  46. Bit.12=21;Spc.12=''
  47.  
  48. menus=showdir(MENUDIR,'f',':');
  49.  
  50. do until menus=''
  51.    parse var menus menu ':' menus
  52.    if upper(right(menu,5))~='.MENU' then iterate  /* allow for other files */
  53.    call open('in',MENUDIR||menu,'R')
  54.    say menu" -  "PadRight(C2AStr(readch('in',61)),61)
  55.    say copies(' ',41)"Lev  R C D CL E PK KP PT P r T V LF"
  56.    do while ~eof('in')
  57.       entry=readch('in',114)
  58.       if length(entry)~=114 then leave
  59.       command=GetItem(1)
  60.       program=PadRight(C2AStr(GetItem(71)),71)
  61.       description=PadRight(C2AStr(GetItem(33)),33)
  62.       retflag=c2d(GetItem(1))
  63.       type=c2d(GetItem(1))
  64.       call GetItem(1) /* skip padbyte */
  65.       tptflags=GetItem(4)
  66.       user_level=PadLeft(c2d(GetItem(1)),3)
  67.       if type=3
  68.          then flagstr='- - -  - -  -  -  - - - - -  -' /*  submenu  */
  69.          else do                                       /* otherwise */
  70.             if retflag=0
  71.                then flagstr='n '
  72.                else flagstr='y '
  73.             do flag=1 to 12
  74.                if bittst(tptflags,Bit.flag)
  75.                   then flagstr=flagstr||'y'
  76.                   else flagstr=flagstr||'n'
  77.                flagstr=flagstr||Spc.flag
  78.                end
  79.             end
  80.       say '  ['command'] 'description'  'user_level'  'flagstr
  81.       say '  'CmdType.type' 'program
  82.       say
  83.       end
  84.    call close('in')
  85.    say
  86.    end
  87.  
  88. exit
  89.  
  90. C2AStr: procedure      /* Convert null-terminated C string to ARexx string */
  91.    str=arg(1)||d2c(0)
  92.    return left(str,pos(d2c(0),str)-1)
  93.  
  94. PadRight: procedure                /* Pad arg(1) on right so length=arg(2) */
  95.    return left(arg(1)||copies(' ',arg(2)),arg(2))
  96.  
  97. PadLeft: procedure                  /* Pad arg(1) on left so length=arg(2) */
  98.    return right(copies(' ',arg(2))||arg(1),arg(2))
  99.  
  100. GetItem: procedure expose entry  /* very ugly way to use kind of C structs */
  101.    tmp=left(entry,arg(1))
  102.    entry=delstr(entry,1,arg(1))
  103.    return tmp
  104.