DIAdem API Reference

Function: TextFileError

  • 已更新2023-02-21
  • 閱讀時間為 1 分鐘

Checks whether an error occurs when you open, write, or read a text file.

ReturnValue = TextFileError(TextFileHandle)

Input Parameters

TextFileHandle Specifies the handle of the text file.
Use the return value of the TextFileOpen function.

Return Parameters

ReturnValueReturns a numeric value. If an error occurs, the function returns the value -1.

Examples

The following example attempts to open the text file OldText.txt. However, DIAdem does not find this text file in the DIAdem folder and the TextFileOpen function returns an error. The example then jumps into the subroutine for dealing with errors and displays the error number and the associated error text.

VBScriptPython

 

Dim intMyHandle, intMyError
intMyHandle = TextFileOpen("OldText.txt",eTextFileAttributeRead)
If intMyHandle = -1 Then
  Call MsgError(intMyHandle)
Else
  Call MsgBoxDisp( "Text file can be read.",_
                   "MB_OK","MsgTypeInformation",,5) 
  intMyError = TextFileClose(intMyHandle)
End If

Sub MsgError(FileNo)
 Call MsgboxDisp("Error number: " & TextFileError(FileNo) & VbCrLf & _
 "error message: " & TextFileErrorTxT(FileNo)) 'Show error number and error message
End Sub

Related Functions

Command: TextFileEncoding | Command: TextFileEOL | Function: FR | Function: TextFileEOF | Function: TextFileErrorTxt | Function: TextFileSeek