Page 1 of 3
Wrapper for cheetah (database access)
Posted: Mon Aug 29, 2011 6:39 pm
by infratec
Hi,
a coding question was the trigger to write a wrapper for PureBASIC.
Cheetah is a dll which makes it possible to access directly DBF files.
Also FoxPro databases are supported.
Look here:
http://cheetahdatabase.sourceforge.net/
I applied my wrapper as a patch:
http://sourceforge.net/tracker/?func=de ... tid=824432
If you download and unpack the file, you can directly run the examples.
Have fun

Re: Wrapper for cheetah (database access)
Posted: Mon Aug 29, 2011 7:19 pm
by luis
Hi, thanks for the wrapper
I gave it a quick run and noticed two things.
The QueryRecords.pb example is empty (?).
In the AddRecords.pb example, in DisplayRecords(), you have defined
Protected st1.s = ""
Protected st2.s = ""
Protected st3.s = ""
but then xdbGetField() it's poking the returned fields values inside them, so you are writing to unallocated space.
Bye!
Re: Wrapper for cheetah (database access)
Posted: Mon Aug 29, 2011 8:15 pm
by infratec
luis wrote:The QueryRecords.pb example is empty (?).
That's true and right.
The original examples of QueryRecords are also empty
luis wrote:
In the AddRecords.pb example, in DisplayRecords(), you have defined
Protected st1.s = ""
Protected st2.s = ""
Protected st3.s = ""
but then xdbGetField() it's poking the returned fields values inside them, so you are writing to unallocated space.
Hm...
Without = "" I got an 0 pointer address. So I added this.
In general I would agree.
But what's about this:
Code: Select all
Protected String1.s
Protected String2.s = "Test"
String1 = String2
Isn't that the same ?
During compilation it's unknown how big String1 will be.
So it is extended during runtime.
Does PokeS() the same or not?
I also never got an error message that I'm writing to an illegal address.
I expect an 'illegal memory access' or something similar.
Maybe one of our gurus can give me an ultimate explanation.
And thanks for testing

Re: Wrapper for cheetah (database access)
Posted: Mon Aug 29, 2011 8:51 pm
by luis
When you assign one string to another PB know what to do, they are both strings and so the empty one is resized to make space for the copy.
With PokeS() (all the Poke*), you are simply stuffing a memory region with some data, it's up to you to make space for the data.
infratec wrote:
I also never got an error message that I'm writing to an illegal address.
I expect an 'illegal memory access' or something similar.
In time you will get one, rarely the OS pops one immediately. More often you simply overwrite some other data. If you are in a hurry to get an error message just use the purifier.
PS: why I'm doing so much advertising for the purifier lately

?
Re: Wrapper for cheetah (database access)
Posted: Mon Aug 29, 2011 10:15 pm
by infratec
Hi Luis,
I just tested AddRecords.pb with activated purifier.
It points out 3 errors.
But not at the expected positions.
One for example in the line:
[ERROR] Overflow in a string memory block.
But \nData is defined as long and nDataAddress is also defined as long.
So how could this happen ?
Since I have no experience with the purifier, can you give me a hint ?
Thanks in advance.
Bernd
Re: Wrapper for cheetah (database access)
Posted: Mon Aug 29, 2011 10:24 pm
by infratec
Ahh...
I see
I replaced = "" with Space(256) and the 3 errors gone.
But without your hint, the errors from the purifier makes absolut no sense.
Because I can only see that something is not ok, but I can not see where or what it is.
Or is there an other trick to come closer to the fault?
Re: Wrapper for cheetah (database access)
Posted: Mon Aug 29, 2011 10:37 pm
by infratec
I updated the files on sourceforge.
Thanks again for checking

Re: Wrapper for cheetah (database access)
Posted: Mon Aug 29, 2011 10:59 pm
by luis
infratec wrote:
But \nData is defined as long and nDataAddress is also defined as long.
So how could this happen ?
Since I have no experience with the purifier, can you give me a hint ?
Sure. Start the program with the debugger and purifier enabled, then select from the ide menu Debugger - > Purifier. You will see a window with four sliders.
Move the "String variables" slider to the left and let the program run. This should catch the error in the right place.
These four sliders set how often the purifier must do its checks for every particular class of memory. You can set all of them to "Every line" but this will slow down the debugged program more. Depending on your hardware and the type of program you can set them to "every line".
In your case the purifier reported the problem on another line because it has checked for an error only then. The error happened before but it had not a chance to check for it until then.
Re: Wrapper for cheetah (database access)
Posted: Tue Aug 30, 2011 3:35 am
by electrochrisso
Thanks, I will try it out.

Re: Wrapper for cheetah (database access)
Posted: Wed Aug 31, 2011 6:15 pm
by jpotting
All the Cheetah Query functions (xdbCreateQuery, xdbQueryCondition, xdbQuerySort, xdbQueryExecute, xdbDestroyQuery, xdbQueryDistinct) are missing from the wrapper.
Re: Wrapper for cheetah (database access)
Posted: Wed Aug 31, 2011 9:45 pm
by infratec
jpotting wrote:All the Cheetah Query functions (xdbCreateQuery, xdbQueryCondition, xdbQuerySort, xdbQueryExecute, xdbDestroyQuery, xdbQueryDistinct) are missing from the wrapper.
Hi,
I downloaded the file cheetahdatabase-0.02.zip and I also checked the CVS:
I didn't found one of your functions.
So please, tell me where I can find them.
Than I'll try to extend the wrapper.
Re: Wrapper for cheetah (database access)
Posted: Thu Sep 01, 2011 5:17 am
by jpotting
I'm not sure what is included in Cheetah4. I've been using Cheetah2 for a long time. See this Discussion
http://www.purebasic.fr/english/viewtopic.php?t=30032. The PureBasic wrapper for Cheetah2 is shown there. I just assumed the Query functions would be in Cheetah4.
Re: Wrapper for cheetah (database access)
Posted: Thu Sep 01, 2011 5:51 am
by jpotting
Well this post got me looking for a Cheetah update. Someone already wrote a wrapper for Cheetah4. It's in the Purebasic Wrappers Repository
http://code.google.com/p/rwrappers/sour ... spec=svn82.
It also looks like Cheetah4 does not include any of the query functions that were in Cheetah2.
Re: Wrapper for cheetah (database access)
Posted: Thu Sep 01, 2011 6:39 am
by netmaestro
jpotting, could you fix your link please?
Re: Wrapper for cheetah (database access)
Posted: Thu Sep 01, 2011 6:48 am
by Kuron
netmaestro wrote:jpotting, could you fix your link please?
Just curious, what is wrong with it?