Last active
April 1, 2020 07:21
-
-
Save nonkit/f5701dc5342d2bf8620102ffabc7ae65 to your computer and use it in GitHub Desktop.
Small Basic Pseudo File Object
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sub File_CheckResult | |
' File | check File operation result | |
' param result, dirs or files - result of a File operation | |
' param op - name of File operation | |
If (op = "GetDirectories") And (dirs = "FAILED") Then | |
FileHelper_ShowError() | |
ElseIf (op = "GetFiles") And (files = "FAILED") Then | |
FileHelper_ShowError() | |
ElseIf result = "FAILED" Then | |
FileHelper_ShowError() | |
EndIf | |
EndSub |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sub File_Exists | |
' File | check a file exists | |
' param["path"] - the full path of the file that needs to be checked | |
' return fileExists - "True" if the file exists | |
fileExists = "False" | |
File_SplitDirectory() | |
files = File.GetFiles(directoryName) | |
op = "GetFiles" | |
File_CheckResult() | |
nFiles = Array.GetItemCount(files) | |
For i = 1 To nFiles | |
If Text.ConvertToLowerCase(files[i]) = Text.ConvertToLowerCase(param["path"]) Then | |
fileExists = "True" | |
i = nFiles ' exit For | |
EndIf | |
EndFor | |
EndSub |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sub File_SplitDirectory | |
' File | split directory name | |
' param["path"] - the full path to be gotton directory name | |
' return directoryName - the directory name | |
directoryName = "" | |
For p = Text.GetLength(param["path"]) To 1 Step -1 | |
c = Text.GetSubText(param["path"], p, 1) | |
If c = "\" Or c = "/" Then | |
directoryName = Text.GetSubText(param["path"], 1, p - 1) | |
p = 1 ' exit For | |
EndIf | |
EndFor | |
EndSub |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sub FileHelper_ShowError | |
' File Helper | show last errer | |
' param op - oparation name | |
' param indent - indent space if needed | |
TextWindow.ForegroundColor = "Yellow" | |
TextWindow.WriteLine(indent + op + ":FAILED") | |
TextWindow.WriteLine(indent + "LastError:" + File.LastError) | |
TextWindow.ForegroundColor = "Gray" | |
EndSub |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Variables
op
,dirs
,files
andindent
should be initialized before usingFile_CheckResult
subroutine.