home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 4 / DATAFILE_PDCD4.iso / utilities / utilsf / jfshared / Modules / RecErrors / Make105 < prev    next >
Encoding:
Text File  |  1995-09-23  |  7.0 KB  |  252 lines

  1. App  RecordErrors
  2. In   -
  3. Out  RecErrors
  4. Type Module
  5. Max  32k
  6. Ver  1.05g
  7.  
  8. Define Module
  9.   Name       : RecordErrors
  10.   Version    : 1.05
  11.   Author     : Justin Fletcher
  12.   Init       : StartCode
  13. {  Final      : ExitCode }
  14.   Commands
  15.     Name     : RecordErrors
  16.     Help     : ...
  17.        RecordErrors simply takes all the error messages produced and
  18.        dumps them directly into a file so that they may be read later.
  19.        It is intended for use with the NoError module which click on
  20.        error boxes OK buttons after a moment or two.
  21.   End Commands
  22.   WimpSWIs
  23.     SWI    Wimp_ReportError
  24.     Pre    ^wimpreport
  25.   End WimpSWIs
  26.   WorkSpace 512+16
  27. End Module
  28.  
  29. {
  30. The RecordErrors module
  31. =======================
  32. This program is PD so long as the source and resultant module code are
  33. distributed togther. This code needs to be assembled with !JFPatch
  34. pre-assembler. Refer to the !Help file for more information.
  35.  
  36. History
  37. -------
  38. Version 1.00 : 22nd April 1995
  39.                Written using WimpSWIVe 0.03
  40.         1.01 : 23rd April 1995
  41.                Error from added to message
  42.         1.02 : 24th April 1995 (really late 23rd April 1995)
  43.                Bit 5 checked for incase of auto-checking boxes
  44.         1.03 : 14th May 1995
  45.                Error copied to claimed memory to aleviate filecore bugs
  46.         1.04 : 14th May 1995
  47.                Option to include user name in output
  48.         1.05 : 21 Jun 1995
  49.                Uses automatic assembly for workspace/WimpSWIve
  50. Contact
  51. -------
  52. Any comments, queries, donations or bug reports can be sent to :
  53.  
  54. Fidonet NetMail :  Justin Fletcher at Arcade (0181 655 4412) [2:254/27]
  55. E-Mail : Gerph@arcade.demon.co.uk
  56.  
  57. Snail Mail :
  58.     Justin Fletcher
  59.     “Galadriel”
  60.     17b Cromwell Road,
  61.     Weeting,
  62.     Brandon,
  63.     Suffolk.
  64.     IP27 0QT
  65. }
  66.  
  67. PRE
  68. # COND INLINE
  69. # COND users Do you want to include the users name
  70. END PRE
  71.  
  72. # REM OFF
  73.  
  74. .StartCode
  75.    STMFD   (sp)!,{link}
  76.    ADR     r0,`setupvar
  77.    SWI     "OS_CLI"
  78.    LDMFD   (sp)!,{pc}^
  79. :
  80. .`setupvar
  81.    EQUS    "If ""<RecordErrors$File>"" = """" Then Set RecordErrors$File Null:"+CHR$0
  82.    ALIGN
  83. :
  84. .wimpreport
  85.    STMFD   (sp)!,{r1,r3-r9,link}
  86.    REM     "%I"+CHR$4
  87.    BL      copyerror
  88.    BL      openfile
  89.    BL      endoffile
  90.    BL      showerror
  91.    BL      closefile
  92.    LDMFD   (sp)!,{r1,r3-r9,pc}^
  93. :
  94. .copyerror
  95.    STMFD   (sp)!,{r1,r5,link}            ; Stack registers
  96.    REM     "copying error to %&C"
  97.    LDR     r5,[r0]
  98.    STR     r5,[r12]                      ; copy error number
  99.    ADD     r0,r0,#4                      ; from error
  100.    ADD     r1,r12,#4                     ; to buffer+4
  101.    BL      movectrl                      ; copy the string
  102.    REM     "Second copy routine"
  103.    CMP     r2,#0                         ; is r2 <=0 ?
  104.    BLE     _ce_notaskname                ; if so, no task name
  105.    MOV     r0,r2                         ; from task name
  106.    ADD     r1,r12,#256                   ; to buffer+256
  107.    BL      movectrl                      ; copy the string
  108.    MOV     r2,r0                         ; r2=new task
  109. ._ce_notaskname
  110.    MOV     r0,r12                        ; r0=new error block
  111.    LDMFD   (sp)!,{r1,r5,pc}              ; Return from call
  112.  
  113. .`filename
  114.    EQUS    "<RecordErrors$File>"+CHR$0
  115.    ALIGN
  116. .openfile
  117.    STMFD   (sp)!,{r0-r5,link}
  118.    REM     "Opening"
  119.    MOV     r0,#&C0                  ; open file for update
  120.    ADR     r1,`filename
  121.    SWI     "XOS_Find"
  122.    CMP     r0,#0
  123.    MOVEQ   r0,#&80                  ; if not found output
  124.    SWIEQ   "XOS_Find"
  125.    MOV     r8,r0                    ; r8 = file handle
  126.    LDMFD   (sp)!,{r0-r5,pc}
  127. :
  128. .closefile
  129.    STMFD   (sp)!,{r0-r5,link}
  130.    REM     "Closing"
  131.    MOV     r1,r8
  132.    MOV     r0,#0
  133.    SWI     "XOS_Find"               ; close file
  134.    MOV     r0,#18                   ; settype code
  135.    ADR     r1,`filename
  136.    MOV     r2,#&F00
  137.    ADD     r2,r2,#&FF               ; as text
  138.    SWI     "XOS_File"
  139.    LDMFD   (sp)!,{r0-r5,pc}
  140. :
  141. .endoffile
  142.    STMFD   (sp)!,{r0-r5,link}
  143.    REM     "Moving to end of file"
  144.    MOV     r0,#2                    ; read length of file
  145.    MOV     r1,r8                    ; file handle
  146.    SWI     "XOS_Args"
  147.    MOV     r0,#1                    ; write PTR#file
  148.    SWI     "XOS_Args"               ; PTR#file=EXT#file !
  149.    LDMFD   (sp)!,{r0-r5,pc}
  150. :
  151. .putstring
  152. ; string at r2 into file
  153.    STMFD   (sp)!,{r0-r5,link}
  154.    REM     "Putting string"
  155.    BL      putstringsemi
  156.    BL      putnewline
  157.    LDMFD   (sp)!,{r0-r5,pc}^
  158. :
  159. .putnewline
  160.    STMFD   (sp)!,{r0-r5,link}
  161.    MOV     r1,r8                    ; file handle
  162.    MOV     r0,#10
  163.    SWI     "XOS_BPut"
  164.    LDMFD   (sp)!,{r0-r5,pc}^
  165. :
  166. .putstringsemi
  167. ; string at r2 into file without linefeed (semicolon at end!)
  168.    STMFD   (sp)!,{r0-r5,link}
  169.    REM     "Putting"
  170. ;   MOV     r0,r2
  171. ;   SWI     "OS_Write0"
  172. ;   SWI     "OS_NewLine"             ; 3 testing line ^
  173.    MOV     r1,r8                    ; file handle
  174. .psloop
  175.    LDRB    r0,[r2],#1
  176.    CMP     r0,#32
  177.    SWIGE   "XOS_BPut"
  178.    BGE     psloop
  179.    LDMFD   (sp)!,{r0-r5,pc}^
  180. :
  181. ;if bit 5 is set (exit now), and bit 6 set (press button) then output
  182. ;if bit 5 is set (exit now), and bit 6 clear (no button press) then no output
  183. ;if bit 5 is clear (exit when clicked) then output
  184. .showerror
  185.    STMFD   (sp)!,{r0-r5,link}
  186.    EOR     r1,r1,#1<<6              ; invert bit six for check below
  187.    TST     r1,#1<<5                 ; is bit 5 set (exit immediately)
  188.    TSTNE   r1,#1<<6                 ; if so, check bit 6 (press button)
  189.    LDMNEFD (sp)!,{r0-r5,pc}         ; Return from call if
  190.    ADR     r2,`header
  191.    BL      putstring
  192.    ADR     r2,`titleleft
  193.    BL      putstringsemi
  194.    TST     r1,#1<<4                 ; is ‘just title’ flag set ?
  195.    ADREQ   r2,`errorfrom            ; if not then add error from
  196.    BLEQ    putstringsemi
  197.    LDMFD   (sp),{r0-r2}             ; reread registers
  198.    CMP     r2,#0
  199.    ADRLE   r2,`unknown
  200.    BL      putstring
  201.    ADR     r2,`messageleft
  202.    BL      putstringsemi
  203.    ADD     r2,r0,#4
  204.    BL      putstring
  205. # COND OF users
  206.    ADR     r0,`uservar                   ; variable to read
  207.    ADD     r1,r12,#512                   ; buffer
  208.    MOV     r2,#16                        ; length of buffer
  209.    MOV     r3,#0                         ; count
  210.    MOV     r4,#3                         ; convert to string
  211.    SWI     "XOS_ReadVarVal"              ; read it
  212.    BVS     _se_nousername                ; if error
  213.    MOV     r0,#0
  214.    STRB    r0,[r1,r2]                    ; terminate string
  215.    ADR     r2,`userleft                  ; address of bit before user
  216.    BL      putstringsemi                 ; put it
  217.    MOV     r2,r1                         ; ready for username
  218.    BL      putstring                     ; put it
  219. ._se_nousername
  220. # COND END
  221.    BL      putnewline
  222.    LDMFD   (sp)!,{r0-r5,pc}
  223. :
  224. .`header
  225.    EQUS    "**Error**"+CHR$0
  226.    ALIGN
  227. .`titleleft
  228.    EQUS    "  Title   : "+CHR$0
  229.    ALIGN
  230. .`messageleft
  231.    EQUS    "  Message : "+CHR$0
  232.    ALIGN
  233. .`errorfrom
  234.    EQUS    "Error from "+CHR$0
  235.    ALIGN
  236. .`unknown
  237.    EQUS    "unknown task"+CHR$0
  238.    ALIGN
  239. # COND OF users
  240. .`userleft
  241.    EQUS    "  User    : "+CHR$0
  242.    ALIGN
  243. .`uservar
  244.    EQUS    "Area$Name"+CHR$0
  245.    ALIGN
  246. # COND END
  247.  
  248. # LIBRARY "Strings",#movectrl
  249.  
  250. #POST
  251. #RUN <CODE>
  252.