Seite 1 von 2

Conifg Files und die Benutzung

Verfasst: 31.05.2008 09:49
von Fox
Hi, ich bin bei meinem Netzwerk Sync Programm nun fast fertig...
Aber nun habe ich ein Problem beim auslesen meiner Cofig Files...
Ich weiss nicht was ich machen muss... Er gibt mir ne Fehlermeldung
Case without Select aus aber was soll ich denn da machen?
Hier mal mein kompletter Source

Code: Alles auswählen

 
#TreeGadget = 0 

Procedure ReadDirs(Path.s, Rek.l) 
  If Right(Path, 1) = "\" : Path = Left(Path, Len(Path) - 1) : EndIf 
  
  NextOK.l 
  Name.s 
  ExamineDirectory(Rek, Path, "") 
  
  Repeat 
    NextOK = NextDirectoryEntry(Rek) 
    Name = DirectoryEntryName(Rek) 
    If NextOK = 2 And Name <> "." And Name <> ".." 
      ReadDirs(Path + "\" + Name, Rek + 1) 
      While WindowEvent() : Wend 
    ElseIf NextOK = 1 
      AddGadgetItem(0, -1, Path + "\" + Name) 
    EndIf 
  Until NextOK = #False 
EndProcedure 


Procedure ReadDir(Path.s, Rek.l) 
  If Right(Path, 1) = "\" : Path = Left(Path, Len(Path) - 1) : EndIf 
  
  NextOK.l 
  Name.s 
  ExamineDirectory(Rek, Path, "") 
  
  Repeat 
    NextOK = NextDirectoryEntry(Rek) 
    Name = DirectoryEntryName(Rek) 
    If NextOK = 2 And Name <> "." And Name <> ".." 
      ReadDirs(Path + "\" + Name, Rek + 1) 
      While WindowEvent() : Wend 
    ElseIf NextOK = 1 
      AddGadgetItem(1, -1, Path + "\" + Name) 
    EndIf 
  Until NextOK = #False 
EndProcedure 




Enumeration
  #Window_0
EndEnumeration

;
Enumeration
  #Listview_0
  #Listview_1
  #Button_0
  #Button_1
  #Button_2
EndEnumeration


  If OpenWindow(#Window_0, 216, 0, 600, 346, "Netzwerk Sync",  #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_TitleBar )
    If CreateGadgetList(WindowID(#Window_0))
      ListViewGadget(#Listview_0, 325, 10, 235, 265)
      ListViewGadget(#Listview_1, 15, 10, 235, 265)
      ButtonGadget(#Button_0, 255, 95, 65, 35, "-->")
      ButtonGadget(#Button_1, 255, 155, 65, 35, "<--")
      ButtonGadget(#Button_2, 195, 320, 170, 20, "Configuartion")
            ReadDirs("\\User\SharedDocs", 0) 
                  ReadDir("C:\", 1) 
     Repeat 
      event=WaitWindowEvent() 
      Select event 
        Case #PB_Event_Gadget 
          Select EventGadget() 
Case #Button_0  
  n = 3 
If ReadFile(0, "config.ini")      
  For z = 1 To n-1 
    ReadString(0) 
  Next      
  CloseFile(0)                
Else 
  MessageRequester("","Config File not found") 
     
     
     n = 7
If ReadFile(1, "config.ini")      
  For z = 1 To n-1 
    ReadString(1) 
  Next      
  CloseFile(1)                
Else 
  MessageRequester("","Config File not found") 

       CopyDirectory(ReadString(0), ReadString(1), "", #PB_FileSystem_Recursive)
     MessageRequester("","Synchronizing finished")
     
Case #Button_1 
       CopyDirectory("\\User\SharedDocs\bilder", "C:\", "", #PB_FileSystem_Recursive)       
Case #Button_2       
 XIncludeFile "config.pb"
  Repeat 
    Until WaitWindowEvent() = #PB_Event_CloseWindow
  End
   End
          EndSelect 
      EndSelect 
    Until event=#PB_Event_CloseWindow 
  EndIf 
EndIf 
  EndIf
  
Hoffe ihr könnt mir helfen

Gruß

Fox

Re: Conifg Files und die Benutzung

Verfasst: 31.05.2008 09:56
von Kiffi
@Fox: Das hat nix mit der Config-Datei zu tun, sondern mit Deiner
Programmstruktur. Formatiere den Code mal anständig und Du wirst von
selber draufkommen ;-)

Außerdem hast Du 2mal ein WaitWindowEvent() in Deiner Schleife.
Dadurch werden einige Events verschluckt.

Grüße ... Kiffi

Verfasst: 31.05.2008 10:06
von marco2007

Code: Alles auswählen

If..
else.. 

case...
Endif?

Verfasst: 31.05.2008 15:29
von BlueHoschi
Dein Code:

Code: Alles auswählen

select...

   If...
   Else...
Case ....

Endselect...
   Endif...
Besser:

Code: Alles auswählen

select...
case...
   if...   ;notfalls in der If-Auswahl Variable setzen
   else...  
   endif...  ;EndIf innerhalb der Case-Auswertung
Case...
.
.
.
Endselect
Dein Code ist selbst für den Interpreter zu verschachtelt :wink: **schwitz**

Verfasst: 31.05.2008 15:36
von ts-soft
Bild

Verfasst: 31.05.2008 15:59
von Kiffi
jaPBe

// Edit: Ok, ich gebe auf! Thomas, der Punkt geht an Dich :allright:

Verfasst: 31.05.2008 16:16
von scholly
Ich blick zwar nich so janz, was Kamerad Reineke da vorhat, aber ich bekomm nachm aufräumen was angezeigt :lol:

Code: Alles auswählen

#TreeGadget = 0

Procedure ReadDirs(Path.s, Rek.l)
  If Right(Path, 1) = "\" : Path = Left(Path, Len(Path) - 1) : EndIf
 
  NextOK.l
  Name.s
  ExamineDirectory(Rek, Path, "")
 
  Repeat
    NextOK = NextDirectoryEntry(Rek)
    Name = DirectoryEntryName(Rek)
    If NextOK = 2 And Name <> "." And Name <> ".."
      ReadDirs(Path + "\" + Name, Rek + 1)
      While WindowEvent() : Wend
    ElseIf NextOK = 1
      AddGadgetItem(0, -1, Path + "\" + Name)
    EndIf
  Until NextOK = #False
EndProcedure


Procedure ReadDir(Path.s, Rek.l)
  If Right(Path, 1) = "\" : Path = Left(Path, Len(Path) - 1) : EndIf
 
  NextOK.l
  Name.s
  ExamineDirectory(Rek, Path, "")
 
  Repeat
    NextOK = NextDirectoryEntry(Rek)
    Name = DirectoryEntryName(Rek)
    If NextOK = 2 And Name <> "." And Name <> ".."
      ReadDirs(Path + "\" + Name, Rek + 1)
      While WindowEvent() : Wend
    ElseIf NextOK = 1
      AddGadgetItem(1, -1, Path + "\" + Name)
    EndIf
  Until NextOK = #False
EndProcedure




Enumeration
  #Window_0
EndEnumeration

;
Enumeration
  #Listview_0
  #Listview_1
  #Button_0
  #Button_1
  #Button_2
EndEnumeration


If OpenWindow(#Window_0, 216, 0, 600, 346, "Netzwerk Sync",  #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_TitleBar )
  If CreateGadgetList(WindowID(#Window_0))
    ListViewGadget(#Listview_0, 325, 10, 235, 265)
    ListViewGadget(#Listview_1, 15, 10, 235, 265)
    ButtonGadget(#Button_0, 255, 95, 65, 35, "-->")
    ButtonGadget(#Button_1, 255, 155, 65, 35, "<--")
    ButtonGadget(#Button_2, 195, 320, 170, 20, "Configuartion")
   EndIf
EndIf

;ReadDirs("\\User\SharedDocs", 0)
ReadDir("C:\", 1)
   
Repeat
  event=WaitWindowEvent()
  Select event
    Case #PB_Event_Gadget
      Select EventGadget()
        Case #Button_0 
          n = 3
          If ReadFile(0, "config.ini")     
            For z = 1 To n-1
              ReadString(0)
            Next     
            CloseFile(0)               
          Else
            MessageRequester("","Config File not found")     
            n = 7
            If ReadFile(1, "config.ini")     
              For z = 1 To n-1
                ReadString(1)
              Next     
              CloseFile(1)               
            Else
              MessageRequester("","Config File not found")
              CopyDirectory(ReadString(0), ReadString(1), "", #PB_FileSystem_Recursive)
              MessageRequester("","Synchronizing finished")
            EndIf 
          EndIf
        Case #Button_1
          CopyDirectory("\\User\SharedDocs\bilder", "C:\", "", #PB_FileSystem_Recursive)       
        Case #Button_2       
          ;XIncludeFile "config.pb"
          Repeat
          Until WaitWindowEvent() = #PB_Event_CloseWindow
          End
      EndSelect
  EndSelect
Until event=#PB_Event_CloseWindow


Verfasst: 01.06.2008 13:44
von Fox
hi... so ich hab jetzt alle probleme gefixt die ich hatte... aber jetzt bekomm ich die dateien in den listview gadgets nicht mehr angezeigt... weiss aber nicht wieso...

Code: Alles auswählen

 
#TreeGadget = 0 

Procedure ReadDirs(Path.s, Rek.l)                                              ; Quell Computer Datei Listen Procedur
  If Right(Path, 1) = "\" : Path = Left(Path, Len(Path) - 1) : EndIf 
  
  NextOK.l 
  Name.s 
  ExamineDirectory(Rek, Path, "") 
  
  Repeat 
    NextOK = NextDirectoryEntry(Rek) 
    Name = DirectoryEntryName(Rek) 
    If NextOK = 2 And Name <> "." And Name <> ".." 
      ReadDirs(Path + "\" + Name, Rek + 1) 
      While WindowEvent() : Wend 
    ElseIf NextOK = 1 
      AddGadgetItem(0, -1, Path + "\" + Name) 
    EndIf 
  Until NextOK = #False 
EndProcedure 


Procedure ReadDir(Path.s, Rek.l)                                                    ; Ziel Computer Datei Listen Procedur
  If Right(Path, 1) = "\" : Path = Left(Path, Len(Path) - 1) : EndIf 
  
  NextOK.l 
  Name.s 
  ExamineDirectory(Rek, Path, "") 
  
  Repeat 
    NextOK = NextDirectoryEntry(Rek) 
    Name = DirectoryEntryName(Rek) 
    If NextOK = 2 And Name <> "." And Name <> ".." 
      ReadDirs(Path + "\" + Name, Rek + 1) 
      While WindowEvent() : Wend 
    ElseIf NextOK = 1 
      AddGadgetItem(1, -1, Path + "\" + Name) 
    EndIf 
  Until NextOK = #False 
EndProcedure 





Enumeration
  #Window_0
EndEnumeration


Enumeration
  #Listview_0
  #Listview_1
  #Button_0
  #Button_2
  #Config
EndEnumeration


  If OpenWindow(#Window_0, 216, 0, 600, 346, "Network Sync",  #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_TitleBar )
    If CreateGadgetList(WindowID(#Window_0))
      ListViewGadget(#Listview_0, 325, 10, 235, 265)
      ListViewGadget(#Listview_1, 15, 10, 235, 265)
      ButtonGadget(#Button_0, 255, 95, 65, 35, "Sync")
      ButtonGadget(#Button_2, 195, 320, 170, 20, "Configuartion")
          
      
      n = 1
If ReadFile(0, "config.ini")      
        For z = 1 To n-1 
   ReadString(0) 
        Next      
   CloseFile(0)                
        Else 
     MessageRequester("","Config File not found / Computer wasn't found") 
                  
                  
                                        
ReadDir(ReadString(0), 0)  ; Listet die Dateien des Quell Computers auf
         
         
         
         EndIf
           
        
         
                   
         n = 2
If ReadFile(1, "config.ini")      
        For z = 1 To n-1 
   ReadString(1) 
        Next      
   CloseFile(1)                
        Else 
     MessageRequester("","Config File not found / Computer wasn't found") 
                                                 
                                                 
                                                
      ReadDirs(ReadString(1), 0)                                                       ; Listet die Dateien des Ziel Computers auf
            
            
            
         EndIf   
            
       Repeat 
       event=WaitWindowEvent() 
     Select event 
     Case #PB_Event_Gadget 
       Select EventGadget() 
       
       
   Case #Button_0                                                                ; Liest den Quell Computer aus
         n = 2 
If ReadFile(0, "config.ini")      
        For z = 1 To n-1 
   ReadString(0) 
        Next      
   CloseFile(0)                
        Else 
     MessageRequester("","Config File not found / Computer wasn't found") 
     
     

           CopyDirectory(ReadString(0), ReadString(1), "", #PB_FileSystem_Recursive)   ; Kopiert die Daten vom Quell Computer auf den Ziel Computer
           
   MessageRequester("","Synchronizing finished")
        EndIf
                 
    Case #Button_2       
 
 
     RunProgram("Config.exe")                                                           ; Konfigurations Panel
     
     
        Repeat
         
        Until WaitWindowEvent() = #PB_Event_CloseWindow
        
        End
        End
          
      EndSelect
           
      EndSelect 
       Until event=#PB_Event_CloseWindow 
  
  EndIf 
   EndIf 


  

In der config.ini steht das:

Code: Alles auswählen

C:\
\\User
jetzt bin ich so gut wie fertig gewesen und auf einmal hat es nicht mehr funktioniert... ich weiss auch nicht was ich geändert habe...

hoffe ihr könnt mir nochmal helfe..

Gruß

Fox

Verfasst: 01.06.2008 18:50
von scholly
Solange Du den Hauptteil nicht selbst ordentlich strukturierst und einrückst, wird sich kaum einer die Arbeit machen. :mrgreen:

Verfasst: 01.06.2008 19:32
von marco2007
Da können noch mehr Fehler sein.
z.B.: Führ mal diesen Code aus:

Code: Alles auswählen

#TreeGadget = 0 

Enumeration 
  #Window_0 
EndEnumeration 


Enumeration 
  #Listview_0 
  #Listview_1 
  #Button_0 
  #Button_2 
  #Config 
EndEnumeration 

Debug #TreeGadget
Debug #Listview_0


Ich hab`s mir nur grob angesehen
Gäbe es #treeGadget -> Hätte es die selbe Id wie #Listview_0.
...Wozu #treeGadet?

lg
Marco