Oh My God what is this??
BlitzPlus Forums/BlitzPlus Programming/Oh My God what is this??
| ||
I think I may be doing something wrong, It is harder than it loks this programming thingy!!!... BLITZCC caused an invalid page fault in module RUNTIME_DBG.DLL at 015f:00ad257c. Registers: EAX=00000000 CS=015f EIP=00ad257c EFLGS=00010202 EBX=00000001 SS=0167 ESP=0069f9d0 EBP=0069fa1c ECX=00000000 DS=0167 ESI=014b1ce4 FS=1277 EDX=00b729fc ES=0167 EDI=018f05ac GS=0000 Bytes at CS:EIP: 8b 48 04 89 4d 08 8b 55 08 83 7a 0c 00 75 04 33 Stack dump: 018f05ac 014b1ce4 00000001 018f07f8 0069f9f0 016944eb 00000003 018f07f8 0069f9fc 01696e32 018f07b0 0069fa08 01696df5 018f04f0 0069fa14 0169631b Luna. |
| ||
You must have seen Matrix too much! "looking at the code, now I can see a brown haired man and a cute girl walking down the street" LOL Seriously, if you find someone that can tell for sure what happend to you just by looking that...that must be Neo himself. Better explain what you were doing extacly when it happened (what the prog does). Also if it is reproductible run the app step by step and tell us on which code it happens. |
| ||
brown haired man with a chick!!!, All I see is the light go out at the end of a tunnel..... Sorry for any spelling errors as I am finding it hard to type with all the hair stuck between my fingers( I must stop pulling out when things go pear shaped). Anyway I have spent the last hour or so scanning through my code and changing bits and bobs, The bit that seems to be going wrong is this function:- 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 SaveDatabase() End Function All I want to do here is scan through a TYPE that I am using as a database and if four fields added together=4 delete that record. This sounds so easy!!, why must I go bald before I can get this to work:-( Luna. |
| ||
I have tried like this:-Function DelRecords() ; Check to see if all the files have been returned For cta.DataCatalogue = Each DataCatalogue If cta\IMPReturned=1 If cta\RPTReturned=1 If cta\MBOMReturned=1 If cta\TIFReturned=1 Delete cta EndIf EndIf EndIf EndIf Next SaveDatabase() End Function But still no joy. Please someone help me before I go MADDDDDD. |
| ||
are you useing some sort of .DLL to load the database? And where is it being loaded in memory...For cta.DataCatalogue = Each DataCatalogue maybe you ment: For cta\DataCatalogue = Each cta\DataCatalogue [code] also... [code] For cta.DataCatalogue = Each DataCatalogue If cta\IMPReturned+cta\RPTReturned+cta\MBOMReturned+cta\TIFReturned=4 Delete cta EndIf Why are you deleteing cta? That contains ALL the datacatalogue records you are searching through...Delete cta then try to axcess it again without allocateing a new cta will cause all sorts of problems...delete cta\DataCatalogue |
| ||
Ummmm... noFor cta\DataCatalogue = Each cta\DataCataloguewill not work... leeluna has that part correct I dont think the problem is in that function as it looks correct. Skully |
| ||
Everything else with the rest of my code seems to be working fine until I call this function. All I want to do with the function is delete records that are no longer needed before I save the data to a txt file. All the type is being used for is to record data about files that need transfering from a directory on a windows NT PC to a unix directory. When the four files have been transfered I do not need to hold information about them anymore and can delete the record from the database and re-save the database to the txt file. Luna. |
| ||
_Skully: Um..Erm...yeah that little "cta.dataCatalogue" typo thingy threw me off :P I think the problem is with 'Delete cta'...Leeluna is looping through each Datacatalogue record within the cta entity but then deleteing cta (meaning everything) rather then the DataCatalogue record in question... fix would be Delete cta\datacatalogue |
| ||
I think the problem is with 'Delete cta'...Leeluna is looping through each Datacatalogue record within the cta entity but then deleteing cta (meaning everything) rather then the DataCatalogue record in question... fix would be Delete cta\datacatalogue No... "cta" is the current instance of the type list DataCatalogue. It probably doesn't have a "\datacatalogue" field. He is deleting only the current instance, not the whole list. I can't see anything wrong with that function either. Is there any chance the Save function has a problem? |
| ||
People I am adding the whole thing, Sorry to do this but I am well and truly stuck on this. The application will sit in the background on a NT pc and check a directory on a unix file server every 30 seconds or so. If it finds a file with a .CTA extension it will read the file and load some variables from it into a custom type called DataCatalogue. The point behind the program is to sit in the background and as the files/tasks are processed to move them to the relevant user directorys back in unix. The .CTA file is a text file created in a CAD package, The code reads its variables from there:- SpoolNO, SpoolCPC,SpoolDIR and SpoolPRJ. P.S the save database function seems to be fine??. .TOP ; ************************************************************************************************ ; **** PipeFAB BatchLoad Application V1.0 11/11/2003 LeeLuna **** ; **** **** ; **** This Application is designed to BatchLoad Isometric CADDS 5 **** ; **** 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 **** ; **** Project 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% = 30 ; 30 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() ; Main Loop ; Function Main() 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() ClearDataCatalogue() End End Select Forever End Function 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 SpoolPRJ$ ; This field will contain the spool project number, E.G. ACPVS. 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) Case Instr(GotLine$,"(PROJEKT=",1)>0 cta\SpoolPRJ=Mid$(GotLine$,Instr(GotLine$,"(PROJEKT=",1)+9,Len(GotLine$)-10) 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) ; ; Process the cta file through PipeFAB Application. ; This will automatically generate the .IMPORTED file and the .RPT file ; ;ExecFile("command /c c:\pipefab\pipefab\run\isoinput.exe pipefab/pipefab@ttdb1 appluser=des password=des workproject="+cta\SpoolPRJ+" cadconstdimportbatch=ON inputfile=%1 CADCONSTD_SAVE_AFTER_IMPORT=1 USERCALL_AFTERIMPORT=EXTCALLBATCH_AFTERIMPORT") ;ExecFile("command /c rename "+cta\Name+" "+cta\SpoolCPC+".IMPORTED") ;ExecFile("command /c rename report.txt "+cta\SpoolCPC+".RPT") 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) WriteString(OutFile,cta\SpoolPRJ) 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\SpoolPRJ=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=1 If cta\RPTReturned=1 If cta\MBOMReturned=1 If cta\TIFReturned=1 Delete cta EndIf EndIf EndIf EndIf Next SaveDatabase() End Function ; Deletes all the types at the end to free memory back to the system. Function ClearDataCatalogue() For cta.DataCatalogue = Each DataCatalogue Delete cta Next End Function ; BringFiles() Collects the files from the user batch directory to the PipeFAB\BatchLoad directory Function BringFiles() ExecFile("command /c 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(Extension$) Select Extension$ Case ".IMPORTED" CopyFile folder$+cta\SpoolCPC+".IMPORTED",cta\SpoolDIR+cta\SpoolCPC+".IMPORTED" DeleteFile folder$+cta\SpoolCPC+".IMPORTED" Case ".MBOM" CopyFile folder$+cta\SpoolCPC+".MBOM",cta\SpoolDIR+cta\SpoolCPC+".MBOM" DeleteFile folder$+cta\SpoolCPC+".MBOM" Case ".RPT" CopyFile folder$+cta\SpoolCPC+".RPT",cta\SpoolDIR+cta\SpoolCPC+".RPT" DeleteFile folder$+cta\SpoolCPC+".RPT" Case ".TIF" CopyFile folder$+cta\SpoolCPC+".TIF",cta\SpoolDIR+cta\SpoolCPC+".TIF" DeleteFile folder$+cta\SpoolCPC+".TIF" Default ; do nothing End Select ; DelRecords() ; check to see if we can remove any records from the database e.g all returned. End Function ; ; CheckRPT() if the file extension is .RPT set flags and call sendfiles(). Function CheckRPT(file$) For cta.DataCatalogue = Each DataCatalogue If Left$(file$,Instr(file$,".",1)-1) = cta\SpoolCPC cta\SpoolRPT=1 cta\RPTReturned=1 SendFiles(".RPT") EndIf Next End Function ; ; CheckIMPORTED() if the file extension is .IMPORTED set flags and call sendfiles(). Function CheckIMPORTED(file$) For cta.DataCatalogue = Each DataCatalogue If Left$(file$,Instr(file$,".",1)-1) = cta\SpoolCPC cta\SpoolIMPORTED=1 cta\IMPReturned=1 SendFiles(".IMPORTED") EndIf Next End Function ; ; CheckMBOM() if the file extension is .MBOM set flags and call sendfiles(). Function CheckMBOM(file$) For cta.DataCatalogue = Each DataCatalogue If Left$(file$,Instr(file$,".",1)-1) = cta\SpoolCPC cta\SpoolMBOM=1 cta\MBOMReturned=1 SendFiles(".MBOM") EndIf Next End Function ; ; CheckTIF() if the file extension is .TIF set flags and call sendfiles(). Function CheckTIF(file$) For cta.DataCatalogue = Each DataCatalogue If Left$(file$,Instr(file$,".",1)-1) = cta\SpoolCPC cta\SpoolTIF=1 cta\TIFReturned=1 SendFiles(".TIF") EndIf Next End Function ; ; .BOTTOM Thanks in advance Luna. Any help will no doubt save my hair. |