Trap a very intermittent write error on XP machine

Getting started -basics for starting with WinTask

Trap a very intermittent write error on XP machine

Postby Carroll on Mon Sep 23, 2013 10:18 am

PROBLEM TEST CODE:

1) THIS WORKS:

Execute WINTASK program that write to a valid path:
a = write("c:\x.txt","record 1",CRLF)

2) THIS IS THE PROBLEM:

When I execute WINTASK program that writes to an invalid path:
a = write("e:\x.txt","record 2",CRLF)

The popup Execution error occurs.
I need to trap the error, pause, and re-write


I tried this:
a = write("e:\x.txt","record 2",CRLF)

Sub Process_Error()
beep(3000)
endaction

OnAction error
dosub Process_Error
endaction

It did not compile . . . .

How should I do?
Carroll
 
Posts: 9
Joined: Tue Aug 30, 2005 2:13 pm

Re: Trap a very intermittent write error on XP machine

Postby TechSupport on Tue Sep 24, 2013 7:13 am

Hello,

For your compilation error, just move the Write line at the end. Subs must be at the beginning of the script.

But you don't need to use that, the system variable #IgnoreErrors=1 prevents execution errors message from displaying. And you can test the return code of the function in order to see if it has successfully written or not.
Code: Select all
'Tell WinTask ignore the error if the write fails
#IgnoreErrors=1
   ret= write("e:\x.txt","record 2",CRLF)
   If ret<> 0 then
      'write is not successfull, put here the lines which have to be executed in this case
   Else
      msgbox("write successfull")
   EndIf
'come back to the standard way of managing errors in WinTask
#IgnoreErrors=0


Regards.
WinTask Tech Support
TechSupport
 
Posts: 805
Joined: Thu Nov 16, 2006 9:58 am


Return to Getting started

Who is online

Users browsing this forum: No registered users and 1 guest

cron