Code: Check the given file exists or not
'----------------------------------
' Method : FileExists
' Author : T.Palani Selvam
' Purpose : Check the given file exists or not. PhaseII
' Parameters: sFile, String - Contains a file name.
' Returns : Returns Integer data type(True or False.)
' Caller : SwitchSpecialTags
' Calls : - Nil
'-----------------------------
Function FileExists(sFile As String)As Integer
Dim iPosition As Integer
Dim sDir As String, sTFile As String, sTemp As String
FileExists = False
sTFile = sFile
iPosition = Instr(sFile,"::")
If (iPosition <> 0) Then
sDir = Mid$(sFile,iPosition + 2)
sTemp = Left(sFile, iPosition - 1)
If (Instr(sTemp,":\") <> 0 ) Then
sTFile = sTemp
Else
If (Right$(Trim(sDir),1) <> "\") Then
sDir = Trim(sDir) + "\"
End If
sTFile = sDir + sTemp
End IF
End If
If Exists(sTFile,"-d") Then
FileExists = True
Logwrite( "Successful - Existing file is " + sTFile , 1)
Else
Logwrite( sTFile + " - File doesn't exist.", 1)
End IF
End Function
Code: Check whether the given folder exists or not
'----------------------------
' Method : FolderExists
' Author : T.Palani Selvam
' Purpose : Check the given folder exists or not.(PhaseII)
' Parameters: sFolder, String - Contains a folder name.
' Returns : Returns Integer data type(True or False.)
' Caller : SwitchSpecialTags
' Calls : - Nil
'---------------------------
Function FolderExists(sFolder As String)As Integer
FolderExists = False
If (Right$(Trim(sFolder),1) = "\") Then
sFolder = Trim(sFolder)
sFolder = Left$(sFolder, Len(sFolder) -1 )
End If
If Exists(sFolder,"+d") Then
FolderExists = True
Logwrite( "Successful - Existing Directory is " + sFolder , 1)
Else
Logwrite( sFolder + " - Directory doesn't exist.", 1)
End IF
End Function
Code: Check whether the given string exists in the given file or not.
'-----------------------------
' Method : StringExists
' Author : T.Palani Selvam
' Purpose : 'Check whether the given string exists in the given file or not.
' Parameters: sFile as String, Contains a file name with full path.
' sWord - String , Consists of string to check into the file.
' Returns : Returns Integer value
' Caller : OperationIdentifier()
' Calls : - Nil
'-------------------------
Function StringExists(sFile As String,sWord As String)As Integer
Dim fNumber As Long
Dim sLine As String
Dim iInt As Integer
fNumber=FREEFILE
StringExists=False
iInt =0
OPEN sFile For Input As #fNumber
While not eof(fNumber)
Line Input #fNumber,sLine
sLine = Trim (sLine)
IF (Instr(sWord,sLine)<>0 AND Len(sLine) > 1) Then
PRINT sLine, "String Exists!"
iInt = iInt + 1
If (iInt > 3) Then
StringExists=True
Exit Function
End IF
End If
Wend
CLOSE #fNumber
End Function
No comments:
Post a Comment