Attribute VB_Name = "Org" ''+--------------------------------------+ ''| ICI Organizer database access module | ''+--------------------------------------+ ''| Made by Jure Sah of MesonAI | ''| TimeDateStamp: 17:15 16.8.2004 | ''+--------------------------------------+ '' ''Type "Org." in the VB code editing screen to get ''a list of functions and subroutines this module ''provides. Each subroutine or function does what ''it's name suggests and all parameters and their ''formats are just as obvious. '' ''This module provides a simplified interface to ''the file Organizer system that ICI AFTP's ''file organizer uses. The advantage of using ''this interface is that diffirent applications ''using this same module are then compatible and ''a user-interface to the data kept this way is ''then already provided by the AFTP program. Public xoDefPath As String Public oxTmpFileList(1000) As String Public oxTmpFileListLen As Integer Public oxTmpAltList(1000) As String Public oxTmpAltListLen As Integer Public Sub xoCreateRootEntry(xAppName As String) If Not Debugging Then On Error Resume Next If Trim$(xoDefPath) = "" Then xoInnitDefPath Data.xSet Data.xFileLoc, xAppName + " databanks", xoDefPath + "Databank.loc" Data.xCreate xoDefPath + "Databank.loc" End Sub Public Function xoGetRootPath(xAppName As String) As String If Not Debugging Then On Error Resume Next xoGetRootPath = Data.xQuery(Data.xFileLoc, xAppName + " databanks") If Trim$(xoGetRootPath) = "" Then xoCreateRootEntry xAppName xoGetRootPath = xoDefPath + "Databank.loc" End If End Function Public Sub xoRemoveDataBank(xAppName As String, xDataBankName As String, xDelete As Boolean) If Not Debugging Then On Error Resume Next tmpDataBankPath$ = xoGetDataBankPath(xAppName, xDataBankName) Data.xSet tmpRootPath$, xDataBankName, "" If xDelete Then Data.xRemove tmpDataBankPath$ End Sub Public Sub xoAddDataBank(xAppName As String, xDataBankName As String) If Not Debugging Then On Error Resume Next tmpRootPath$ = xoGetRootPath(xAppName) tmpDataBankPath$ = xoDefPath + xDataBankName Data.xSet tmpRootPath$, xDataBankName, tmpDataBankPath$ Data.xCreate tmpDataBankPath$ End Sub Public Function xoDoesDataBankExist(xAppName As String, xDataBankName As String) As Boolean tmpRootPath$ = xoGetRootPath(xAppName) tmpDataBankPath$ = Data.xQuery(tmpRootPath$, xDataBankName) xoDoesDataBankExist = (Trim$(tmpDataBankPath$) <> "") End Function Public Function xoGetDataBankPath(xAppName As String, xDataBankName As String) As String If Not Debugging Then On Error Resume Next tmpRootPath$ = xoGetRootPath(xAppName) xoGetDataBankPath = Data.xQuery(tmpRootPath$, xDataBankName) If Trim$(xoGetDataBankPath) = "" Then Org.xoAddDataBank xAppName, xDataBankName End If End Function Public Sub xoAddFile(xAppName As String, xDataBankName As String, xFile As String) If Not Debugging Then On Error Resume Next Dim tmpFile As String tmpFile = xFile If InStr(tmpFile, ":/") = 0 Then tmpFile = Data.xFixName(tmpFile) tmpFile = "ici://" + STATUS.xGetLocalID + "/" + tmpFile End If tmpDataBankPath$ = xoGetDataBankPath(xAppName, xDataBankName) Data.xAppendSerial tmpDataBankPath$, "File", tmpFile End Sub Public Sub xoRemoveFile(xAppName As String, xDataBankName As String, xFile As String) If Not Debugging Then On Error Resume Next Dim tmpFile As String tmpFile = xFile If InStr(tmpFile, ":/") = 0 Then tmpFile = Data.xFixName(tmpFile) tmpFile = "ici://" + STATUS.xGetLocalID + "/" + tmpFile End If tmpDataBankPath$ = xoGetDataBankPath(xAppName, xDataBankName) Data.xRemoveSerial tmpDataBankPath$, "File", tmpFile End Sub Public Sub xoClearFileList() If Not Debugging Then On Error Resume Next For x = 0 To 1000 oxTmpFileList$(x) = "" Next x oxTmpFileListLen = -1 End Sub Public Sub xoLoadFileList(xAppName As String, xDataBankName As String) If Not Debugging Then On Error Resume Next tmpDataBankPath$ = xoGetDataBankPath(xAppName, xDataBankName) oxTmpFileListLen = -1 FNs = FreeFile Open tmpDataBankPath$ For Input As #FNs For c = 1 To Data.xNumberOfLines(tmpDataBankPath$) Line Input #FNs, tmp$ tmpP$ = Data.xLine2Property(tmp$) tmpV$ = Data.xLine2Value(tmp$) If LCase$(Left$(Trim$(tmpP$), 4)) = "file" Then cc = Data.xExtractPropertySerial(tmpP$) oxTmpFileList$(cc) = tmpV$ If oxTmpFileListLen < cc Then oxTmpFileListLen = cc End If Next c Close #FNs End Sub Public Function xoIsFileAlready(xAppName As String, xDataBankName As String, xFile As String) As Boolean If Not Debugging Then On Error Resume Next Dim tmpBoo As Boolean tmpBoo = False tmpDataBankPath$ = xoGetDataBankPath(xAppName, xDataBankName) FNl = FreeFile Open tmpDataBankPath$ For Input As #FNl For c = 1 To Data.xNumberOfLines(tmpDataBankPath$) Line Input #FNl, tmp$ tmpP$ = Trim$(Data.xLine2Property(tmp$)) tmpV$ = Trim$(Data.xLine2Value(tmp$)) If LCase$(Left$(tmpP$, 4)) = "file" Then If Right$(LCase$(tmpV$), Len(xFile)) = LCase$(xFile) Then tmpBoo = True: Exit For 'Debug.Print LCase$(tmpV$); LCase$(xFile) End If Next c Close #FNl xoIsFileAlready = tmpBoo End Function Public Sub xoSaveFileList(xAppName As String, xDataBankName As String) If Not Debugging Then On Error Resume Next tmpDataBankPath$ = xoGetDataBankPath(xAppName, xDataBankName) For c = 0 To oxTmpFileListLen Data.xSet tmpDataBankPath$, "File" + Trim$(CStr(c)), oxTmpFileList$(c) Next c Data.xRemoveEntry tmpDataBankPath$, "File" + Trim$(CStr(oxTmpFileListLen + 1)) End Sub Public Sub xoSaveAltList(xAppName As String, xDataBankName As String, xListTypeName As String) If Not Debugging Then On Error Resume Next tmpDataBankPath$ = xoGetDataBankPath(xAppName, xDataBankName) For c = 0 To oxTmpAltListLen Data.xSet tmpDataBankPath$, xListTypeName + Trim$(CStr(c)), oxTmpAltList$(c) Next c Data.xRemoveEntry tmpDataBankPath$, "File" + Trim$(CStr(oxTmpAltListLen + 1)) End Sub Public Sub xoLoadAltList(xAppName As String, xDataBankName As String, xListTypeName As String) If Not Debugging Then On Error Resume Next tmpDataBankPath$ = xoGetDataBankPath(xAppName, xDataBankName) oxTmpAltListLen = -1 FNs = FreeFile Open tmpDataBankPath$ For Input As #FNs For c = 1 To Data.xNumberOfLines(tmpDataBankPath$) Line Input #FNs, tmp$ tmpP$ = Data.xLine2Property(tmp$) tmpV$ = Data.xLine2Value(tmp$) If LCase$(Left$(Trim$(tmpP$), Len(Trim$(xListTypeName)))) = LCase$(Trim$(xListTypeName)) Then cc = Data.xExtractPropertySerial(tmpP$) oxTmpAltList$(cc) = tmpV$ If oxTmpAltListLen < cc Then oxTmpAltListLen = cc End If Next c Close #FNs End Sub Public Function xoAltListAsString(xDelimeter As String) As String Dim tmpS As String tmpS = "" For x = 0 To oxTmpAltListLen tmpS = tmpS + oxTmpAltList$(x) + xDelimeter Next x xoAltListAsString = tmpS End Function Public Function xoFileListAsString(xDelimeter As String) As String Dim tmpS As String tmpS = "" For x = 0 To oxTmpFileListLen tmpS = tmpS + oxTmpFileList$(x) + xDelimeter Next x xoFileListAsString = tmpS End Function Public Sub xoSetSetting(xAppName As String, xSetting As String, xValue As String) If Not Debugging Then On Error Resume Next tmpDataBankPath$ = xoGetDataBankPath(xAppName, "Settings") Data.xSet tmpDataBankPath$, xSetting, xValue End Sub Public Function xoQuerySetting(xAppName As String, xSetting As String) As String If Not Debugging Then On Error Resume Next tmpDataBankPath$ = xoGetDataBankPath(xAppName, "Settings") xoQuerySetting = Data.xQuery(tmpDataBankPath$, xSetting) End Function Public Sub xoInnitDefPath() If Not Debugging Then On Error Resume Next tmp$ = App.Path If Right$(tmp$, 1) <> "\" Then tmp$ = tmp$ + "\" xoDefPath = tmp$ End Sub