Page 1 of 1

PostPosted: Thu Aug 16, 2001 3:20 pm
by wossname
Has anyone else had problems with the new version of Ptoolboxlib? When I try to create forms, i get various crashes complaining about memory alloc problems, form ID's being less than 3000 when they are actually comfortably over 3001.

My palm IIIx crashed 6 times today, and it stopped ArtBMP (cool program by the way Dian) working altogether! I have gone back to the previous version of PTBL and all is well again.

Is it just my device? :(

Wossname :)

PostPosted: Thu Aug 16, 2001 4:36 pm
by jstadolnik
I took a peek at the code and I don't see anything obvious which could be causing a fatal error related to a form ID being less than 3000. If you are getting "mem alloc fail" warnings, your device is very likely low on free memory.

My guess is that either 1) your machine is running low on dynamic heap space (the form function will return 0 if it fails to allocate memory for a form), or 2) you perhaps are creating more than one form with the same ID number.

You can use the HeapSize command to determine how much heap space you have left.

Are you running the lastest and greatest ArtBMP? Dian has a version out which works with PT7.


PostPosted: Sat Aug 18, 2001 7:45 am
by wossname
My unit has more than 3 megs of free memory at the last count. I was just playing with the library (like you do when you have a new toy to try out) and I was just trying to make 1 form with a single button on it.

Is there any chance that your library will corrupt any data on my unit when it crashes it?

Wossname :)

PostPosted: Sat Aug 18, 2001 2:07 pm
by jstadolnik
Well, you certainly may have found something which slipped through my gauntlet of tests and/or caveat list.

Total free memory is no indication of free heap space (heap space is a special chunk of scratch pad memory allocated to an application. For pre-os3.5 systems it runs less than 36k, OS3.5 provides larger heaps upwards of 200k). If you use a lot of scratch buffers and/or large dynamic arrays, it's very easy to run out of heap space.

The best thing you can do is send me your source code (since it sounds like a simple test) and indicate what OS version you are using. My email is

Any crash with any application has the possibility of corrupting data.


PostPosted: Sat Aug 18, 2001 4:13 pm
by wossname

Okay, I stopped sulking long enough to download the lib again :)

This time I installed the source code for the button demo program and compiled it, no worries, runs just like the compiled version that you include in the distrib package.

Forgive me for not knowing what a heap is, ASM is not my forte!

Unfortunately I have got rid of my miserable effort from earlier, but from what I remember, it was largely composed of code copied and pasted from your own example.

Would it be possible for you to give me an example of the absolute minimum code required to show a simple form, with a button, a text field and a group of 2 checkboxes. That would be helpful in finding out what went wrong with my attempt.

I also got the new version of artbmp. All seems well so far.

Thanks for the help

Adam W (Professional dunce)

Wossname :)

PostPosted: Sat Aug 18, 2001 7:16 pm
by jstadolnik
Dynamic forms are particularly delicate things in the palm OS. I've placed numerous hooks in the code to prevent users from accidentally shooting themselves in the foot, however it's still far from bulletproof. The problem with "safeguards" is that they make the library larger and the code run slower... so I've had to make compromises.

Just be sure you read through all the caveats listed in the "Forms" section of the toolbox docs.

Below is a simple form example.


<pre id=code><font face=courier size=2 id=code>
library "PToolboxLib"
include "Fctl.h"
#define FORM1 3000
#define DONE 3001
#define CHECK1 3002
#define CHECK2 3003
#define FIELD1 3004
main() {
int e;
Form(FORM1,"Simple Form");
Button(CHECK1,0x102,10,30,0,0,"Check1"); //group 1
Button(CHECK2,0x102,10,50,0,0,"Check2"); //group 1
Field(FIELD1,0,80,30,70,120,256,"Some text...");
while(1) {
if(e==DONE) return;
</font id=code></pre id=code>

Edited by - jstadolnik on 08/18/2001 14:19:55

PostPosted: Sun Aug 19, 2001 12:26 pm
by wossname

I tried to re-construct the program that I did earlier that crashed the device, but it must have been a typo or something because it ran ok this time!

Thanks for the demo code, I'll go and have a tinker with it.


Wossname :)

PostPosted: Sun Aug 19, 2001 12:31 pm
by wossname
While I'm here I just thought I'd ask...

If I create a form with a button on it, and I FastBMP a small image onto the button (but not so that it obscures the border), will it (a) preserve the image if i hide the form and bring it back with SHOW and (b) will the FEvent() still return the button ID as normal?

I haven't had a chance to test it but it would be handy to know.

Adam W (Professional nuisance!)

Wossname :)

PostPosted: Sun Aug 19, 2001 4:54 pm
by jstadolnik
a) No, you'll have to redraw it after you "show" the button (you also may run into problems in color modes?). A different approach is to create a custom font with the image you want. Then just use that font for the button. This way the image will be persistent. See the OpenFontDb() function description for more information.

b) Yes.