Condition Inside Try And Catch()


dle

Recommended Posts

some time it works with the script below but most of the time it won't catch.

 

//Assume one of the parameter is empty 

//A is a channel

Private Error = 1

Private String FileHandle = File.Open(Directory,0,1,1,1)

Try

 If ( A == 0)

    File.Write(FileHandle, Test_Result[][0]+","+Test_Result[][1]+.........)

Else

   File.Write(FileHandle, Test_Result[][10]+","Test_Result[][9]+..........)

Endif

  File.CloseAll() 

 Error = 0

Catch()

  File.CloseAll()

  System.MessageBox("One of the parameter is empty","Help")

Endcatch

 

If (Error == 0)

  System.MessageBox("Successsfully saved","Help")

Endif

 

I mostly receive the message "Successfully saved", and the data is not updated to the file. just 1 out of 20 time it will throw me my error message in the Catch.

 

However, if I do the below

 

Try

    File.Write(FileHandle, Test_Result[][0]+","+Test_Result[][1]+.........)

    File.CloseAll()

    Error = 0

 

Catch()

  File.CloseAll()

  System.MessageBox("One of the parameter is empty","Help")

Endcatch

 

If (Error == 0)

  System.MessageBox("Successsfully saved","Help")

Endif

 

It will always throw me the error message "One of the parameter is empty" if there is an empty parameter.

 

 

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.