Can someone have a quick look at this and tell me if they can see a FOR without a NEXT as this is the error I keep getting.
; ************************************************************************************************
; **** PipeFAB BatchLoad Application V1.0 11/11/2003 LeeLuna ****
; **** ****
; **** This Application is designed to BatchLoad Isometric ****
; **** CTA files from a shared UNIX directory into PipeFAB ****
; **** software. ****
; **** ****
; **** Program Steps:- ****
; **** ****
; **** Start as a background task in WindowsNT ****
; **** Load Files.DataCatalogue from Seq File ****
; **** ****
; **** ****
; **** Check the users\project\files\_bcd directory for *.CTA files ****
; **** If New File ****
; **** Load Files.DataCatalogue with file information ****
; **** CPC Number ****
; **** Return Directory ****
; **** Spool Number ****
; **** ****
; **** IMPORTED = When file has been processed by PipeFAB ****
; **** RPT = Report file returned by PipeFAB ****
; **** MBOM = Manufacture Bill Of Material file created by PipeFAB ****
; **** TIF = Tiff image of isometric drawing saved by user ****
; **** ****
; **** ****
; **** Load cta files into PipeFAB with ExecFile() command ****
; **** ****
; **** ****
; **** Check C:\BatchLoadACP directory for *.IMPORTED files ****
; **** Update Files.DataCatalogue with file information ****
; **** Check C:\BatchLoadACP directory for *.RPT files ****
; **** Update Files.DataCatalogue with file information ****
; **** Check C:\BatchLoadACP directory for *.MBOM files ****
; **** Update Files.DataCatalogue with file information ****
; **** Check C:\BatchLoadACP directory for *.TIF files ****
; **** Update Files.DataCatalogue with file information ****
; **** If IMPReturned+RPReturned+MBOMReturned+TIFReturned=4 ****
; **** Delete record from Files.DataCatalogue ****
; **** ****
; **** ****
; **** ****
; **** Check through Files.DataCatalogue ****
; **** If SpoolIMPORTED>0 and IMPReturned=0 ****
; **** Return *.IMPORTED to SpoolDIR$ ****
; **** Set IMPReturned=1 ****
; **** If SpoolRPT>0 and RPTReturned=0 ****
; **** Return *.RPT to SpoolDIR$ ****
; **** Set RPTReturned=1 ****
; **** If SpoolMBOM>0 and MBOMReturned=0 ****
; **** Return *.MBOM to SpoolDIR$ ****
; **** Set MBOMReturned=1 ****
; **** If SpoolTIF>0 and TIFReturned=0 ****
; **** Return *.TIF to SpoolDIR$ ****
; **** Set TIFReturned=1 ****
; **** ****
; **** Save Files.DataCatalogue Too Seq File ****
; **** ****
; ************************************************************************************************
;
;
; *** MAIN LOOP ***
; Make CTA global so all functions can see it.
Global cta.DataCatalogue
Const WaitTime% = 10 ; 10 Seconds
Const Folder$ = "C:\PipeFAB\PipeFAB\BatchLoad\" ; This needs to change to whatever the users files directory is
; can this be read from a redgistry variable?
; or be part of the startup script?
;
;
; Main Loop
;
LoadDatabase()
BringFiles()
win=CreateWindow ("",0,0,300,300);create window first
txtbox=CreateTextArea(0,0,200,200,win) ;create textarea in that window
CreateTimer(1)
Repeat
Select WaitEvent()
Case $4001 ; Timer tick (one second) has occurred
ticks% = ticks + 1
; if WaitTime has passed then check the folder for *.CTA, *.RPT files
; *.MBOM, *.TIF files
; and *.MPORTED files.
If ticks Mod WaitTime = 0
CheckFolder(Folder)
;
; Just for testing, the code below prints to a text area in a window.
;
For cta.DataCatalogue = Each DataCatalogue
AddTextAreaText txtbox,cta\Name+">"+cta\SpoolCPC+">"+cta\SpoolDIR+">"+cta\SpoolNO+Chr$(13)
Next
EndIf
Case $803
SaveDatabase()
End
End Select
Forever
Type DataCatalogue
Field Name$ ; CTA File Name
Field SpoolCPC$ ; This field will contain the spool CPC Number, It could be a string!!
Field SpoolDIR$ ; This field will contain the return directory for our files
Field SpoolNO$ ; This field will contain the spool number, E.G. 0123HPA
Field SpoolIMPORTED ; Has it been imported, 0=NO 1=YES
Field SpoolRPT ; Has it had a report created, 0=NO 1=YES
Field SpoolMBOM ; Has it had a MBOM created, 0=NO 1=YES
Field SpoolTIF ; Has it had a TIFF created, 0=NO 1=YES
Field IMPReturned ; Has the IMPORTED file been returned to SpoolDIR$, 0=NO 1=YES
Field RPTReturned ; Has the RPT file been returned to SpoolDIR$, 0=NO 1=YES
Field MBOMReturned ; Has the MBOM file been returned to SpoolDIR$, 0=NO 1=YES
Field TIFReturned ; Has the TIF file been returned to SpoolDIR$, 0=NO 1=YES
End Type
;CheckFolder() This function performs a recursive check of our directory for files ending in.CTA
; Thanks to SoJa from the BlitzBasic.com community section for the help
; with this function.
Function CheckFolder(Folder$)
; Find all CTA files in the folder
dir = ReadDir(Folder)
While MoreFiles(dir)
; Found a file. Is it CTA file?
; Maybe change this to a select
; on the file extension .
file$ = NextFile$(dir)
If Upper$(Right$(file$, 4)) = ".CTA" Then CheckCTA(file$)
If Upper$(Right$(file$, 4)) = ".RPT" Then CheckRPT(file$)
If Upper$(Right$(file$, 9)) = ".IMPORTED" Then CheckIMPORTED(file$)
If Upper$(Right$(file$, 5)) = ".MBOM" Then CheckMBOM(file$)
If Upper$(Right$(file$, 4)) = ".TIF" Then CheckTIF(file$)
Wend
CloseDir(dir)
End Function
;CheckCTA() This function checks the filename of a found CTA file against against our cta database
; Thanks to SoJa from the BlitzBasic.com community section for the help
; with this function.
Function CheckCTA(file$)
; Check to see if we've seen this CTA file before
For cta.DataCatalogue = Each DataCatalogue
If cta\Name = file$ Then Return
Next
; It's a new one
cta.DataCatalogue = New DataCatalogue
cta\Name = file$
ReadCTA(file$)
End Function
;ReadCTA() Open the cta file and find the values for our fields.
; Thanks to MasterBeaker, Koriolis and Floyd from the BlitzBasic.com community for
; help on this Function.
Function ReadCTA(file$)
; Name$ ; Added in the CheckCTA() Function
; SpoolCPC$ ; ReadLine and find "(STLNUMMER=" value is 8 characters from this point.
; SpoolDIR$ ; ReadLine and find "## " Directory is the rest of the line, trim trailing spaces.
; SpoolNO$ ; ReadLine and find "(MSECTION=" value is from this point and closing ")" after.
FoundFile=ReadFile(Folder$+"\"+file$)
While Not Eof(FoundFile)
GotLine$=ReadLine(FoundFile)
Select True
Case Instr(GotLine$,"(STLNUMMER=",1)>0
cta\SpoolCPC=Mid$(GotLine$,Instr(GotLine$,"(STLNUMMER=",1)+11,8)
Case Instr(GotLine$,"## ",1)>0
cta\SpoolDIR=Mid$(GotLine$,Instr(GotLine$,"## ",1)+14,Len(GotLine$)-14)
Case Instr(GotLine$,"(MSECTION=",1)>0
cta\SpoolNO=Mid$(GotLine$,Instr(GotLine$,"(MSECTION=",1)+10,Len(GotLine$)-11)
End Select
cta\SpoolIMPORTED=0:cta\SpoolMBOM=0:cta\SpoolRPT=0:cta\SpoolTIF=0
cta\IMPReturned=0:cta\RPTReturned=0:cta\MBOMReturned=0:cta\TIFReturned=0
Wend
CloseFile(FoundFile)
End Function
; SaveDatabase() Saves the custom type .DataCatalogue to disk.
Function SaveDatabase()
OutFile=WriteFile("C:\LeeTest\CTACAT.txt")
For cta.DataCatalogue = Each DataCatalogue
WriteString(OutFile,cta\Name)
WriteString(OutFile,cta\SpoolCPC)
WriteString(OutFile,cta\SpoolDIR)
WriteString(OutFile,cta\SpoolNO)
WriteInt(OutFile,cta\SpoolIMPORTED)
WriteInt(OutFile,cta\SpoolRPT)
WriteInt(OutFile,cta\SpoolMBOM)
WriteInt(OutFile,cta\SpoolTIF)
WriteInt(OutFile,cta\IMPReturned)
WriteInt(OutFile,cta\RPTReturned)
WriteInt(OutFile,cta\MBOMReturned)
WriteInt(OutFile,cta\TIFReturned)
Next
CloseFile(OutFile)
End Function
; LoadDatabse() Loads the custom type .DataCatalogue from disk.
Function LoadDatabase()
OutFile=ReadFile("C:\LeeTest\CTACAT.txt")
While Not Eof(OutFile)
cta.DataCatalogue = New DataCatalogue
cta\Name=ReadString(OutFile)
cta\SpoolCPC=ReadString(OutFile)
cta\SpoolDIR=ReadString(OutFile)
cta\SpoolNO=ReadString(OutFile)
cta\SpoolIMPORTED=ReadInt(OutFile)
cta\SpoolRPT=ReadInt(OutFile)
cta\SpoolMBOM=ReadInt(OutFile)
cta\SpoolTIF=ReadInt(OutFile)
cta\IMPReturned=ReadInt(OutFile)
cta\RPTReturned=ReadInt(OutFile)
cta\MBOMReturned=ReadInt(OutFile)
cta\TIFReturned=ReadInt(OutFile)
Wend
CloseFile(OutFile)
End Function
; DelRecords() Deletes the record after all the files have been returned to the users directory.
Function DelRecords()
; Check to see if all the files have been returned
For cta.DataCatalogue = Each DataCatalogue
If cta\IMPReturned+cta\RPTReturned+cta\MBOMReturned+cta\TIFReturned=4
Delete cta
EndIf
Next
End Function
; Deletes all the types at the end to free memory back to the system.
Function ClearDataCatalogue()
Delete Each cta
End Function
;
; BringFiles() Collects the files from the user batch directory to the PipeFAB\BatchLoad directory
Function BringFiles()
ExecFile("MOVE c:\LeeTest\*.cta c:\pipefab\pipefab\batchload")
End Function
; SendFiles() Sends the files to the required directory after they have been created.
; in the PipeFAB\BatchLoad directory.
Function SendFiles()
For cta.DataCatalogue = Each DataCatalogue
If cta\SpoolCPC = Left$(file$,Instr(file$,".",1)-1)
If Upper$(Right$(file$, 4)) = ".RPT"
ExecFile("MOVE c:\pipefab\pipefab\batchload\"+file$+" "+cta\SpoolDIR)
cta\RPTReturned=1
EndIf
If Upper$(Right$(file$, 9)) = ".IMPORTED"
ExecFile("MOVE c:\pipefab\pipefab\batchload\"+file$+" "+cta\SpoolDIR)
cta\IMPReturned=1
EndIf
If Upper$(Right$(file$, 5)) = ".MBOM"
ExecFile("MOVE c:\pipefab\pipefab\batchload\"+file$+" "+cta\SpoolDIR)
cta\MBOMReturned=1
EndIf
If Upper$(Right$(file$, 4)) = ".TIF"
ExecFile("MOVE c:\pipefab\pipefab\batchload\"+file$+" "+cta\SpoolDIR)
cta\TIFReturned=1
EndIf
EndIf
Next
DelRecords()
End Function
Function CheckRPT(file$)
For cta.DataCatalogue = Each DataCatalogue
If cta\SpoolCPC = Left$(file$,Instr(file$,".",1)-1)
cta\SpoolRPT=1
SendFiles(file$)
Next
End Function
Function CheckIMPORTED(file$)
For cta.DataCatalogue = Each DataCatalogue
If cta\SpoolCPC = Left$(file$,Instr(file$,".",1)-1)
cta\SpoolIMPORTED=1
SendFiles(file$)
Next
End Function
Function CheckMBOM(file$)
For cta.DataCatalogue = Each DataCatalogue
If cta\SpoolCPC = Left$(file$,Instr(file$,".",1)-1)
cta\SpoolMBOM=1
SendFiles(file$)
Next
End Function
Function CheckTIF(file$)
For cta.DataCatalogue = Each DataCatalogue
If cta\SpoolCPC = Left$(file$,Instr(file$,".",1)-1)
cta\SpoolMBOM=1
SendFiles(file$)
Next
End Function
Any help on solving this may just save my hair.
Thanks Luna.
|