home *** CD-ROM | disk | FTP | other *** search
/ Frozen Fish 2: PC / frozenfish_august_1995.bin / bbs / d09xx / d0950.lha / BBDoors / BBDoors65.lha / rexxDoors / Amiga_List.rexx next >
OS/2 REXX Batch file  |  1993-08-05  |  7KB  |  241 lines

  1. /*    Amiga List.rexx -  updated for BBBBS.baud - 6 Februaury 1993    */
  2. /*    by Charles Johnston (Sysop) Crazy Train BBS 602-771-8971        */
  3. /*    Added ANSI color&detect-Menu redisplay for screen scrolling     */
  4. /*    Pause and resume for listings that otherwise would scroll away. */
  5. /*    Clear screen code so program has it's own screen.               */
  6. /*    Renamed program from 'sholist' to more descriptive 'Amiga List' */
  7. /*   -------------------------------------------------------------    */
  8. /*      Copyright 1989 Richard Lee Stockton and Gramma Software.      */
  9. /*    This code is freely distributable as long as this copyright     */
  10. /*   notice remains, unchanged, at the start of the code. Thank you.  */
  11.  
  12. CR='0D'x
  13. CALL TIME('R')
  14. SIGNAL ON BREAK_C
  15. SIGNAL ON BREAK_E
  16.  
  17. PARSE arg Username winnings . colorflag secs .
  18. IF secs='' THEN secs=3600
  19.  
  20.        /* Turns colors off unless colorflag=1*/
  21. def=''
  22. red=''
  23. grn=''
  24. yel=''
  25. blu=''
  26. mag=''
  27. cyn=''
  28. wht=''
  29.  
  30. IF colorflag=1 THEN    /* let's see some color!*/
  31.   DO
  32.     def=''
  33.     red=''
  34.     grn=''
  35.     yel=''
  36.     blu=''
  37.     mag=''
  38.     cyn=''
  39.     wht=''
  40.   END
  41.  
  42.  
  43. /* Open the support library if it is not already open. */
  44. if ~show('L',"rexxsupport.library") then do
  45.     addlib('rexxsupport.library',0,-30,0)
  46.      end
  47.  
  48.  
  49. /* This is the menu and selection prompt function*/
  50.  
  51. Start:
  52. SAY '0C'x /*Clear screen(formfeed)*/
  53. SAY  grn'                          A M I G A     L I S T'def''||CR
  54. SAY  wht'                          ~~~~~~~~~     ~~~~~~~'def''||CR
  55. SAY  cyn'  This is your chance to LIST what is  going on inside  the  Amiga that is'CR
  56. SAY '  running this BBS. You may combine letters to examine more  than one area'CR
  57. SAY '  such as: MDVPH would yield -> memory,devices,volumes,ports and handlers.'CR
  58. SAY CR
  59. SAY  wht' =================================='grn' M E N U'wht' ================================'def''||CR
  60. SAY CR
  61. SAY  yel'  A=directories  C=clip list    D=devices  F=open files     H=handlers'||CR
  62. SAY '  I=interrupts   L=libraries    M=memory   P=ports          R=resources'||CR
  63. SAY '  S=semaphores   T=ready_tasks  V=volumes  W=waiting_tasks  X=REXX tasks'||CR
  64. SAY CR
  65. SAY wht LEFT('=',75,'=')||CR
  66. SAY yel'               Space Bar PAUSES listing - Backspace Key RESUMES'def''||CR
  67. SAY grn'                        Press RETURN to EXIT to BBS'def''||CR
  68. SAY CR
  69. OPTIONS PROMPT def' '?' for Menu'yel' OR'def' Enter Letter(s): > '
  70. DO FOREVER
  71. PULL x
  72. /* if no argument, then exit */
  73.   IF length(x)=0 THEN CALL OUT
  74.   
  75.   CALL checkBBS()
  76.  
  77. /* if '?' clear screen call start (display menu) and return to prompt*/
  78.   IF (x=='?') THEN DO
  79.                     CALL Start
  80.                    END
  81.  
  82. /* Take each letter in the argument, one at a time */
  83.  
  84.   DO i=1 TO length(x)
  85.     y=substr(x,i,1)
  86.  
  87. /* Select an appropriate title for this letter */
  88.  
  89.    SELECT
  90.        WHEN y='A' THEN title = 'Assigned Directories [DOS list]'
  91.        WHEN y='C' THEN title = 'Clips [AREXX list]'
  92.        WHEN y='D' THEN title = 'Device Drivers'
  93.        WHEN y='F' THEN title = 'Open Files [local]'
  94.        WHEN y='H' THEN title = 'Handlers [DOS list]'
  95.        WHEN y='I' THEN title = 'Interrupts'
  96.        WHEN y='L' THEN title = 'Libraries'
  97.        WHEN y='M' THEN title = 'MemoryList Items'
  98.        WHEN y='P' THEN title = 'Ports'
  99.        WHEN y='R' THEN title = 'Resources'
  100.        WHEN y='S' THEN title = 'Semaphores'
  101.        WHEN y='T' THEN title = 'Ready Tasks'
  102.        WHEN y='V' THEN title = 'Volumes [DOS list]'
  103.        WHEN y='W' THEN title = 'Waiting Tasks'
  104.        WHEN y='X' THEN title = 'REXX Tasks'
  105.        OTHERWISE
  106.          DO          /* Bad Letter in argument. Complain and die */
  107.            SAY '0C'x
  108.            CALL START
  109.          END
  110.    END
  111.  
  112. /* ARexx scans system lists. This is where the good stuff gets done. */
  113.  
  114.    IF y='X' THEN CALL AStatus()
  115.    ELSE IF((y='C')|(y='F')) THEN list = show(y,,';')
  116.                             ELSE list = showlist(y,,';')
  117.  
  118. /* everything below is just formatting and printing the list to the CLI */
  119. /* based on the longest name in the list, and the number of list items. */
  120.  
  121.    listlength=length(list)    /* length in characters of the whole list */
  122.    longest=0
  123.    j=1
  124.    items=0
  125.    position=1
  126.  
  127.    DO WHILE(position>0)      /* how many total and how long is longest? */
  128.        position=pos(';',list,j) /* <-- returns 0 when the list runs out */
  129.        IF((position-j)>longest) THEN longest=position-j
  130.        IF(position>0) THEN j=position+1
  131.        items=items+1
  132.    END
  133.    IF((listlength+1-j)>longest) THEN longest=listlength+1-j /* last item */
  134.  
  135.    columns = 77%(longest+2)           /* we assume an 80 column display */
  136.    position=1
  137.    count=0
  138.    j=1
  139.    line = ""
  140.    IF(listlength==0) THEN items=0
  141.    SAY  wht'      -*-*-*-'cyn'' items title  ''wht'-*-*-*-'def''||CR
  142.    IF(listlength==0) THEN ITERATE         /* no list, go to next letter */
  143.    DO WHILE(position>0)
  144.        position=pos(';',list,j)
  145.        IF(position>0) THEN
  146.          DO
  147.            nextItem = ""
  148.            nextItem = left(substr(list,j,position-j),longest)
  149.            IF LENGTH(STRIP(nextItem))==0 THEN
  150.              nextItem = left("<blank>",longest)
  151.            line = line || nextItem || '  '
  152.            j = position + 1
  153.          END
  154.        ELSE line = line || left(substr(list,j),longest)
  155.        count = count + 1
  156.        IF(count=columns) THEN
  157.          DO
  158.            SAY yel'' line''||CR
  159.            count=0
  160.            line=""
  161.          END
  162.    END
  163.    IF(count>0) THEN SAY yel'' line''||CR        /* Only print when the line is full */
  164.   SAY CR
  165.   END
  166. END
  167. EXIT
  168.  
  169.  
  170. checkBBS:
  171. IF ADDRESS()~='BAUD' THEN RETURN 0
  172. IF TIME('e')>secs THEN SIGNAL OUT
  173. dcd
  174. IF RC=0 THEN EXIT
  175. temp=secs-TIME('E')
  176. IF temp<120 THEN SAY '*** Only' temp 'seconds left! ***'CR 
  177. RETURN 0
  178.  
  179.  
  180. /* AStatus.rexx   ARexx task list display   by BaudMan */
  181.  
  182. AStatus:
  183. RxsBase = findlib("rexxsyslib.library")
  184. Call RxsOffsets()
  185. TaskList = import(offset(RxsBase,RxsBase.rl_TaskList),4)
  186. n=1
  187. list=""
  188. do j=1 TO 999 WHILE( import(TaskList,4) ~= NULL())
  189.     name=Import(Import(Offset(TaskList,56),4)) 
  190.     if name='' then do
  191.         name='String_'n
  192.         n=n+1
  193.     end
  194.     IF j=1 THEN list=name
  195.     ELSE list=list';'name
  196.     TaskList = import(TaskList,4)
  197. END
  198. RETURN;
  199.  
  200. OUT:
  201.  SAY '0C'X||CR
  202.  SAY CR
  203.  SAY Returning to BBS...||CR
  204.  SAY CR
  205.  CALL DELAY(75)
  206.  EXIT
  207.  
  208.  
  209. /* Find a given library in the system - copied from Status.rexx */
  210. findlib:
  211.     parse arg tofind
  212.     execbase = import('00000004'x,4)
  213.     nodebase = import(offset(execbase, 378), 4)
  214.  
  215.     do while(import(nodebase,4) ~== NULL())
  216.         if import(import(offset(nodebase,10),4)) == tofind then
  217.             return nodebase
  218.         nodebase = import(nodebase,4)
  219.     end
  220.  
  221.     say 'Could not find' tofind||CR
  222.     exit(20)
  223.  
  224. RxsOffsets:
  225. RxsBase.rl_TaskList =168/* List     */
  226. RxsBase.rl_NumTask  =182    /* WORD     */
  227. RxsBase.rl_LibList  =184    /* List     */
  228. RxsBase.rl_NumLib   =198    /* WORD     */
  229. RxsBase.rl_ClipList =200    /* List     */
  230. RxsBase.rl_NumClip  =214    /* WORD     */
  231. RxsBase.rl_MsgList  =216    /* List     */
  232. RxsBase.rl_NumMsg   =230    /* WORD     */
  233. RETURN;
  234.  
  235. BREAK_C:
  236. BREAK_E:
  237. EXIT;
  238.  
  239.  
  240. /* end of ShowList.rexx for BBBBS    6 February 1993 */
  241.