home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 562.lha / ReturnCode / LogRC.asm < prev    next >
Assembly Source File  |  1991-08-06  |  2KB  |  98 lines

  1. ; LogRC             ..           Jim Butterfield 1991Apr19
  2. ; CLI only .. puts <return> status into ENV file RETURN<n>
  3. ; thus, a script could say;
  4. ;          <.. some program..>
  5. ;          LogRC
  6. ;          IF $RETURN<$$>="WARN"
  7. ;               ...
  8. ;          ENDIF
  9. ;          IF $RETURN<$$>="ERROR"
  10. ;               ...                    etc.
  11. ;
  12. ; exec calls
  13. _LVOOpenLibrary   EQU -$228
  14. _LVOCloseLibrary  EQU -$19E
  15. ThisTask          EQU $114
  16. ; dos calls
  17. _LVOOpen          EQU -$1E
  18. _LVOClose         EQU -$24
  19. _LVOWrite         EQU -$30
  20. ; process structure
  21. pr_TaskNum        EQU $8C
  22. pr_CLI            EQU $AC
  23.  
  24.         lea    dosName(pc),a1
  25.         moveq  #0,d0
  26.         move.l 4.w,a6
  27.         move.l ThisTask(a6),a5
  28.         move.l pr_TaskNum(a5),d6
  29.         jsr    _LVOOpenLibrary(a6)
  30.         move.l d0,a6
  31.         moveq  #5,d7        ; WARN
  32.         tst.l  d0
  33.         beq    exit
  34. ; d6 contains CLI number for decimal conversion
  35.         link   a3,#-$20
  36.         move.l a3,a2
  37.         move.b #0,-(a2)   ; EndString
  38. Digit   divu.w #10,d6
  39.         swap   d6
  40.         or.b   #$30,d6
  41.         move.b d6,-(a2)
  42.         move.b #0,d6
  43.         swap   d6
  44.         bne.s  Digit
  45.         moveq  #9,d0
  46.         lea    Stem(pc),a0
  47. GetStem move.b 0(a0,d0.w),-(a2)
  48.         dbf    d0,GetStem
  49.         move.l a2,d1
  50.         move.l #1006,d2
  51.         jsr    _LVOOpen(a6)
  52.         unlk   a3        
  53.         move.l d0,d4
  54.         beq.s  dosExit
  55. ; now analyze the return value and deliver it to $RETURN
  56.         lea    bMess(pc),a0
  57.         move.l pr_CLI(A5),a4
  58.         add.l  a4,a4
  59.         add.l  a4,a4
  60.         move.l $C(a4),d7     ; return code
  61.         bmi.s  SayIt
  62.         lea    kMess(pc),a0
  63.         beq.s  SayIt
  64.         lea    mMess(pc),a0
  65.         cmp    #5,d7
  66.         bcs.s  SayIt
  67.         lea    wMess(pc),a0
  68.         cmp    #10,d7
  69.         bcs.s  SayIt
  70.         lea    eMess(pc),a0
  71.         cmp    #20,d7
  72.         bcs.s  SayIt
  73.         lea    fMess(pc),a0
  74. SayIt   move.l d4,d1
  75.         move.l a0,d2
  76.         moveq  #0,d3
  77. SayLp   addq.w #1,d3
  78.         cmp.b  #$A,-1(a0,d3.w)
  79.         bne.s  SayLp
  80.         jsr    _LVOWrite(a6)
  81.  
  82.         move.l d4,d1
  83.         jsr    _LVOClose(a6)       
  84. dosExit move.l a6,a1
  85.         move.l 4.w,a6
  86.         jsr    _LVOCloseLibrary(a6)
  87. exit    move.l d7,d0
  88.         rts
  89.         dc.b '$VER:LogRC 1.0',$A
  90. dosName dc.b 'dos.library',0
  91. Stem    dc.b 'ENV:Return'
  92. bMess   dc.b 'BAD',$A
  93. kMess   dc.b 'OK',$A
  94. mMess   dc.b 'MINOR',$A
  95. wMess   dc.b 'WARN',$A
  96. eMess   dc.b 'ERROR',$A
  97. fMess   dc.b 'FAIL',$A
  98.