Page 1 of 1

Cheetah Works then does not Work

Posted: Wed Jun 27, 2007 10:24 pm
by Slyvnr
I have written a couple of small programs using Cheetah2.dll with the CheetaInc.pb (PureBasicStarter.zip wrapper written by Bob Houle).

Here is the simplest program

Code: Select all

Dim field$(50)
XIncludeFile "C:\Program Files\Purebasic\Includes\CheetahInc.pb"

xdbUseDLL()
dat_directory$=GetCurrentDirectory()
dat_directory$=dat_directory$+"\"
CustomerDB$=dat_directory$+"Customer.dbf"
;         
          F_CustID$="CustID,N,10,0"
          F_CustName$="CustName,C,30,0"
          F_CustAdd$="CustAddr,C,50,0"
          F_CustCSZ$="CustCSZ,C,75,0"
          F_CustPhone$="CustPhone,C,13,0"
          F_CustFax$="CustFax,C,13,0"
          
          dbFields$=F_CustID$+";"+F_CustName$+";"+F_CustAdd$+";"+F_CustCSZ$+";"
          dbFields$=dbFields$+F_CustPhone$+";"+F_CustFax$
     
          xdbCreate(CustomerDB$,dbFields$)
          AnyErrors()
          
          JobsDB$=dat_directory$+"Jobs.dbf"
      
          F_JobID$="JobID, N, 10, 0"
          field$(0)="JobDesc1, C, 50,0"
          field$(1)="JobDesc2, C, 50,0"
          field$(2)="JobDesc3, C, 50,0"
          field$(3)="Bidtype, N, 2,0"
          field$(4)="Pitches, C, 80, 0"
          field$(5)="Stories, C, 80,0"
          field$(6)="Removal, C, 80, 0"
          field$(7)="Deck, C, 80,0"
          field$(8)="DryinSqFt, C, 12, 0"
          field$(9)="DryinMat, C, 30,0"
          field$(10)="RoofSqFt, C, 12, 0"
          field$(11)="Roofguage, C, 4,0"
          field$(12)="RoofDesc,C,80,0"
          field$(13)="RoofType,N,2,0"
          field$(14)="SSRoofHgt,C,3,0"
          field$(15)="SSRoofWid,C,3,0"
          field$(16)="VentRidge,C,12,0"
          field$(17)="Hips,C,12,0"
          field$(18)="Valley,C,12,0"
          field$(19)="Sidewall,C,12,0"
          field$(20)="SWtoWood,C,12,0"
          field$(21)="SWtoRock,C,12,0"
          field$(22)="EndWall,C,12,0"
          field$(23)="EWtoWood,C,12,0"
          field$(24)="EWtoRock,C,12,0"
          field$(25)="Fireplace,C,12,0"
          field$(26)="FPtoWood,C,12,0"
          field$(27)="FPtoRock,C,12,0"
          field$(28)="HDE,C,12,0"
          field$(29)="HDEE,C,12,0"
          field$(30)="HDEG,C,12,0"
          field$(31)="FlashGauge,C,4,0"
          field$(32)="FlashMat,C,30,0"
          field$(33)="Days,C,4,0"
          field$(34)="MatWar,C,30,0"
          field$(35)="WorkWar,C,30,0"
          field$(36)="BidPrice,C,16,0"
          field$(37)="Option1,C,150,0"
          field$(38)="Option1P,C,16,0"
          field$(39)="Option2,C,150,0"
          field$(40)="Option2P,C,16,0"
          field$(41)="Option3,C,150,0"
          field$(42)="Option3P,C,16,0"
          field$(43)="Option4,C,150,0"
          field$(44)="Option4P,C,16,0"
          field$(45)="JiPDraw,C,16,0"
          field$(46)="Extra1,C,30,0"
          field$(47)="Extra2,C,30,0"
          
          AllFields$=F_CustID$+";"+F_JobID$
          For i=0 To 47
               AllFields$=";"+AllFields$+field$(i)
          Next i
         
          xdbCreate(JobsDB$,AllFields$)
          AnyErrors()
          
          AllFields$=""
                    
          DefaultsDB$=dat_directory$+"Settings.dbf"
          AllFields$="FType,C,20,0;FSeq,N,10,0;FText,C,100,0;FFont,C,40,0;FSize,C,3,0;FType,C,120,0"
          xdbCreate(DefaultsDB$,AllFields$)
          AnyErrors()
          
          ;PureZIP_Archive_Create(dat_directory$+"TOPMRoof.Bid",#APPEND_STATUS_CREATE)
          ;PureZIP_Archive_Compress(dat_directory$+"Customer.dbf",#False)
          ;PureZIP_Archive_Compress(dat_directory$+"Jobs.dbf", #False)
          ;PureZIP_Archive_Compress(dat_directory$+"Settings.dbf",#False)
          ;PureZIP_Archive_Close()
           
          ;DeleteFile(dat_directory$+"Customer.dbf")
          ;DeleteFile(dat_directory$+"Jobs.dbf")
          ;DeleteFile(dat_directory$+"Defaults.dbf")
          

xdbFreeDLL()
Works fine. Close things down for the night and the next day I come in and the program will not work. No Error Messages, nothing. Just no .dbf files created like the day before. Started from scratch and copied "chunks" from original and it worked. Today again, not working, well sort-of. It "creates" .dbf files but they are empty, i.e. 0 kb, no structure, no header, nothing. Tried starting a new program and copying the chunks again and it does not work.

Seems really strange. Any ideas as to this behavior? Thought maybe hardware problem, shutdown and reboot, no help. Have tried on other computer with same results.

Sly'vnr

Posted: Thu Jun 28, 2007 1:48 am
by Rook Zimbabwe
A question...

The next day. You come in. Are the DBF files already deleted from the previous day? In slang terms... you start fresh from scratch... :D

Cheetah Pblm

Posted: Thu Jun 28, 2007 2:14 am
by Slyvnr
Yes.

Basically I erase all files except for source code files.

Run the "setup.pb" (or even the setup.exe from previous day which was working) to "CREATE" fresh empty databases while I am in development phase.

Either I get a result of program does not "CREATE" files Or "CREATES" directory entries but no structure (ie 0 byte files listed in directory only).

Commented out last few lines to see what was happening.

Sequence of events:

Day 1: Original program would create dbfs just fine, zip them up, delete originals. Could look at zip file files were good (about 1k in size each). Could unpack and 2 files were 1k in size and 1 file was 2k in size. Ran multiple times to test. Everything fine. Erased zip file and dbfs. Shut down for night, went home.

Day 2: Boot system (fresh boot from power off over night). Load PB. Loaded Setup.pb (this code). Ran fine. Started working on next step in project. Ran Test. Error'ed out because "FILE NOT FOUND". Went to directory and .pb files were there but zip file was not (at this point should only have the zip file, the program I started working on would unzip, manipulate files and then rezip). Ran Setup.pb. Checked for file. No file. Commented out DeleteFile(...) lines. Ran Setup.pb. No dbfs, no zip file. Nothing. Started a new project. Entered XIncludeFile line and xdbUseDLL() line then cut and past setup.db code for creating just one dbf file. Ran program. It worked. Cut and pasted rest of code. Worked fine. Went back to other program. Throughout day would delete all dbf and zip files and run Setup.db without problems. Recompiled after several successful runs. Compiled program worked without a problem.

Day 3 (today): Had left computer on overnight. Started PB. Load program from where I left off day before. Ran Setup.exe. Check directory had a 0 byte zip file. Opened zip file. Had 3 files correctly named, all 0 bytes in length (ie Directory Entries only). Retried start from scratch with cut and paste. Would not work. Ran Setup.pb Would not work. Can not get correct files at all today.

-----------------------------------------
Side note. Since I posted this I ran the Setup.pb file and it worked. This is driving me crazy! :evil: :roll: :lol: AAAARGH!

Anyone else have this behavior with CHEETAH?

Sly'vnr
The Crazy Frustrated Old School BALD xBase Programmer

Started actingup again

Posted: Thu Jun 28, 2007 5:03 am
by Slyvnr
Well it started acting up again. Nothing I do will create the files correctly.

I have turned xdbDebugMode(1) to see errors, None.

I put in breakpoints and step through the program and view variables. Everything looks like it works. But the results are not right.

:(

Will look at it again tomorrow :(

Slynr

Back to working

Posted: Thu Jun 28, 2007 7:50 pm
by Slyvnr
This is so strange!

Just got around to working on this project for today. Now it seems to be working again.

Delete all of the old files. Cleaned everything up in the directories. Ran just fine.

**scratching head on this one fellows**

Do not know what is going on. Thought it would be hardware (memory problem specifically) but that does not seem to be a controlling factor.

Will keep things updated if starts acting up again.

Other than this one weird series of events, CHEETAH is GREAT in pb


Take care all

Slyvnr

Posted: Thu Jun 28, 2007 10:47 pm
by Rook Zimbabwe

Code: Select all

AllFields$="FType,C,20,0;FSeq,N,10,0;FText,C,100,0;FFont,C,40,0;FSize,C,3,0;FType,C,120,0" 
Now I am not familiar with Cheetah... I have used ODBC. I was having just writing to a record with the commands in PB, I got told this:

End the command line with a semi-colon () ; ()

I notice one between every field there... I am just thinking outside the box, I am no expert...

What operating system are you using when this poccours? Vista? XP Pro???

Dare and Fangbeast know more about PB and DB than I... I am still al neophyte! :)

Posted: Fri Jun 29, 2007 2:58 pm
by blueb
I haven't looked into this too deeply (I'll have more time this week end) but, I believe PureBasic's strings are all Null terminated (ASCIIZ) delimited therefore...

According to the Cheetah help file you cannot build tables using an array (see your Jobs.dbf.. I had a problem opening this file with another program)

You must create tables in this fashion....

;Create the database
AllFields.s = "CUSTID,C,7,0;CUSTNAME,C,35,0;SALARY,N,14,2"
xdbCreate(DBFName, AllFields)

--Bob

Posted: Fri Jun 29, 2007 7:02 pm
by Slyvnr
blueb wrote:I haven't looked into this too deeply (I'll have more time this week end) but, I believe PureBasic's strings are all Null terminated (ASCIIZ) delimited therefore...

According to the Cheetah help file you cannot build tables using an array (see your Jobs.dbf.. I had a problem opening this file with another program)

You must create tables in this fashion....

;Create the database
AllFields.s = "CUSTID,C,7,0;CUSTNAME,C,35,0;SALARY,N,14,2"
xdbCreate(DBFName, AllFields)

--Bob
Your right on this one. I look at the file and the array elements do not appear as fields. I figured that building the AllFields string from the array would not matter, but apparently it does. Thus I guess I will have to go ahead and code it long hand anyway.

It still builds the file, just does not build it with all the fields. (Lacks the ones in the array.)

=============

So far, the program has worked the past two days without fail. I finally did manage to get a xdbDebugMode(1) error message and corrected that (something about how I was opening the file) and have not had any strange behaviors since then.

I LOVE CHEETAH! It is very fast and very easy to use. I need to spend some time and "re-create" old style Foxbase commands in a windows environment to make programming faster and easy. :)

Thanks for the responses everyone. I will post a CHEETAH tutorial soon given what I have learned. It is really nice for simple storage vs. a flat file or using SQLite.


Take care

Slyvnr

Posted: Fri Jun 29, 2007 11:46 pm
by Rook Zimbabwe
:oops:
Why could I not see that!!! I had a similar problem just writing to a created database using Databaseupdate and a large block created with listiconbox...

Learning and squirming!

Can't wait to see the cheetah info! Is Cheetah now free??? 8)

Cheetah FREE

Posted: Sat Jun 30, 2007 2:32 am
by Slyvnr
Yes, has been for about a year or so I believe. Go to http://www.planetsquires.com/cheetah.htm to get it.

Go to the bottom and there are two wrappers. The one I used (see first message) includes an AnyErrors() procedure that really helps.

Also, when doing development I do the following


Top of code
t_debug=1

and then use xdbDebugMode(t_debug) throughout my code. When I am done debugging I just set t_debug to 0. That way I can always turn it on later if I need to.

Figured out a problem

Posted: Tue Jul 10, 2007 5:08 pm
by Slyvnr
Well it seems that my problem of working then not working is back again (after working quite some time now).

I think I have narrowed the problem down to Windows XP Professional.

I have been doing development on a Windows 2000 Professional and everything works fine. Today, I am at a different office of mine and the computer runs Windows XP Professional and everything I have with Cheetah crashes.

Copied over to a Windows 2000 system and works without problems. This happens regardless of whether the program is being run from within PB or has already been compiled into an .exe

Have registered at CHEETAH forums and waiting for approval to post questions there.

Will keep things updated as there are developments.

Slyvnr

Posted: Wed Jul 11, 2007 2:38 pm
by blueb
This may or may not be the problem (depends who set up the Win XP machine)... Opportunistic Locking

see: http://support.microsoft.com/kb/296264

HTH,
--blueb

Posted: Sun Aug 12, 2007 12:35 pm
by Jeff74
Hello,

when I compile the "Cheetah_test", I got an error message form the include file.

Code: Select all

 Procedure xdbTempFileName() 
        ProcedureReturn PeekS(CallFunction(xdbhDLL, "XDBTEMPFILENAME_Z")) 
      EndProcedure 
I there something wrong ?

Jeff

Cheetah Wrapper

Posted: Tue Aug 14, 2007 2:53 am
by Slyvnr
The problem is in the code for the wrapper.

Simply add a .s at the end of the procedure name so that it looks like this

Code: Select all

 Procedure.s xdbTempFileName()
        ProcedureReturn PeekS(CallFunction(xdbhDLL, "XDBTEMPFILENAME_Z"))
      EndProcedure 
I think there was one or two other areas that you need to make some minor corrections also but I can not remember of the top of my head and not at home development computer to pull it up and check.

Slyvnr