ich habe 2 Funktionen in verschiedenen Modulen:
1. Modul heißt getCurDir, die Funktion darin heißt getCurDir$()
2. Modul heißt getFileLocations, die Funktion darin heißt getFileLocations$()
Die Funktion im 1. Modul wird von der Funktion im 2. Modul aufgerufen.
getFileLocations$() wird von einer Testroutine (Sub test), die sich einem 3. Modul Modul1 befindet, gestartet.
Problem:
Wenn ich alle Funktionen zusammen mit der Sub in einem Modul habe, klappt alles prima.
Wenn ich die Funktionen und die Sub auf verschiedene Module verteile klappt nichts mehr.
Ich habe die o.g. Module in eine Bibliothek namens HTML_Code_Generator eingehängt.
Die Bibliothek hängt an einem Formular einer Datenbank.
Der Code von Modul "getCurDir":
Code: Alles auswählen
'----------------------------------------------------------------
' Function: getCurDir$()
' Author: keyboard-billy
' Version: 1.00
' Date: 28.02.2007
' Description: Die Funktion emittelt unabhängig vom genutzen
' Betriebssystem das aktuelle Programmverzeichnis.
' Der Rückgabewert erfolgt in URL-Notation.
'----------------------------------------------------------------
Option Explicit
Function getCurDir$(fileName$)
GlobalScope.BasicLibraries.LoadLibrary("Tools")
Dim oDocs As Object, oDoc As Object, oComponents As Object
Dim FileN$, DirName$, URL$
Dim found As Boolean : found = false
oComponents = StarDesktop.getComponents() 'Alle geöffneten Komponenten ermitteln
oDocs = oComponents.createEnumeration() 'Index für alle geöffneten Komponenten erstellen
Do While oDocs.hasMoreElements() 'Suchroutine
oDoc = oDocs.nextElement()
On Error Goto go_on
URL$ = oDoc.getURL()
FileN$ = FileNameoutofPath(URL$) 'Funktion der Globalen Bibliothek "Tools"
If FileN$ = fileName$ Then
DirName$ = DirectoryNameoutofPath(URL$, "/") 'Funktion der Globalen Bibliothek "Tools"
found = true
End If
go_on:
Loop
If found = false Then
MsgBox ("Die Datei """ & fileName$ & """ ist zur Zeit nicht geöffnet!", 48, "Fehler")
End If
getCurDir$ = DirName$
End Function
Code: Alles auswählen
'----------------------------------------------------------------
' Function: getFileLocations$()
' Author: keyboard-billy
' Version: 1.00
' Date: 28.02.2007
' Description: Die Funktion sucht im aktuellen
' Programmverzeichnis nach einer Template-Datei
' {Dokumentname}.ini
' Anschliessend wird die ini-Datei nach
' den Parametern "Template_Path", "Template_File"
' "Output_Path" und "Output_File" abgesucht.
' Die zugehörigen Parameter werden ausgelesen und
' in den öffentlichen Variablen "templatePath$",
' "templateFile$", "outputPath$" und "outputFile$"
' abgelegt.
'----------------------------------------------------------------
Option Explicit
'Global documentName$
'Global templatePath$, templateFile$
'Global outputPath$, outputFile$
Public documentName$
Public templatePath$, templateFile$
Public outputPath$, outputFile$
Function getFileLocations$(documentName$)
Dim fileP$, iniFile$, recordLine$, text$
Dim tmp$(2)
Dim fileMask%, inputFileHandle%
Dim pos% : pos% =1
Dim lPos%, uPos%
iniFile$ = Left((documentName$),Len("documentName$")-3) & ".ini" 'Dateiname der Datei {documentName$}.ini
If getCurDir$(documentName$) <> "" Then
fileP$ = getCurDir$(documentName$)
If FileExists(fileP$ & "/" & iniFile$) Then 'Verzeichnis-Separator ist "/" in URL-Notation!
'ini-Datei einlesen
inputFileHandle% = Freefile()
Open fileP$ & "/" & iniFile$ For Input As #inputFileHandle
Do While Not EOF(#inputFileHandle)
Line Input #inputFileHandle, recordLine$
'Parser
If InStr(pos%, recordLine$,"Template_Path=") <> 0 Then
tmp$ = Split(recordLine$, "=", 2)
templatePath$ = tmp$(1)
End If
If InStr(pos%, recordLine$,"Template_File=") <> 0 Then
tmp$ = Split(recordLine$, "=", 2)
templateFile$ = tmp$(1)
End If
If InStr(pos%, recordLine$,"Output_Path=") <> 0 Then
tmp$ = Split(recordLine$, "=", 2)
outputPath$ = tmp$(1)
End If
If InStr(pos%, recordLine$,"Output_File=") <> 0 Then
tmp$ = Split(recordLine$, "=", 2)
outputFile$ = tmp$(1)
End If
Loop
Close #inputFileHandle
Else
'ini-Datei nicht vorhanden
MsgBox("Datei """& iniFile$ & """ in Pfad """ & _
ConvertFromURL(fileP$) & """ nicht vorhanden!", 48, "Fehler")
End If
End If
End Function
Code: Alles auswählen
Sub test
getFileLocations$("Repertoire.odb") 'getFileLocations$({Dateiname des Dokuments})
MsgBox("Template_Path=""" & templatePath$ & """" & chr$(13) & _
"Template_File=""" & templateFile$ & """" & chr$(13) & _
"Output_Path=""" & outputPath$ & """" & chr$(13) & _
"Output_File=""" & outputFile$ & """" & chr$(13))
End Sub
Ich hab' die Variablen im Modul "getFileLocations" auch schon als Global deklariert. Aber das bringt auch nix.
Ich mach hier bestimmt was ganz elementares falsch

Greetz,
keyboard-billy