PDA

View Full Version : Pocketstudio help


mormegil
03-10-2003, 05:52 PM
Any recommendations on a web site or book to learn PocketStudio?

My only programming experience is Basic, and 2 years of high school Pascal. I don't really have any experience with object oriented programming, but would like to learn.

I've got the trial version of PocketStudio, but can't even figure out how to get a string out of a field! I don't find the help files that useful.

Should I bother with PocketStudio, or should I try PocketC, even though I don't know C.

Thanks

MarkS
03-12-2003, 07:49 PM
Hi,

FWIW, I've used PocketC. Works quite well and pretty easy to learn. There's a good book available by Andy Harris called "Palm Programming for the Absolute Beginner".

Also, a good forum on Orbworks.com website. Very helpful.

Check it out...

HTH,

Mark

mormegil
03-17-2003, 02:19 AM
I couldn't find it at my local Borders. I did find the Programming Bible. I didn't exactly buy it yet. While my girlfriend was studying for finals for a few hours, I was just reading the Bible.

Two things I couldn't find in there.
1) Anything on float manager. I just want to know how to output it to a string, not in scientific notation

2) What is the purpose of "Handled" boolean variables in a lot of the procedures.

If somebody could help me out a little here, I would appreciate it.

Thanks

Hobart
03-17-2003, 02:25 AM
You think they could make it a little easier to learn PocketStudio. I even went as far as decompiling the help files and printing them all out. Not worth all the effort I put into it.

A few suggestions:
1) Print out and read the source for the examples. You can learn a lot from studying the code.

2) Play around with the environment so you understand how it is generating code/resources and what files they are being stored in. (sounds like you are already doing this)

3) Check the newsgroups listed on their website. But even there, the support is only so-so.

Its really too bad the learning curve is so steep. At its heart, its a more or less decent environment to work with.

MarkS
03-17-2003, 09:25 AM
Mormegil,

Borders can order the book for you or get it from Amazon. ISBN number is 0-7615-3524-1.

HTH,

Mark

ayasin
03-20-2003, 12:25 AM
Originally posted by mormegil

Two things I couldn't find in there.
1) Anything on float manager.
I just want to know how to output it to a string, not in scientific notation


FlpFtoA is the API call you are looking for. There are various things you can do to select different portions of the number if you don't want to have it in scientific notation and put it into an int. To convert an int to a string use StrItoA. These API calls are documented in SDK 5.



2) What is the purpose of "Handled" boolean variables in a lot of the procedures.



Handled is typically used as a boolean in the event loop to stop processing (i.e. if a() handled the event then don't need to pass it to b() otherwise send it to b()).

mormegil
03-20-2003, 09:58 PM
Originally posted by ayasin

FlpFtoA is the API call you are looking for. There are various things you can do to select different portions of the number if you don't want to have it in scientific notation and put it into an int. To convert an int to a string use StrItoA. These API calls are documented in SDK 5.



Handled is typically used as a boolean in the event loop to stop processing (i.e. if a() handled the event then don't need to pass it to b() otherwise send it to b()).

Thanks for the help. I've since found a subroutine, and modified it for my purposes to outpout the real in non scientific notation.

I'm in the process of trying to write something up to take in field input, and change it to a real (maybe I should just look at the examples, but that's no fun). I'm still a little confused about when to use handles and pointers with strings. I think I'm getting there though.

As far as "Handled" goes, the reason I asked is, Pocket Studio seems to put it into all the button selection procedures (button_OnCtlSelect). And I can't even seem to find where it was originally declared. I just find a use for it being passed down in this case.

ayasin
03-20-2003, 10:54 PM
Originally posted by mormegil

I'm in the process of trying to write something up to take in field input, and change it to a real (maybe I should just look at the examples, but that's no fun).

Its about 3 lines of code...but I don't want to spoil your fun :).


I'm still a little confused about when to use handles and pointers with strings.

The advantage of handles over pointers is that the memory associated with a handle can be relocated (allowing for heap defragmentation) when the handle is unlocked. Tihs allows for a larger chunk of contiguous heap in which to do allocation. They are also easier to resize (particularly make larger, anything will get smaller without failing). The basic rule is if you need it for more than a short time, better to make it a handle, otherwise a pointer is ok.


As far as "Handled" goes, the reason I asked is, Pocket Studio seems to put it into all the button selection procedures (button_OnCtlSelect). And I can't even seem to find where it was originally declared. I just find a use for it being passed down in this case.
I've never used pocket studio myself, but I wager that it's declared in the form's main event handler and passed into each your handlers so that you can set and/or return it. A typical form handler loop looks like

Boolean frmMain_HandleEvent(EventPtr event)
{
FormPtr form;
Boolean handled = false;
switch (event->eType)
{
case ctlSelectEvent:
switch (event->data.ctlSelect.controlID)
{
// btnlTest receives an event
case btnlTest:
handled = frmMain_btnlTest_OnSelect(event);
break;
}
break;
case frmOpenEvent:
// Repaint form on open
form = FrmGetActiveForm();
FrmDrawForm(form);
handled = true;
break;
default:
break;
}
return handled;
}

of course this is C and your working in pascal but the logic flow is the same. Also this may be hidden from you deep in the bowels of your project depending on how much "help" pocket studio provides you.

PS. Since the forum seems to want to strip leading spaces, you'll have to copy and beautify the code yourself :).

mormegil
03-21-2003, 02:45 AM
Yeah, I found it. It was showing up in the Main Form Handler, but what threw me off was, it was declared as Result, and passed as Handled at the procedural level.

If anybody can give me some advice on this code, please do. It returns a PChar final of the input real in non-scientific notation. The problem is, I'm trying to free the pointer at the end - hence MemPtrFree(p). The problem is, when compiled with this line, the program crashes when it calles this procedure.

I can only get it to work when it's commented out. Can somebody tell me why. Do I need to bother freeing this pointer? Am I freeing the wrong thing? I don't need 'p' anymore, and it's a local variable.

Thanks


procedure StrF(var final: PChar; input: FlpDouble);


var
buf2, buf : Array [0..19] of char;
p : pChar;
i: UInt32;

begin
p := buf;
final := buf2;
i := trunc(input);
StrIToA(p, i);
StrCopy(final, p);
input:= input - i;
input:= input*100;
i := trunc(input);
p := StrIToA(p, i);
StrCat(final, '.');
StrCat(final, p);
p:='';
//MemPtrFree(p);
end;

ayasin
03-21-2003, 12:01 PM
Your trying to free memory that you didn't allocate.

buf2, buf : Array [0..19] of char <- declares an array on the stack
.
.
p := buf; <-- assigns p to point to the array on the stack
.
.
p:='' <- assigns p to point to the literal '' in y our code or data seg (depending on how your compiler will generate the asm for this)

MemPtrFree(p) <- attempts to free memory that you didn't allocate. This will caiuse unpredictable results (in a good case it will crash and you'll know there's an issue, in a bad case you'll corrupt the stack or data seg and not know until much later).

Unregistered
03-21-2003, 01:20 PM
Originally posted by ayasin
Your trying to free memory that you didn't allocate.

buf2, buf : Array [0..19] of char <- declares an array on the stack
.
.
p := buf; <-- assigns p to point to the array on the stack
.
.
p:='' <- assigns p to point to the literal '' in y our code or data seg (depending on how your compiler will generate the asm for this)

MemPtrFree(p) <- attempts to free memory that you didn't allocate. This will caiuse unpredictable results (in a good case it will crash and you'll know there's an issue, in a bad case you'll corrupt the stack or data seg and not know until much later).

OK. Thanks.

I thought that by declaring the variable buf, and buf2, I allocated that memory. So I assume then, that at the end of the procedure, the allocated memory is freed as buf and buf2 are local variables.

If so, when would I actually use MemPtrFree?

Thanks for the help.

ayasin
03-21-2003, 03:02 PM
Originally posted by Unregistered

If so, when would I actually use MemPtrFree?

Anything _you_ allocate with MemPtrNew() you have to free with MemPtrFree()


Thanks for the help.
Any time :)

maddie
03-30-2003, 11:45 AM
I actually downloaded pocket studio because it was similar to Delphi (according to the website) Since I've used Delphi before, it would be easier for me.

I am in the same state that mormegil is in. And just by reading your posts has given me a lot of insight.

Thanks for being so helpful