During the copying, I wish to display information about the file just copied.
I've posted some sample code, not the same as in my program, but is simpler and has exactly the same problem.
I find that the window blanks and no text is displayed until all the files have been copied!
I tried moving the copy process into another thread but then all the text is displayed before copying is started!
Can anybody say what I am doing wrong?
Code: Select all
;// Copyfiles.pb ?
EnableExplicit
CompilerIf #PB_Compiler_Unicode
#XmlEncoding = #PB_UTF8
CompilerElse
#XmlEncoding = #PB_Ascii
CompilerEndIf
#Dialog = 0
#Xml = 0
Global XML1$, XML2$, Event.i
Global SourcePath$, TargetPath$, NewList FileList$()
Runtime Enumeration Windows
#WinMain
#win2
EndEnumeration
Runtime Enumeration Gadgets
#copySourceButton
#copySourcePath
#copyTargetButton
#copyTargetPath
#copyList
#copyGo
EndEnumeration
Runtime Enumeration Gadgets
EndEnumeration
Declare ProcessFiles()
Procedure ProcessFiles()
If ExamineDirectory(0, SourcePath$, "*.*")
While NextDirectoryEntry(0)
If DirectoryEntryType(0) = #PB_DirectoryEntry_File
AddElement(FileList$())
FileList$() = DirectoryEntryName(0)
EndIf
Wend
FinishDirectory(0)
EndIf
ClearGadgetItems(#copyList)
ForEach FileList$()
AddGadgetItem(#copyList,-1,FileList$())
Next
ForEach FileList$()
CopyFile(SourcePath$ + FileList$(),TargetPath$ + FileList$())
SetGadgetItemText(#copyList,ListIndex(FileList$()),"Copied!",1)
Next
EndProcedure
Runtime Procedure EventButtons()
Select EventGadget()
Case #copySourceButton
SourcePath$ = PathRequester("Source Directory","")
SetGadgetText(#copySourcePath,SourcePath$)
Case #copyTargetButton
TargetPath$ = PathRequester("Target Directory","")
SetGadgetText(#copyTargetPath,TargetPath$)
Case #copyGo
ProcessFiles()
EndSelect
EndProcedure
Runtime Procedure SetUP()
SetGadgetItemText(#copyList,-1,"Files to Copy")
AddGadgetColumn(#copyList,1,"Result",60)
EndProcedure
XML1$ = "<dialogs>"+
" <window id='#WinMain' name='Template' text='Print' minwidth='auto' minheight='auto' flags='#PB_Window_ScreenCentered |"+
" #PB_Window_SystemMenu | #PB_Window_SizeGadget'>" +
" <vbox>"+
" <hbox>"+
" <button id='#copySourceButton' height='60' text='Source' onevent='EventButtons()' />"+
" <text id='#copySourcePath' width='350' />"+
" </hbox>"+
" <hbox>"+
" <button id='#copyTargetButton' height='60' text='Target' onevent='EventButtons()' />"+
" <text id='#copyTargetPath' width='350' />"+
" </hbox>"+
" <listicon id='#copyList' width='450' height='200' flags='#PB_ListIcon_GridLines' />"+
" <button id='#copyGo' text='Go' onevent='EventButtons()' />"+
" </vbox>"+
" </window>"+
"</dialogs>"
If CatchXML(#Xml, @XML1$, StringByteLength(XML1$), 0, #XmlEncoding) And XMLStatus(#Xml) = #PB_XML_Success
If CreateDialog(#Dialog) And OpenXMLDialog(#Dialog, #Xml, "Template")
SetUp()
Repeat
Event = WaitWindowEvent()
Until Event = #PB_Event_CloseWindow
Else
Debug "Dialog error: " + DialogError(#Dialog)
EndIf
Else
Debug "XML error: " + XMLError(#Xml) + " (Line: " + XMLErrorLine(#Xml) + ")"
EndIf

