Re: Why year 1904 is chosen for start date?

2005-10-18 Thread Chris Tutty
From: Ben Combee [EMAIL PROTECTED]
 At 09:53 AM 10/18/2005, you wrote:
 As for why that date exactly I think it's related to leap year
 calculations. By avoiding 1900 they avoided some possibly
 complicated leap year issues (only to run into them again in
 Y2K, of course).
 
 Actually, the leap year problems did not occur with 2000, since it was a 
 multiple of 400 and had a leap day -- 1900 didn't have a leap day, so 
 handling it would have been a problem.
 
Great in theory, except for those programmers that did enough
research to find the 'divide by 100' rule and not enough to find 
the 'divide by 400' rule.  D'oh

Not that this has anything to do with Palm OS :-)

Chris Tutty


-- 
For information on using the PalmSource Developer Forums, or to unsubscribe, 
please see http://www.palmos.com/dev/support/forums/


Re: odd address error

2005-10-12 Thread Chris Tutty
From: cbruner [EMAIL PROTECTED]
(as part of a possibly off-topic discussion about structure byte-alignment)
 ... seems to me to be very byte centric. The only difference between
reading at
 an even boundary and odd one is one bit. The as far as the boundaries
being
 set up as dwords/words/bytes is just a matter of  convenience, mainly for
 programmers.

Nope, it's _in_convenient for programmers, done purely for processor speed.
Even the processors that allow non-word oriented data explicitly document
this as slow and to be avoided.  And, since it generally can be avoided,
anyone that packs a structure array to an odd offset is producing a bad
design
because this has an unknown speed and code complexity hit.  Hell, half of
the
quad-byte aligned structures out there have a chance of failing on the new
64-bit
processors, a google search will show you the problems people are having
with alignment so it's not something you want to avoid thinking about.

After all, if you're accessing an indexed store written by a different
processor
issues such as endianness and byte-alignment have a fair chance of making
your
goal of mapping the processor-independent disk-based index directly to an
in-memory array optimistic and unlikely.  I agree that sometimes you get
handed stuff designed by someone who didn't think past the end of their
desk but I'd be more likely to point the 'bad design' finger at whoever
handed
you that data structure, not the designer of the processor you happen to be
compiling for at the moment.  Me, I'd have built the index as two arrays,
one
with the keys and one with the offsets, each of which would then be
correctly
aligned for whichever processor it was loaded onto.  Although I guess that
is just as likely to introduce some sort of problem somewhere, but that's
optimisation for you.  It's never free.

Are we off-topic for this list yet?  :-)

Chris Tutty



-- 
For information on using the PalmSource Developer Forums, or to unsubscribe, 
please see http://www.palmos.com/dev/support/forums/


Re: Compressing records with Lz77

2005-10-12 Thread Chris Tutty
From: Trevor MacPhail [EMAIL PROTECTED]
 I'm writing an application that is going to be working with a potentialy
 large database of almost all text and I'd like to compress the records.
 Is it possible to use PalmOS's Lz77 API for this? And if so, HOW? I
 can't find any documentation of the functions other than what little
 there is in the Lz77Mgr.h header file.

I successfully used the zlib stuff from zboxz
http://palmzlib.sourceforge.net/
to add compression to a project.  My project was cross-platform
and I had to rework the libraries to embed them but even so I'm
happier I started there than starting from scratch.

No idea how this compares with the Lz77 API.

Chris Tutty


-- 
For information on using the PalmSource Developer Forums, or to unsubscribe, 
please see http://www.palmos.com/dev/support/forums/


Re: command line building for metrowerks

2005-09-22 Thread Chris Tutty
From: David Birdsall [EMAIL PROTECTED]
 According to the manual for codewarrior (...) you can script 
 codewarrior to do automated builds and the like. It talks 
 about using the OLE/COM object viewer to look for interface 
 definitions of objects you can script using vbs/jscript 
 (using wscript.exe on windows at least). 

There are some sample scripts included with the CW release
(folder name of (CodeWarrior Examples)\Scripting Examples)
that were easy enough to follow.  They are documented and
include code to copy the compiler messages to a log file.

I found it fairly easy to extend the basic build script to read a file 
of projects in order to automate the building of a set of libraries
and the apps that used them, although if I had to do it again
I'd start by finding a vbscript debugger.

Chris Tutty


-- 
For information on using the PalmSource Developer Forums, or to unsubscribe, 
please see http://www.palmos.com/dev/support/forums/


Re: Nested_FrmPopupForm().

2005-09-21 Thread Chris Tutty
From: rci_ind [EMAIL PROTECTED]
 Can i use nested FrmPopupForm(). 
(snip of 'form A, form B, form C sequence)

I don't think so but, more importantly, a form sequence
this complex is going to be difficult to debug and maintain.
It's not generally the way complex Palm interfaces do things.

 How should i ensure the proper closure of formB and formC?
 will i still have Field1 undisturbed?
 
If you need to spread your data management over several
forms you are better to isolate your data saving and loading
to a separate module and then have each form interact with 
that.  Each form then uses those routines to load the current
record (generally using an index stored in a global variable),
interacts with the user to edit the data and then saves the
fields it has modified.  In theory this means that the data
module is free to save all of the data back to the database
each time one of the forms closes, or to keep it all in 
global memeory until a final 'Save' button is hit and then
update the database record.  Your forms don't have to
manage the data themselves and so it becomes easier to 
do things such as move a field from one form to another 
or split or combine forms later on.

The data module can be built as if it was an object with get() 
and set() methods for each field.  Although C doesn't support 
object-oriented programming syntactically there's no reason 
you can't apply object-oriented design principals.

Chris Tutty


-- 
For information on using the PalmSource Developer Forums, or to unsubscribe, 
please see http://www.palmos.com/dev/support/forums/


Re: The File vs Database Paradigm

2005-09-14 Thread Chris Tutty
From: Lance Drake [EMAIL PROTECTED]
   My application creates records. I do not want to create PDB files 
 because the destination for the records is FileMaker or Excel - which 
 don't know how to read those Palm binary file formats for import into 
 records or spreadsheets.  Yes, I could write a plug-in for the 
 destination apps - but that seems riskier (because of assumptions about 
 the PDB internal structures) than just making the XML text available.
 
One option is to tag the databases for backup and then look for 
them in the desktop backup folder after the hotsync has completed
and use a pdb2csv converter to produce files that desktop apps
can import.  It's an alternative, although the last time this was 
discussed there were a few people pointing out that conduits 
have become _much_ easier to write (conduits also don't require
knowing anything about the PDB internal structures - the conduit
API does that for you).

Chris Tutty


-- 
For information on using the PalmSource Developer Forums, or to unsubscribe, 
please see http://www.palmos.com/dev/support/forums/


Re: How to find a bug that crashes Simulator?

2005-09-13 Thread Chris Tutty
From: Aaron Hansen [EMAIL PROTECTED]
 Is this not an issue for anyone else?  I'd at least like to know if
 other people are able to trap fatal errors in any simulator without it
 GPF'ing too.  It's not like the old days when I had the source code for
 the POSE and I could just throw it in the debugger and track down the
 crash myself.  Or is it? Is the source for any of the simulators
 available?

My experience has been that a crash in the simulator was usually
caused by a bug in my code resulting in either memory corruption
or an API call being passed an invalid value.  The simulator, because
it's just a copy of the normal Palm OS ROM, can't handle this and
dumps out.

This, unfortunately, makes it a much less powerful debugging aid 
than the emulator (which could tell you about stuff like null pointers 
and memory corruption) but it's a lot cheaper to build this way for 
PalmSource.

The bottom line is that you first need to gaurantee that your code 
isn't causing the crash and to do that you've got to employ the same 
sort of strategies as debugging on the device - log to the screen, log 
to a db, log to a VFS file, etc.  The crash is far more likely to be a 
bug in your code than a bug in the Palm OS source and, if it is a 
bug in the Palm OS source you're down to debugging assembler 
because you're not going to get access to the Palm OS source.

Chris Tutty


-- 
For information on using the PalmSource Developer Forums, or to unsubscribe, 
please see http://www.palmos.com/dev/support/forums/


Re: How to find a bug that crashes Simulator?

2005-09-13 Thread Chris Tutty
From: Aaron Hansen [EMAIL PROTECTED]
 I never suggested I want to find bugs in the PalmOS code.  I want to
 find bugs in my code.  Of course we try to garuntee that we never
 generate a memory exception or use an API incorrectly, but that is going
 to happen with a code base as large as the one I work with (60 segments
 to give you an idea). There are several developers touching the same
 code, and some of it is code that is common to other plaforms like
 Symbian, PPC and SmartPhone.  When it does happen the simulator should
 not GPF.  No amount of discussion will convince me that is OK.

You've got my full agreement there.  I was amazed at the simplicity 
of some of the crashes in terms of bad API parameters.  How hard 
would it be for Palm Source to provide a developer build that left the 
ASSERTS in place and generated a stop of some sort.  At least then 
you could quickly identify the location of the crash.

Chris Tutty


-- 
For information on using the PalmSource Developer Forums, or to unsubscribe, 
please see http://www.palmos.com/dev/support/forums/


Re: How to find a bug that crashes Simulator?

2005-09-13 Thread Chris Tutty
From: Ben Combee [EMAIL PROTECTED]
 The simulator is a whole build of the OS with a Windows-based device
 abstraction layer.  It's used for OS development at PalmSource, so
usually
 a crash in the sim is detected in the debugger of Visual Studio by a
 developer that has full simulator source code.  No source is available,
 because the sim source is actually the whole OS source.

Excuse me?  It's used for OS development at PalmSource.  My
mistake then, because I thought it had been released as a tool
for Palm OS developers.  It's one thing to replace the robust, well
built and useful emulator with a simple simulator - cheap, but that's
life.  It's something else to respond to complaints by suggesting
that it's only an internal tool.

If it's an internal tool then Palm Source need to identify it as such
and, on that basis, admit that OS 5 has no debugging environment.
If it's not an internal tool but is intended for use as a debugging aid
for third-party developers then let's have a debug build that doesn't
crash when an ASSERT fails (I'm assuming that the crash is an
ASSERT and not a simple failure to check API parameters).

Which puzzles me because, as I'm typing this, I'm remembering
that there *is* a debug version of the simulator and debug ROMS
which, if I remember correctly, crashes just as badly as the 'release'
stuff.  What's the difference between the debug and release
versions?

I've also just noticed an early release of an ARM emulator for
Palm OS 5.4 and 6.  Is that intended to replace the simulator
as the primary debugging tool or is it just for low level tech
stuff?

Chris Tutty


-- 
For information on using the PalmSource Developer Forums, or to unsubscribe, 
please see http://www.palmos.com/dev/support/forums/


Re: How to find a bug that crashes Simulator?

2005-09-13 Thread Chris Tutty
From: Ben Combee [EMAIL PROTECTED]
 Make sure you're using a debug version of the simulator.  That has a lot
 more checks, since the assertions are turned on in the OS code.  When one
 it hit, you should be able to hit the debug in 68K button and see your
 stack crawl.

If someone identifies a crash as relating to a situation where an assert
seems to be missing (perhaps a bad API parameter crashing the
simulator rather than triggering an assertion) is there any value in
raising this as a bug, or would it be ignored because it doesn't affect
the real-world behaviour of Palm OS?

I realise that it's a gray area, but I'm thinking that this at least would
allow us to gradually improve the robustness of the simulator as a
debugging tool, although it depends on PalmSource being willing to
apply resources to those bug reports.

Chris Tutty


-- 
For information on using the PalmSource Developer Forums, or to unsubscribe, 
please see http://www.palmos.com/dev/support/forums/


Re: Fatal Exception on Zire 71 and 72

2005-09-08 Thread Chris Tutty
From: [EMAIL PROTECTED]
 i´m working on this application that was tested originally on
 Tungsten C and Sony Clie. In both was working fine.
 But now our customer will install like 100 Zires 72 with this
 application. The problem is that when trying to exit the
 application there is a fatal exception.
 I've tried to debug with CW, but I can not reproduce the fault.
 The same Zire works perfect while debugging.

I have no idea what the problem is, but found that an excellent
tool for tracking down this sort of problem was a simple logging
module that wrote text to a PDB.  Although this isn't as good as
source-level debugging it has the advantage of running on the
actual device and so has more chance of capturing the sequence
of events that lead to the crash.

I had a fairly complex module that tracked many resource issues
for tracking problems with serial-connected hardware, but for
this sort of thing all you really need is a couple of functions that
- create a database using a timestamp for the name (so that
new runs don't over-write previous debug data and to help
keep them organised when you've hotsynced them back to your
PC).
- a function to write a string to the pdb (it can be useful to format
the string as a string of comma separated values that starts
with an incrementing index and then a tickcount - this lets
you easily import it into a spreadsheet to filter out the crap).
- then call that function at the top of important functions and
anywhere you want to dump a data value or signal that
something happened.

Hotsync the device, grab the pdb from the backup directory
and use one of the pdb 2 cvs converters to convert to a
text file (one of the reasons you want each record to just be a
formatted string) and voila - you can see the point the code
crashed.  It'll take a couple of round trips to start isolating
the problem but with any luck it will get you to the point where
you can actually get some info about the crash where-as at
the moment you're probably just trying to guess what might
be happening.

It sounds like a lot of work just to trace the execution flow
but trust me that this is invaluable (and reusable) whenever
you've got a problem that only occurs on the device (or that
other support nightmare: a problem that only occurs on one
client's device).  One of these days I'll get around to putting
my debug module up on-line, but I just don't have the time
to debug and document it.

Chris Tutty


-- 
For information on using the PalmSource Developer Forums, or to unsubscribe, 
please see http://www.palmos.com/dev/support/forums/


Re: problem adding rsrc to mcp project

2005-09-01 Thread Chris Tutty
From: Ben Combee [EMAIL PROTECTED]
  The palms applications here were created in PILRC and some in
  constructor.  I am trying to bring it uniform to use one resource
editing
  method (don't tell me constructor is crap, it's what I'm usingJ).
 
 CW V9 uses PilRC as the standard format for projects using the Palm OS 68K
 Linker.  To use Constructor resources, you need to create projects using
 the stationery, not the wizard, as that uses the Mac OS 68K Linker and
 PalmRez which allows Constructor-format resources.

It's also not too hard to support both styles in the same project (which
can be useful for testing during the transition).  You have to take a
project built for one style and manually set up the file types for the
other.  Sorry to be vague, but it's several years since I did this.  You
also end up with two different sets of resource setting locations (the
new dialog inside the CW project IDE and also the constructor
settings) so you have to be careful what you mix and match.  I had
a project with constructor-built forms and app definition but string
resources and bitmap families created in the PilRC format via a
custom-built app (for managing internationalisation with run-time
language selection).

It takes a bit of setting up and generally isn't necessary or desirable
so I'm only mentioning that it's possible as an interim measure.

Chris Tutty


-- 
For information on using the PalmSource Developer Forums, or to unsubscribe, 
please see http://www.palmos.com/dev/support/forums/


Re: Duplicating an asp database web tool

2005-08-16 Thread Chris Tutty
From: Ornstein, Adam [EMAIL PROTECTED]
 1.  (brute force?)  I was thinking that we could spider the tool, and
 produce a large number of files, that could be linked to one another from
 the PDA tool's main interactive page.  Making it seem interactive... but
is
 there something out there that can make that happen?

Regarding html apps on the Palm, I've had some conversations with
these guys and they might have an option for you.

Copy of an earlier forum message
From: James Fisher [EMAIL PROTECTED]
 Our viewer included on the ROM of the T5 and LifeDrive, used to render
 Addit has a lot of functionality that makes it useful as an html front
 end for 3rd party applications.  We have been planning to publicly
 release our SDK to allow developers to take advantage of the viewer
 within their applications but the lack of business case means it keeps
 getting pushed back.
(snip)
 If you are interested in playing with the SDK within your application
 contact me offline.  The Addit conduits will also be available to
 developers for use within their application for system and other updates.

 James Fisher
 Bluefish Wireless



-- 
For information on using the PalmSource Developer Forums, or to unsubscribe, 
please see http://www.palmos.com/dev/support/forums/


Re: OS 5 is messing up certain numbers

2005-08-16 Thread Chris Tutty
From: Jim McGowen [EMAIL PROTECTED]
 Found something strange... Looks like Palm OS 5 changes certain numbers
 multiplying.  For example:
   double x = 0.141;
   long y = (long)( x * 1.0 );

 y becomes 1409.

 Also:
   double x = 1410.0;
   double test = 0.141;
   double y = test * 1.0;
   double z = 0.141 * 1.0;

 x = = 1410.0 = =
 0100100101101000
 y = = 1410.0 = =
 0100100101100111
 z = =1410.0 = =
 0100100101101000

This is just a rounding issue isn't it?  0.141 * 1.0 has a good chance
of
being resolved at compilation time rather than run time so it's just an
assignment
of a precalculated constant where the test * 1.0 is subject to the
accuracy
with which that number can be stored and computed.

To my knowledge casting isn't a good way to obtain an accurate conversion
of a floating value because you don't have control over issues like
truncation.
I think you should be using an explicit conversion function so that
1409.99...
is rounded to 1410 rather than being truncated to 1409.

Chris Tutty


-- 
For information on using the PalmSource Developer Forums, or to unsubscribe, 
please see http://www.palmos.com/dev/support/forums/


Re: Need some help determing what might be crashing this code

2005-08-13 Thread Chris Tutty
From: Henk Jonas [EMAIL PROTECTED]
 druid wrote:
  Hmmm and what determines
  
  poor coding practices.
  
 I guess, Roger was rather talking about your C-code style and all the 
 bugs you put in your code and then ask here for help. Dude, you should 
 better watch your code carefully, use a debugger and debug output and 
 try to remove all the obvious mistakes before asking for help every day 
 in the forum.
 
Well the way I read it he was talking about the use of a 
global pointer to store the pointer of an open database.
I do something similar, although wrapped in a module 
so that each database has a module that manages it, but
some people are agressively opposed to global variables
and wouldn't like my approach at all.  But it was a fairly
vague statement so...

As to the 'obvious mistakes' I'm not sure how many mistakes
are obvious when you don't know the answer and druid 
at least shows signs that he's investigating these problems
himself.  We've had posters in the past that have said
I can't do this, please write the code for me and I need it
by tomorrow.

Chris Tutty


-- 
For information on using the PalmSource Developer Forums, or to unsubscribe, 
please see http://www.palmos.com/dev/support/forums/


Re: Database: memory reading error

2005-08-10 Thread Chris Tutty
From: Stephan [EMAIL PROTECTED]
 Hi all!
 I am implementing a database with a list and edit tables similar to the
address example. My problem is after entering text in the second field in my
dataColumn I receive an error (also attached) that my program is reading
from a location in the memory manager’s data structures. Any help will be
appreciated!!

And an excellent error message it is.  The last sentence about writing
past the end of the buffer says it all.  Check the logic that limits
the amount of data written and the size of the buffers allocated.

Chris Tutty


-- 
For information on using the PalmSource Developer Forums, or to unsubscribe, 
please see http://www.palmos.com/dev/support/forums/


Re: Need some help determing what might be crashing this code

2005-08-10 Thread Chris Tutty
From: druid [EMAIL PROTECTED]
 Run it twice in a row and it will crash
 EditRecord()
  {
(snip)
   err = Open();
   h = DmGetRecord(dbPtr, nRecordIndex);
(snip)
MemHandleUnlock(h);
DmReleaseRecord(dbPtr, nRecordIndex, true);
err = DmCloseDatabase(dbPtr);
return 0;
  }
 
You're finishing with a DmCloseDatabase but it's not
clear from this code whether Open() opens the database
or returns a stored pointer.  Good practice is to allocate
and free resources at the same level so if you've got an
Open() function that does some special database management 
you should also have a Close() function to reverse this.  Of
course if Open() does something else entirely then your bug 
is elsewhere.

Chris Tutty



-- 
For information on using the PalmSource Developer Forums, or to unsubscribe, 
please see http://www.palmos.com/dev/support/forums/


Re: How to I load a text file into a Database?

2005-08-04 Thread Chris Tutty
From: John Spence [EMAIL PROTECTED]
 The problem is that the database itself needs to be updated externally
 about 4 times a year.  The update form is simply a new set of data in a
 Text file in Comma Separated Value form.  The update file is more than
 64K in length.

There's no problem with the database size (details below) but the newer
Palm OS storage systems have brought back the old problem with small
record sizes so it's more important to make sure that your records are
a reasonable size - several hundred bytes is fine.  For more info read up
on database bloat problems in the forum archives.

 a) Upload the text data file to the Treo650?  Does the file need to be
converted before the Upload?
 b) Load the data in the text file into a standard Palm Database?
 c) Handle the issue of the large amount of data (greater than 64K)?

The best approach, IMHO, is to convert this to a Palm database (PDB)
file on the desktop so that you can just hotsync it to replace the existing
database.  There are a number of products that will do csv to pdb
conversion.  Google or an forum archive search should point you in
the right direction.

Because you're converting to a PDB on the desktop you're not trying
to fit the whole data block into a single memory object so 64K
becomes completely irrelevant (as long as you're not talking about a
database with only one record).  Multi-megabyte databases are common
with Palm apps.

Chris Tutty


-- 
For information on using the PalmSource Developer Forums, or to unsubscribe, 
please see http://www.palmos.com/dev/support/forums/


Re: preload a field on a popup form

2005-07-31 Thread Chris Tutty
From: druid [EMAIL PROTECTED]
 Can some one explain how I preload a field on a popup form
 so when I call that popup form from the main form the field
 is already loaded with the records field data
 
The field doesn't exist until the form is created.  Note that although
most forms are created and displayed in the same call that you 
can create a form in memory, use that form in API calls and then
display it later (the FrmInitForm() call in Robert's code).  This gives 
you a couple of options when it comes to situations where you have 
data available that isn't currently  displayed:

1. Create the form when the other data is read but don't display it.
This gives you the chance to prepopulate the form and keep it 
stashed away ready for display, but seems a bit clumsy to me.
This is also more difficult because you've got to manage the form 
creation and disposal yourself and there are a number of different
problems that can arise however if you're using popup forms you've
already got those headaches so you're not really losing anything.

2. Store the value somewhere and use it to set the field when 
the popup is displayed.
This is one of the reasons I like making each form in a C module
of it's own.  I can add a module-level variable to the form's
C module and expose a setfieldname() function in the header.
When the data is read I call the set method to store the value
for later use by the form.  When the form is popped up it's
initialisation function uses the stored value to populate the field.
I then store any modified value back in the local variable and use
a getfieldname() function to retrieve it at other times.  This 
disconnects the data storage from the form visibility.

Of course this uses global variables and requires good modularity
to your project so it's not going to suit some people.  But then
if you're going to create the form and hold it for later use you'll
need to store the form pointer somewhere anyway so...

It's really a matter of how you prefer to organise your code.
My apologies if I've raised more questions than I've answered.
I hope at least you've got some alternatives to think about.

Chris Tutty


-- 
For information on using the PalmSource Developer Forums, or to unsubscribe, 
please see http://www.palmos.com/dev/support/forums/


Re: A user that has a full mail box!

2005-07-30 Thread Chris Tutty
From: Luc Le Blanc [EMAIL PROTECTED]
 This sometimes occurs with people with palmsource.com addresses ;)

 Regarding the full mailbox problem, shouldn't these messages be sent to
the news
 mailer, not the poster? After all, to the mailer is the message origin
(spreading
 the post), not to poster.

I asked about this some years ago but the reply was that
it's really out of their control because the mail arrives at
that person's inbox with From=WhoeverPostedTheMessage
so the mail reader does what it's been told and sends a reply
to say that this person is out of the office and can't respond.

I've checked the headers and, as far as my limited knowledge
takes me, all of the other lists I'm on seem to run the same
way.  I think this list has this problem more frequently because
it's huge and has a fair number of subscribers in corporate
environments (where autoresponders are more common).

The only way to change this behaviour would be to alter the
list manager so that messages where sent using a From=trash
so that autoreplies went to a dump address.  But if you do
that then you lose any reader functionality that depends on
getting the author of the message from the From= line.

Chris Tutty


-- 
For information on using the PalmSource Developer Forums, or to unsubscribe, 
please see http://www.palmos.com/dev/support/forums/


Re: Trying to test for false and break routine

2005-07-27 Thread Chris Tutty
From: druid [EMAIL PROTECTED]
 trying to determine if the field is empty and poping up a
 alert window then breaking the routine
 been at it a few days now, Im missing something

I think your outer logic is fine, but it's failing because inside
GetFieldData() nofield is set if the text buffer or the field is
missing - these shouldn't happen if your code is written
correctly.  What you want is to have that flag set if your
field is *empty*.  Change GetFieldData so that the
if (FldGetTextLength (pField))
that does the copy has an else that sets nofield to true.

Your outer logic then has more chance of doing something
useful.

Chris Tutty

(snip)
 Boolean nofield = false;
 static Boolean frmMain_frmTestButton_OnSelect(EventPtr event)
 {
 // Insert code for frmTestButton
 GetFieldData( fldTest, testdata, 255 );
 if (nofield) status = FrmAlert(frmAleart);
 nofield = false;
  break;
 return true;
 }
(snip)
 Boolean GetFieldData (UInt16 fld, Char *text, UInt16 maxLen)
  {
   FormPtr pForm = FrmGetActiveForm ();
   FieldPtr pField = FrmGetObjectPtr (pForm, FrmGetObjectIndex (pForm,
fld));

   if (text != NULL) *text = '\0'; // initialize
   if (text == NULL || pField == NULL)
{
 nofield = true;
 return false;
}
   if (FldGetTextLength (pField))StrNCat (text, FldGetTextPtr (pField),
maxLen);
   return true;
  }
 --
 For information on using the PalmSource Developer Forums, or to
unsubscribe, please see http://www.palmos.com/dev/support/forums/


-- 
For information on using the PalmSource Developer Forums, or to unsubscribe, 
please see http://www.palmos.com/dev/support/forums/


Re: form - return to previous form

2005-07-27 Thread Chris Tutty
From: Evan [EMAIL PROTECTED]
 FrmPopupForm the new form
 then FrmReturnToForm to go back previous form
 -- 
Another alternative that sticks to standard FrmGotoForm
calls is to store a property with the id of the calling form and
use that to return.  This isn't perfect, but avoids some
issues with FrmPopForm.  I honestly can't remember what
they were, but I know the popup and return gave me some
headaches, possibly one being that you *have* to use the 
return, you can't then step off to a third form.  This can
cause your interface to become unnecessarily constrained.
Of course, if that's all you'll ever want to do then the constraint
isn't an issue.

As far as the use of globals goes, I tend to implement each
form in it's own module with a header to expose the interface.
Properties such as returnToForm are then local to that module
and managed using a setReturnToForm() function exposed
via the header.  While this is still global from the compilers
point of view it provides good modularity for code 
management.

Chris Tutty


-- 
For information on using the PalmSource Developer Forums, or to unsubscribe, 
please see http://www.palmos.com/dev/support/forums/


Re: revisit the alert issue

2005-07-27 Thread Chris Tutty
From: druid [EMAIL PROTECTED]
 there has got to be a better way, this could get ugly
 with 10 fields or so

You could wrap the test and alert in a private work function
that's passed the name and index of the field.  That means
that your main code would just be:
if (handleField(Name, fldName))
{
if (handleField(Number, fldNumber))
{
}
}
That's slightly less efficient, but is a lot easier to read.  It also
stays simple even if the logic associated with each field becomes
more complex.

For this sort of problem I've also sometimes used a loop with
a case statement:

for (fieldnum = 0; fieldnum  FIELDCOUNT; ++fieldnum)


// common set up logic

switch (fieldnum)
{
case 0:  // do stuff for field zero
break;
case 1:  // do stuff for field one
break;
// etc...
}
// common error check and clean up logic

if (err != NOERROR)
{
break;
}
} // end field for

which isn't as clean as a worker function but is useful where
the worker function would otherwise need to pass a dozen
parameters in and out.  It's essentially just using the loop to
step through a sequence (a simple state machine) to ensure
that the before and after logic in always consistent.

Chris Tutty


 #include PalmOS.h
 #include testaleart.h
 #include testaleart_res.h
 Char testdata[256], testdata1[256];
 Boolean nofield = false;
 UInt16 status;

 static Boolean frmMain_frmTestButton_OnSelect(EventPtr event)
 {
 UInt16 fld;

 // Insert code for frmTestButton

 GetFieldData( fldTest, testdata, 255 );
 if(nofield)
 {
   status = FrmCustomAlert(frmAleart, Name, NULL, NULL);
   nofield = false;
 }
 else
 {
   GetFieldData( fldTest1, testdata1, 255 );
 }
 if(nofield)
 {
   status = FrmCustomAlert(frmAleart, Number, NULL, NULL);
   nofield = false;
 }
 else
 {
   file://go to routine to save records
 }



 return true;

 }





 Boolean GetFieldData (UInt16 fld, Char *text, UInt16 maxLen)
  {
   FormPtr pForm = FrmGetActiveForm ();
   FieldPtr pField = FrmGetObjectPtr (pForm, FrmGetObjectIndex (pForm,
fld));

   if (text != NULL) *text = '\0'; // initialize
   if (text == NULL || pField == NULL)return false;
   if (FldGetTextLength (pField))
   {
StrNCat (text, FldGetTextPtr (pField), maxLen);
   }
   else
   {
nofield = true;
   }
   return true;
  }

 --
 For information on using the PalmSource Developer Forums, or to
unsubscribe, please see http://www.palmos.com/dev/support/forums/


-- 
For information on using the PalmSource Developer Forums, or to unsubscribe, 
please see http://www.palmos.com/dev/support/forums/


Re: Checking to see if field has data in it before passing it routine

2005-07-24 Thread Chris Tutty
From: druid [EMAIL PROTECTED]
 Here's a better way that has error checking, default processing and takes
 advantage of a unique feature of the PalmOS StrNCat() function to
prevent
 stack corruption:

Are you sure it's StrNCat you want and not StrNCopy?  I'm just
asking because the old version copied to text so you seem to
have changed the way the function works.

 When using a functin like this where does the maxLen
 value come from when passing the data to this function

It depends on how the buffer is defined.  If you're defining it
using a constant then pass that constant - 1.  It gets more
complicated if you're building a string up and concatenating
because you need to take the existing length of the string into
account but for StrNCopy it's generally just a matter of passing
the defined length -1.

Chris Tutty

 Boolean GetFieldData (UInt16 fldNbr, Char *text, UInt16 maxLen) {
 FormPtr pForm = FrmGetActiveForm ();
 FieldPtr pField = FrmGetObjectPtr (pForm, FrmGetObjectIndex
 (pForm, fldNbr));
 if (text != NULL) *text = '\0'; // initialize
 if (text == NULL || pField == NULL)
  {
   missing_field = true;
   return false; // I like error checking !!
  } // use missing_field to set an aleart window and brake the
file://static Boolean frmMain_saveButton_OnSelect(EventPtr event)
// so as to not allow the save ??
 if (FldGetTextLength (pField))
 StrNCat (text, FldGetTextPtr (pField), maxLen);
 return true;
 }


 --
 For information on using the PalmSource Developer Forums, or to
unsubscribe, please see http://www.palmos.com/dev/support/forums/


-- 
For information on using the PalmSource Developer Forums, or to unsubscribe, 
please see http://www.palmos.com/dev/support/forums/


Re: Checking to see if field has data in it before passing it routine

2005-07-24 Thread Chris Tutty
From: Chris Tutty [EMAIL PROTECTED]
 From: druid [EMAIL PROTECTED]
  Here's a better way that has error checking, default processing and
takes
  advantage of a unique feature of the PalmOS StrNCat() function to
 prevent
  stack corruption:
 
 Are you sure it's StrNCat you want and not StrNCopy?  I'm just
 asking because the old version copied to text so you seem to
 have changed the way the function works.

Ah, my mistake, I didn't realise that Roger had stepped in and
rewritten your function (of course if I'd actually read the whole
function I'd have seen that).

And he's added a technique for handling the missing fields.
Yeesh, I should just go back to bed.

Chris Tutty


-- 
For information on using the PalmSource Developer Forums, or to unsubscribe, 
please see http://www.palmos.com/dev/support/forums/


Re: Checking to see if field has data in it before passing it routine

2005-07-23 Thread Chris Tutty
From: druid [EMAIL PROTECTED]
 I need to check to see if the field has data in it before I pass it to
GetFieldData.
 What is the best way to do that and assign a text value to name
 if the field is NULL

Do you mean if the field is NULL or if the field contents are NULL?

If the contents are NULL GetFieldData will handle it acceptably,
although it would perhaps be better to clear text before copying any
value in fld.  Clearing it first gaurantees that there isn't old data in
text after GetFieldData returns.

Unfortunately you're not passing enough information to GetFieldData
for it to gaurantee robust results.  All functions that pass a buffer as a
char * must also pass a buffer length.  WIthout this length it's impossible
for the function to either clear the buffer if fld is NULL, or to gaurantee
that buffer overflow isn't occuring.  StrCopy is actually very dangerous
- your code will be much more robust in the long term if you remove
every StrCopy and replace it with a StrNCopy using the appropriate
defined buffer length AND terminate the string properly.  Since the
standard Palm OD StrNCopy doesn't gaurantee string termination it's
better to wrap this in a function that always terminates the string.

It's a bit of work to make sure that you always handle strings robustly,
but it'll save you time in the long run.  Tryng to track down buffer
overruns after release is insanely expensive in times of time, money
and product credibility.

So
 GetFieldData( fldName, name );

should be GetFieldData( fldName, name, nameLen );

 static void GetFieldData( UInt16 fld, Char *text )
 {
static void GetFieldData( UInt16 fld, Char *text, length )
{


 FormPtr frm = FrmGetActiveForm();
 FieldPtrfldP = FrmGetObjectPtr(frm, FrmGetObjectIndex(frm,fld));

 MemHandle hText = FldGetTextHandle(fldP);
 if (hText)
 {
   MemPtr *pMem = MemHandleLock( hText );
   StrCopy( text, (Char*)pMem );

StrNCopy( text, (Char*)pMem, length );
text[length - 1] = '\0';

   MemHandleUnlock( hText );
 }
} else
{
MemSet(text, length, '\0');
}
 }

Chris Tutty


-- 
For information on using the PalmSource Developer Forums, or to unsubscribe, 
please see http://www.palmos.com/dev/support/forums/


Re: Checking to see if field has data in it before passing it routine

2005-07-23 Thread Chris Tutty
From: Jonathan King [EMAIL PROTECTED]
 Here is a simple way to do what you are doing.

 static void GetFieldData( UInt16 fld, Char *text )
 {
 FormPtr frm = FrmGetActiveForm();
 FieldPtrfldP = FrmGetObjectPtr(frm,
 FrmGetObjectIndex(frm,fld));

 if(FldGetTextLegnth(fldP))
which needs to be:
if(fldP   FldGetTextLegnth(fldP))
if the point about the field itself being null is to be handled,
but since the code already tests the field handle for NULL
the only other thing you're doing is checking for an empty
string which, from memory, StrCopy will handle acceptably
so I'm not sure that this code adds much and...

 {
 StrCopy(text, FldGetTextPtr(fldP);
... you're not testing the FldGetTextPtr() return value for
null and, as far as I'm aware, this can return null so your
code is more fragile than the original druid proposed.
No?


  -Original Message-
  From: [EMAIL PROTECTED] [mailto:bounce-449914-
  [EMAIL PROTECTED] On Behalf Of druid
  Sent: Friday, July 22, 2005 8:53 PM
  To: Palm Developer Forum
  Subject: Checking to see if field has data in it before passing it
 routine
 
   I need to check to see if the field has data in it before I pass it
 to
  GetFieldData.
  What is the best way to do that and assign a text value to name
  if the field is NULL
 
 
  GetFieldData( fldName, name );
 
 
 
 
  static void GetFieldData( UInt16 fld, Char *text )
  {
  FormPtr frm = FrmGetActiveForm();
  FieldPtrfldP = FrmGetObjectPtr(frm,
 FrmGetObjectIndex(frm,fld));
 
  MemHandle hText = FldGetTextHandle(fldP);
  if (hText)
  {
MemPtr *pMem = MemHandleLock( hText );
StrCopy( text, (Char*)pMem );
MemHandleUnlock( hText );
  }
  }
  --
  For information on using the PalmSource Developer Forums, or to
  unsubscribe, please see http://www.palmos.com/dev/support/forums/



 --
 For information on using the PalmSource Developer Forums, or to
unsubscribe, please see http://www.palmos.com/dev/support/forums/


-- 
For information on using the PalmSource Developer Forums, or to unsubscribe, 
please see http://www.palmos.com/dev/support/forums/


Re: Checking to see if field has data in it before passing it routine

2005-07-23 Thread Chris Tutty
From: druid [EMAIL PROTECTED]
 The problem is I need to know what is in fldName before I try 
 and use GetFieldData and if the contents or the field is NULL
 not do the call to the GetFieldData routine
 
Nope, I think you're doing the right thing bu checking for NULL 
data within the function.  This means that the function is safe
regardless of what's passed to it.  You just need to check the
fldP for null and I think the function as written is fine.

Chris Tutty


-- 
For information on using the PalmSource Developer Forums, or to unsubscribe, 
please see http://www.palmos.com/dev/support/forums/


Re: Checking to see if field has data in it before passing it routine

2005-07-23 Thread Chris Tutty
From: druid [EMAIL PROTECTED]
 I tried you code change and it does work
 Now for the wierd thing
 
 I added this
 
StrCopy(text, UNKNOWN);
   }
 now if I dont fill in any of the fields and it writes this to
 the record, the very first field has the first three characters
 cut off
 OWN,UNKNOWN,Select,,

Hmm, that's the first four characters which is significant because
it's the size of a long int, suggesting that a char pointer has been
offset by one (stack corruption, mishandled pointer or something
strange about the way the constant is being stored).  It's
difficult to say why this might work for good data and fail for
the constant.  

Try checking to see if the data *before* the first field has been 
overwritten (generally requiring some work with the debugger
or a hex editor).  You want to know whether the full text has been
written to an address four bytes before the start of the field or
whether the start of the constant is wrong by four bytes but the
data has been written to the wrong location.  There are some
compiler settings for how constants are handled but I wouldn't
have thought they'd cause this sort of problem.

Chris Tutty


-- 
For information on using the PalmSource Developer Forums, or to unsubscribe, 
please see http://www.palmos.com/dev/support/forums/


Re: Palm dedicated to one application

2005-07-20 Thread Chris Tutty
From: Jerry Martinez [EMAIL PROTECTED]
 We have customer who wants his palm to only run our palm 
 app when he turns on his palm and does not want access to any 
 other feature.
 
 Is is possible?
 
If the client has the budget one alternative is to create a special
ROM image that only includes your app and drops the standard
Palm OS apps.  This generally isn't something you'd do for one
person but I mention it because it's an often-overlooked option
for the distribution of custom-purpose units within an enterprise
or as prizes or advertising hand-outs.

That takes a little preparation, but I was pleasantly surprised by 
how easy it was - of course this requires devices that have
flashable ROM.

Chris Tutty


-- 
For information on using the PalmSource Developer Forums, or to unsubscribe, 
please see http://www.palmos.com/dev/support/forums/


Re: im stumped could use some ideas

2005-07-20 Thread Chris Tutty
From: druid [EMAIL PROTECTED]
 I run my program and get no errors
 However looking at the records with par
 -d--  0   68 New QUest.22.Fair.123456789.good.A Gnoll Cave.NO
 I always end at 68 to 70 characters
 
From memory this is a par problem - I think the output was
only intended to dump database contents for debugging so
they never bothered writing code to handle any string size.

If you want to handle string contents you need to move to 
a different tool - there are a couple that convert databases
to csv or text files that handle simple databases quite well,
or a commercial tool like PDBGo that will let you write
custom scripts to extract database contents to exact
specifications (there also used to be a PDBC tool that allowed
COM access to PDB files from memory).  Google should
answer this.

Chris Tutty


-- 
For information on using the PalmSource Developer Forums, or to unsubscribe, 
please see http://www.palmos.com/dev/support/forums/


Re: Ideas on how to do this

2005-07-19 Thread Chris Tutty
From: druid [EMAIL PROTECTED]
 I have to many fields for one form
 So I want to make a popup form for some of the checkbox fields
 I was going to use a FrmPopupForm call then a FrmReturnToForm(0)
 call to go back to the origional form.

This can cause problems if it's not done carefully.  You should
review the archives of this forum for more info.

 I guess I could make global variables, but is their a better way
 to do this.

If you mean having a global structure that stores data shared by
fields spread across several forms then I think this has the solid
advantage of making it much easier to move fields between forms
or add other forms as you extend the project.  This is true regardless 
of whether you use a popup or not - you want to avoid having
the data management for the app hard-coded to the fields that
happen to be on each form.

If your app is getting to this size it's time (past time?) to create a 
code module to manage the data separately from the form code.  
This module would have the code to load and save the data from 
the database and would either expose globally visible variables 
or, more work but better, expose get~ and set~ methods for 
each property.  Just because you're coding in C doesn't mean that
you can't use the object-oriented concepts of data hiding and
interfaces.  They're really just old C concept anyway.

I guess it's obvious advice, but a great deal of the simple examples
for Palm have the field management logic in the same functions
that implement the forms so it's easy to extend these simple
examples without stopping to think that at some point their
underlying design has to be re-examined.

Chris Tutty



-- 
For information on using the PalmSource Developer Forums, or to unsubscribe, 
please see http://www.palmos.com/dev/support/forums/


Re: Why does this cause a low byte fault solved update I think

2005-07-18 Thread Chris Tutty
From: druid [EMAIL PROTECTED]
 This is what worked finaly
 Thanks to all who helped, it seems that when you create
 any key or enter event, all default action is ceased
 and must be hard coded.

Well, as I indicated in my email, when I used
static Boolean frmMain_fldName_OnfldEnter(EventPtr event)
{
SysKeyboardDialog(0);
return true;
}
it worked as expected and didn't fault.  I only tried four or
five iterations but this seemed sufficient since you'd reported
a crash after three.  I still suspect that there was something
else going on with your code.  Your last response that when
you took out the keyboard popup the crash went away doesn't
mean the rest of your code is bug-free, just that the problem
went away.  This can sometimes mean that memory or stack
corruption is happening, but that's it's not affecting important
areas of memory.  You can also have code that will work OK
as long as you don't change the active window.

It's good that you can continue moving forwards, but I'd treat
the underlying problem as mising rather than fixed.

Chris Tutty

 UInt16  entered_name = 0;

 static Boolean frmMain_fldName_OnfldEnter(EventPtr event)
 {
 // Insert code for fldName
 FormPtr form;
 Boolean handled = false;
 FieldPtr fldP;

 form = FrmGetActiveForm();
 FrmSetFocus(form, FrmGetObjectIndex(form, fldName));
 fldP = FrmGetObjectPtr(form, FrmGetObjectIndex(form, fldName));
 if(entered_name  1) EvtEnqueueKey(vchrKeyboardNumeric, 0,
commandKeyMask);
 entered_name = 1;
 FldDrawField(fldP);
 handled = true;
 return true;

 }



-- 
For information on using the PalmSource Developer Forums, or to unsubscribe, 
please see http://www.palmos.com/dev/support/forums/


Re: Crash if I click button twice

2005-07-18 Thread Chris Tutty
Druid,

It looks fine at first glance.

My only comments right now would be:
- after  labela = (Char *)CtlGetLabel( ctlP ); you should check labela
against null before using it.  From memory it's possible for a popup
to have nothing selected in some circumstances.
- How does the GetFieldData() know to limit the data to 256?  I would
have thought that this function would also need to be passed a
buffer length.

Aside from that it all looks sensible.

Chris Tutty


- Original Message -
From: druid [EMAIL PROTECTED]
To: Palm Developer Forum palm-dev-forum@news.palmos.com
Sent: Tuesday, July 19, 2005 11:34 AM
Subject: Crash if I click button twice


 this code will crash If I click the save button twice
 I must not be releasing some memory somewhere


 static Boolean frmMain_saveButton_OnSelect(EventPtr event)
 {
  Char name[256];
  Char level[256];
  Char expFld[256];
  Char desc[256];
  FormType *frmP;

  ControlType *ctlP;
  Char *labela;
  Char labelb[256];

  frmP = FrmGetActiveForm();

  ctlP = FrmGetObjectPtr( frmP, FrmGetObjectIndex( frmP, frmPopupTrig1 ) );
  labela = (Char *)CtlGetLabel( ctlP );
  StrCopy(expFld, (const char *)labela);

  if(dbPtr == NULL)
   {
 // First see if we can find it:
 LocalID dbID = DmFindDatabase(DB_CARDNO, DB_NAME);
 if(!dbID)
 {
 // Couldn't find it, so create it:
 Err err = DmCreateDatabase(DB_CARDNO, DB_NAME, DB_CREATOR, DB_TYPE,
false);
 if(err)return err;
 // Now we ought to find it:
 dbID = DmFindDatabase(DB_CARDNO, DB_NAME);
 if(!dbID)return 1;
   }
 // Found it, now open it:
 dbPtr = DmOpenDatabase(DB_CARDNO, dbID, dmModeReadWrite);
 if(dbPtr == NULL)return 1;
 }
 // Everything went smoothly:


GetFieldData( fldName, name );
GetFieldData( fldLevel, level );
GetFieldData( fldNewDesc, desc );

size = StrLen(name)+1+ StrLen(level)+1+ StrLen(expFld)+1+
StrLen(desc)+1;
index = dmMaxRecordIndex;

h = DmNewRecord(dbPtr, index, size);
ptr = MemHandleLock(h);
Offset = 0;
DmWrite(ptr, Offset, (const void *)name, StrLen(name)+1);
Offset += StrLen(name)+1;
DmWrite(ptr, Offset, (const void *)level, StrLen(level)+1);
Offset += StrLen(level)+1;
DmWrite(ptr, Offset, (const void *)expFld, StrLen(expFld)+1);
Offset += StrLen(expFld)+1;
DmWrite(ptr, Offset, (const void *)desc, StrLen(desc)+1);
MemHandleUnlock(h);
DmReleaseRecord(dbPtr, index, true);
err = DmCloseDatabase(dbPtr);
   return true;
 }

 --
 For information on using the PalmSource Developer Forums, or to
unsubscribe, please see http://www.palmos.com/dev/support/forums/


-- 
For information on using the PalmSource Developer Forums, or to unsubscribe, 
please see http://www.palmos.com/dev/support/forums/


Re: Crash if I click button twice

2005-07-18 Thread Chris Tutty
From: druid [EMAIL PROTECTED]
 this code will crash If I click the save button twice
 I must not be releasing some memory somewhere
 
dbPtr seems to be external.  You're closing this database each time, but 
keeping the dbPtr and trying to use it next time.

You need to be clearer about who owns dbPtr - if it's owned externally
then the db find, open and close should be external, if the open and 
close are going to be done by this function then it needs to own the
dbPtr.

A fast fix is to set dbPtr to null after the close.

Chris Tutty

 static Boolean frmMain_saveButton_OnSelect(EventPtr event)
 {
(snip - no declaration of dbPtr)
  if(dbPtr == NULL)
   {
(snip of find, create and open db)
 }
 // Everything went smoothly:
  
(snip of create record and write data)
err = DmCloseDatabase(dbPtr);
   return true;
 }
 



-- 
For information on using the PalmSource Developer Forums, or to unsubscribe, 
please see http://www.palmos.com/dev/support/forums/


Re: windows console application

2005-07-17 Thread Chris Tutty
From: Mike Hodkin [EMAIL PROTECTED]
 Need to walk before running.  I need to brush up on C/C++ 
 before diving into Palm.
 
The Palm stationery produces apps that will run (from memory 
a simple form with and edit field and an About form).  You can
use this as a platform to practice C skills just by writing background
modules that calculate or manipulate strings and then copy the
results to one of the pre-built forms.  I had a student that wrote
code to calculate student debt repayments and produced the 
output by using the window write routines to dump text to the
current form.  You don't have to know anything about the
Palm OS memory management, form, controls, events or database
functions to do this, but can gradually expand your tests to include
those.

The problem I've found with students working on C skills outside
of Palm OS is that it's difficult to ignore the environment issues,
particularly when the Palm libraries don't use the standard C
naming for core functions (what-ever misguided Pascal-oriented 
idiot decided to rename standard C functions deserves a good
kicking but it's with us for good now).  Although you will run into
annoying walls with Palm OS issues this group should be able
to fix those for you fairly quickly.  At least with that approach
you get your head into the right space in terms of the design, 
code, debug cycle.

Chris Tutty


-- 
For information on using the PalmSource Developer Forums, or to unsubscribe, 
please see http://www.palmos.com/dev/support/forums/


Re: Using the Table Control

2005-07-17 Thread Chris Tutty
From: Layne Lund [EMAIL PROTECTED]
 values are all static in the resource file.  Is there a way to set the
 column widths at run time instead?  Of course, this gets into a whole
 other mess in trying to calculate the width of a string in a given
 font, but I can figure out that part later.  I need to first know if
 it's even possible to set the width at run time.  (Maybe I should just

That's actually the easy part.  There are a number of good functions
for determining pixel widths and wrap breaks of text.  Example:

 // set drawing font
 FntSetFont(g_prefs.Font);
 LstGlueSetFont(GetObjectPtrFromId(frmP, MsgListMessageList), g_prefs.Font);

 // Calculate widest column contents (assumes fixed width digits)
 LineOneX = FntCharsWidth(00/00, 5);

I then draw the whole list myself using.
 // Notify Palm OS that we will draw each list item ourselves.
 pList = GetObjectPtrFromId(frmP, MsgListMessageList);
 LstSetDrawFunction(pList, ListDrawFunc);

and combinations of WinDrawChars() and
WinDrawLine(LineOneX + 1, etc to do the work.  It's a bit fiddly to
set up, but gives you complete freedom to change the style of the list
and my experience is that once you're concerned with column widths
you're likely to start wanting to make all sorts of detailed changes.
Biting the bullet to go to custom drawing pays off when you're
fine-tuning the list style.

Chris Tutty


-- 
For information on using the PalmSource Developer Forums, or to unsubscribe, 
please see http://www.palmos.com/dev/support/forums/


Re: Why does this cause a low byte fault

2005-07-15 Thread Chris Tutty
From: druid [EMAIL PROTECTED]
 testdb just read from memory location 0x324A
 which is in Memory Manager data structures

 Boolean handled = false;
 form = FrmGetActiveForm();
 FrmSetFocus(form, FrmGetObjectIndex(form, fldNewDesc));
 fldP = FrmGetObjectPtr(form, FrmGetObjectIndex(form, fldNewDesc));
  crashes here on the third time this is called
 - SysKeyboardDialog(0);
 FldDrawField(fldP);
 --
You're not testing return values at all so if either the FrmGetObjectIndex()
or FrmGetObjectPtr() calls fail (say because the resource files haven't
linked properly or fldNewDesc doesn't exist on the current form) then
all you'll get is a crash.

If you test fldP for null before trying to use it your code won't crash -
of course it won't do what you want, but at least you'll have more
chance of seeing what the problem is.

However, that's probably an aside since a crash the third time you're
doing something suggests that by the time you get here something
in the first two interations has corrupted memory or the heap.  The
problem might not be in this code at all.

Chris Tutty


-- 
For information on using the PalmSource Developer Forums, or to unsubscribe, 
please see http://www.palmos.com/dev/support/forums/


Re: freelance help / active posters

2005-07-15 Thread Chris Tutty
From: Henk Jonas [EMAIL PROTECTED]
 Aaron Ardiri wrote:
  Ben has worked for Palm Source and now works for Palm, Inc. he
  was an active posted before he started working there - but, i 
  do remember the days when i used to hold the 'most active' 
  post crown :)
  
  2938 messages 
  http://www.escribe.com/computing/pcpqa/index.html?by=Authora=Aaron%
  20Ardiri
  
  5100 messages
  http://www.escribe.com/computing/pcpqa/index.html?by=Authora=Ben%
  20Combee
 
 I only get 623 posts for me - no stop, it's 624 :-)
 
Well yeah, and I get 719 (heh - never thought of using the archive
for that) but if the archive totalled 'questions' and 'useful answers' 
separately the contribution of people like Ben and Aaron would really 
become clear.  Which is not to say that they're alone, one of the 
things that's made Palm OS development easier for me over the years 
is the extent to which this group will help with any question, no matter 
how trivial.  Many forums that are able to answer specialist questions 
become quite short-tempered with newbies.  It's the fact that this group 
has always had people with the patience to answer the simple questions 
that's helped to keep it strong  (group hug?  Come on, don't be shy).

And apologies to druid for starting a side-conversation without 
re-subjecting his thread.

Chris Tutty


-- 
For information on using the PalmSource Developer Forums, or to unsubscribe, 
please see http://www.palmos.com/dev/support/forums/


Re: freelance help

2005-07-14 Thread Chris Tutty
From: druid [EMAIL PROTECTED]
 anyone know where I can find some part time assistance for hire
 I find I am getting into areas that my six books do not
 explain well. Learning by doing is working except I spend hours
 trying to figure out something that is simple, and time is money
 so in the PALM world im going broke  LOL
 
This group is also good for reasonably fast turn-around on 
questions so I think even if you do retain someone to assist
it's always worth searching the forums or posting a question
here first.  I'm constantly amazed at how quickly obscure 
questions are answered here and for the simple questions
you'll often get two answers and a code fragment.  Of course
you have to walk away from the problem for a few hours and 
work on something else but then that's not always a bad thing 
anyway.

It's generally where you're the first person trying to do 
something that the group can't help.  As an example, I think 
Vesselin has answered about ten times as many questions 
for other people as he's had answered of his.  Actually it's about 
time PalmSource put up a monthly cash prize.  I know there's
about a dozen people I'd vote for and it's got to be saving 
PalmSource money because without this group they'd have to 
provide real support  :-)

Chris Tutty


-- 
For information on using the PalmSource Developer Forums, or to unsubscribe, 
please see http://www.palmos.com/dev/support/forums/


Re: Tungsten W emulator mangles bitmaps.

2005-07-14 Thread Chris Tutty
From: Valeriy Zamarayev (DHL UA) [EMAIL PROTECTED]
 The problem appeared with Tungsten W emulator. This is I believe the only
OS4 handheld which supports the high density feature.

 The problem is that during animation images are often mangled after some
period of play, they are a kind of rotated, the sprites are shifted to the
right, and pixels from the right border appear at the left border of the
sprite. It's quite random, because sometimes bitmaps are drawn correctly,
sometimes not.

How much is it shifted by?  Could it be an issue to do with rounding
the bit image to a byte or multi-byte boundary?

Is the shifting only once for the image or for each scan-line?  I haven't
done low-level image stuff for ages, but I recall that some shifting
occurs because the image block is mis-aligned while some is because
the image isn't the 'right' width and each scan line will be affected.  If
the shifting gets worse down the image it's a per scan-line thing
where-as if it's constant down the image it's more likely that the
start of the image data block is somehow incorrect.  Anyone that's
actually done this stuff under Palm OS can feel free to step in and
correct me (Aaron?  hello?  Paging the GamesMeister...).

Chris Tutty


-- 
For information on using the PalmSource Developer Forums, or to unsubscribe, 
please see http://www.palmos.com/dev/support/forums/


Re: -1 madness?

2005-07-13 Thread Chris Tutty
From: Bryce Burrows [EMAIL PROTECTED]
 Using PODS , i have a function i return the int value -1 from
 
 int MyGroovyFunction()
 {
   int nMyReturnValue  =0;
 // do some funky work and for a very good reason set the following
   nMyReturnValue = -1;
 
   return nMyReturnValue;
 }
 
While I agree that this should work I walked away from 
using -1 as an error return a while ago because of this sort 
of problem.   

If you use error enums or constants it doesn't matter what 
the number is and you avoid signed vs unsigned issues 
completely.  This makes it more difficult to pass back a 
value that's either data if it's = 0 _or_ 'undefined
error' if it's  0 but then experience showed that there was
more potential for obscure bugs with this sort of value
combination than by returning an error code and using
another method to obtain a valid value.  I just got sick of
finding that an error value was being used as valid data
because someone forgot that their (if x  0) was using an
unsigned x (not that you are) rather than a signed value.

Alternatively your function only returns a valid value or zero 
and use another mechanism to identify a problem.  I've got a 
number of modules where I've implemented a xxxGetLastError() 
function.  The code logic then tests this after each call rather and, 
if it's NoError, uses the return value from the function.  It's a 
mechanism that's far more robust and extendable and if you 
can get used to implementing it from day one it's no slower
to write.

I guess to a certain extent I use these methods because I
code in a team with junior programmers and I've got more
need to protect against poor judgement than one experienced
coder working alone, but then I think my coding style has
improved because of the need to establish more formal error
handling mechanisms.  

Feel free to flame me for issuing a condescending lecture on
code style rather than working out what the problem is.  :-)

Chris Tutty



-- 
For information on using the PalmSource Developer Forums, or to unsubscribe, 
please see http://www.palmos.com/dev/support/forums/


Re: -1 madness?

2005-07-13 Thread Chris Tutty
From: Bryce Burrows [EMAIL PROTECTED]
 ahh something seriously screwy is going on with PODS
 
 if (false == bFailed)
 {
   nCount ++;
 }
 
 bFailed is true , yet it heads on to the nCount++  line
 
I've found that with compiler optimisations small test code
often doesn't operate as you would expect because the
compiler eliminates code without side-effects or merges
code paths that resolve to the same end result.

What I mean is that if the code after the if () continues
on to a code section that also executes nCount ++; the 
compiler might determine that the test is redundant.  The
debugger is only approxiamating the connection between
the compiled binary and the source text and so can
sometimes indicate that a certain line is executing where
what's actually happening is that a line with the same effect
and sequence in the binary code flow is executing (if that
makes sense at all).  When you add register colouring to the 
equation it gets even more complicated.  

My suggestion is to add an else clause that does something
different whichcauses sufficient side-effect that the compiler 
is forced to execute it and see what the debugger shows
when you test that.

Chris Tutty


-- 
For information on using the PalmSource Developer Forums, or to unsubscribe, 
please see http://www.palmos.com/dev/support/forums/


Re: freelance help

2005-07-13 Thread Chris Tutty
From: druid [EMAIL PROTECTED]
 anyone know where I can find some part time assistance for hire
 I find I am getting into areas that my six books do not
 explain well. Learning by doing is working except I spend hours
 trying to figure out something that is simple, and time is money
 so in the PALM world im going broke  LOL
 
I've trained several Palm OS developers and have mentored 
people working through self-teach programs via email.  If
you're interested contact me off-list and we can discuss rates
and structure.

Chris Tutty


-- 
For information on using the PalmSource Developer Forums, or to unsubscribe, 
please see http://www.palmos.com/dev/support/forums/


Re: libexpat?

2005-07-11 Thread Chris Tutty
From: Scott Bennett [EMAIL PROTECTED]
 Just wondering if anyone has tried porting libexpat to palm (its an XML
library), If you did attempt it, what sort of problems did you encounter?
I've seen a couple attempts at XML parsers on palm but they all have their
problems, I even found a commercial one that had a 64k limit to document
size (I'm guessing they dont use the glueptrs).
 --
From memory the problem with porting most desktop XML
code is that it handles the unknown depth of the hierarchy
using stack-based mechanisms.  This produces code that
is fragile under Palm OS because of the smaller stack.  You
generally have to refactor the code to use memory-based
mechanisms for building and iterating the tree, making the
job more complex than a simple port.

Chris Tutty


-- 
For information on using the PalmSource Developer Forums, or to unsubscribe, 
please see http://www.palmos.com/dev/support/forums/


Re: ptr is handle error?

2005-07-07 Thread Chris Tutty
From: Dr. Vesselin Bontchev [EMAIL PROTECTED]
  This is definitely a case of accessing a non existent memory
  location.

 Ah, are you sure about that? I thought that accessing non-existent memory
tends to produce other kinds of errors - NULL pointer references, access to
unallocated memory, etc. But ptr is a handle? It sounds as the program is
using a MemPtr (or some other pointer) at a place where a MemHandle is
expected (or maybe the other way around?). But I thought that the compiler
would catch such things...

On the few occassions that I've had to chase memory contents
around in hex it seemed like the hex encoding of handles was
deliberately outside of the valid values for pointers.  I think
Palm OS is built to check for a pointer that 'looks like' a handle.

I don't think the compiler can always tell you if you've accidentally
addressed a handle as a pointer (I don't remember what MemHandle
and MemPtr evaluate to, but I've had this happen before when
not being careful enough with casting of return values).  I've also
got a feeling that the older types were more prone to confusion
but I'd have to dig a project out of storage to be sure.

If I'm correct about the logic being based on the the value of the
pointer, this could be confused by memory overwrites caused by
wild pointers or heap corruption, although I think it's more likely
that somewhere you're not being strict enough with casting or variable
typing.

This is nasty to track down blind so it's worth putting some work
into trying to reproduce it.  See if you can get a copy of the emulator
session your client is working with, or any details as to the sequence
of events that cause it.

Chris Tutty



-- 
For information on using the PalmSource Developer Forums, or to unsubscribe, 
please see http://www.palmos.com/dev/support/forums/


Re: Re-arranging functions in a code segment

2005-07-05 Thread Chris Tutty
From: Dr. Vesselin Bontchev [EMAIL PROTECTED]
 The code of my application is signifficantly less than 64 Kb - it is only
about 45 Kb. Nevertheless, long time ago I started getting text segment
full errors from the linker of PODS (ld). Obviously, this happened because
the distance between some function and the function it was calling had
become larger than 32 Kb.
(snip)
 My question is - is there some clever way of doing this? Alas, the linker
doesn't tell me which particular function was trying to call a function that
was more than 32 Kb away, so I didn't know which function to try moving
closer to which one.

That's a pity - it looks like PODS is significantly less useful than
CW in this respect since this wort of problem in CW would
produce a 'function out of range' error or some-such and identify
the module attempting the call and the function being called.  That
made it fairly easy to pin down the problem.

I never had significant problems running segments of 40K to 50K,
but then generally there were a couple of core modules that called out
to secondary modules and putting those in the centre of the segment
had a good chance of making all functions within reach.  With apps
that have more complex inter-connectivity it can get complicated.

I'm not sure how easy it is to compile a PODS project under
CW, but that might give you the info you need to make the app
single-segment.

Chris Tutty


-- 
For information on using the PalmSource Developer Forums, or to unsubscribe, 
please see http://www.palmos.com/dev/support/forums/


Re: Object Library for Palm OS (was Re: Old SDKs)

2005-06-27 Thread Chris Tutty
From: Ben Combee [EMAIL PROTECTED]
 At 10:05 PM 6/26/2005, you wrote:
 Are there any plans to port POL to prc-tools so that it can be used
 with the new Palm Development Suite?  Personally, I like the whole
 object-oriented paradigm.  From your brief explanation here, it sounds
 like OO provides a great way to hide the differences in the API
 changes.

 Not that I know.  In my opinion, the C++ support in prc-tools isn't quite
 able to handle POL very well -- there's no exception handling support for
 68K code, something that POL uses.  It's also more difficult to partition
 code into sections, something that POL uses in its static library setup to
 be able to pull a lot of code into a program.  The author did look at a
 prc-tools version a few years ago, but decided not to go ahead with it at
 the time.  He's the one who has rights to any future versions of the
library.

It's a pity that POL is so promising and still so constrained.
I looked into publishing some of our routines as a C library
for abstracting the version issues but both the Glue layer and
POL seem to solve half the problem, but different halves (Glue
is good for some problems, but not others, while POL seems
to be good for more problems, but only if you're coding in
C++).

I'd like to see that effort aimed at creating something that is
useful to a wider range of Palm OS coders, hell even the
initial default projects could be much more useful, but the
framework needed to allow a range of programmers to
contribute is too big a job for anyone to take on as a hobby.
It's a pity and, IMHO, the sort of thing that stays unresolved
unless someone puts up a stack of money to fund the framework
and, as for IBM and eclipse, there's got to be a good business
reason to do that.

Chris Tutty


-- 
For information on using the PalmSource Developer Forums, or to unsubscribe, 
please see http://www.palmos.com/dev/support/forums/


Re: Visual FoxPro/Palm Custom Conduit Help

2005-06-26 Thread Chris Tutty
From: Dan Wellisch [EMAIL PROTECTED]
 I want to develop a conduit application that can sync .pdb files on the 
 Palm with Visual FoxPro .dbf files.

I haven't done this, but I worked with complex integration with
an Access app some years ago and have some alternatives
you could consider.

 1) Hotsync from PDA to Desktop
 2) Run a .pdb to .dbf converter (avail. from a 3rd party)
 3) Write a Java app to read the converted .pdb in 2) and process that 
 one against the .dbf
in the Visual FoxPro application.  In essence, I would be creating 
 the hotsync to happen
using the .dbf format (via ODBC).  I know this works.
 
 4) Run a .dbf to .pdb converter (avail. from a 3rd party) and replace 
 the .pdb in the Desktop Hotsync dir
with the updated .pdb from process in 3)
 
There is a commercial app called PDBGo that could handle
2), 3) and 4) from one application.  It's a COM component
that comes with sample code in multiple languages to read
and write pdb files.

It's also worth remembering that record-based Hotsync isn't
the only way data comes off a device.  We found it easier
to work with the database backups HotSync stored in the
user backup folder.  We picked these up intact, carried out
a data import to the Access database using PDBGo and 
then created new databases for installation to the device.

In our case the app was a data collection app using Access-
-generated lookup tables so the downloaded database was 
a complete replacement for the device database.  If you want
to syncronise the device database it's a little more complex.

Another approach I've used successfully with other projects
is to build throw-away update pdbs.  By that I mean a 
small pdb with new records in it. On startup the app looks for 
databases having the 'update' naming pattern (and, of course, 
the correct CRID).  If one is found it uses the contents to update 
it's primary database and deletes the update pdb.

Certainly a strong driver in developing these solutions
were deficiencies in the earlier HotSync and conduit solutions
available and things have changed significantly in the conduit 
area since then.  As an example I've seen examples in this 
group of Delphi-based conduits that seemed to do a great 
deal of work fairly easily.  So I'm not suggesting that these ideas 
are the best way to do things, just some alternatives you might 
keep in mind.

Chris Tutty

-- 
For information on using the PalmSource Developer Forums, or to unsubscribe, 
please see http://www.palmos.com/dev/support/forums/


Re: Perl scripts for POSE

2005-06-26 Thread Chris Tutty
From: epross [EMAIL PROTECTED]
 I seem to recall seeing a few scripts that had the functionality to
 automate POSE and take screenshots, etc.  Does anyone know where I can
 find these?
 
They used to be distributed with the emulator download,
in a scripting folder.  I'm not sure if the modern downloads
include them.

Chris Tutty

-- 
For information on using the PalmSource Developer Forums, or to unsubscribe, 
please see http://www.palmos.com/dev/support/forums/


Re: New guy questions

2005-06-26 Thread Chris Tutty
 Aaron D. Campbell wrote:

  I have a few questions.  All are directed at development for the Treo
650.
 
  1) Can GPS location be integrated into an application, and does it
require additional hardware?  I want to be able to send current coordinates
to my program.
 
  2) Is it possible to allow someone to write on the screen? I want to
get a signature from a delivery location.
 
  3) Can an app send post requests to a website, and receive data back?
 
  4) How hard is it to integrate barcode scanning into an application
(preferrably a bluetooth scanner)
 
  5) I'm a web programmer, who has no experience developing anything but
websites for the palms.  Where is a good place to go to find a developer to
create this app?
 
It sounds like you're building yet another courier support
application.  I'd write up a spec detailing your requirements
and then announce the project here requesting bids. I'm
sure that this has been done half a dozen times before so
another approach might be to search PalmGear and google
for existing products.

Chris Tutty


-- 
For information on using the PalmSource Developer Forums, or to unsubscribe, 
please see http://www.palmos.com/dev/support/forums/


Re: Old SDKs

2005-06-25 Thread Chris Tutty
From: Tam Hanna [EMAIL PROTECTED]
 I don't beleive that artificially restricting to OS5 is a good idea. 
 Just think about all the Zires and the existing user base.
 I always try to target OS3.5, as that is a pretty good common 
 denominator(first 8meg devices,...)!

The difficulties with pre-OS4.1 are you get into times when the
base APIs were still in a state of flux.  This affects things such as 
form painting (the event sequences and the way background painting 
was done changed), the serial libraries changed, sound management 
changed (I think?).  Not that I want to imply that this has stopped
happening.  :-)

Our code for 3.1 to 4.1 support effectively has an abstraction
layer that works out what routines are appropriate for the OS
version and adjusts.  It's a pain to support and debug.

While I agree that you can often support a wider variety of 
devices by coding carefully, it's easy to forget how much has 
been added to Palm OS.  Image buttons, for instance, are 
pre-4.1 from  memory and handling those yourself is just a pain.  
They're also an example of something that influences the look of 
the app and can only be worked around by having two sets of 
resources.

The other approach is to make an assessment as to how much 
of the coding work is interface-driven.  For an app that has a 
lot of code related to storing data, performing calculations and
communicating with a server it can be a relatively small task
to define a function interface between the core modules (which
will change very little over OS versions) and the interface
(which will look completely different under a colour 320x320
OS5 device than on a mono 160x160 OS 3.5 device) and
then build two interfaces.  For your friend build the OS 3.5
interface but tinker with a prettier colour interface that you
can flesh out if the app becomes viable as a commercial
product.  

It sounds more complicated to have two interfaces but it's
often less work to have two simple, tightly targeted code 
modules than one complex, multi-version, multi-format 
code module.  If you plan for this from day one you can
save some pain downstream.

Chris Tutty

-- 
For information on using the PalmSource Developer Forums, or to unsubscribe, 
please see http://www.palmos.com/dev/support/forums/


Re: PluggedIn Site

2005-06-21 Thread Chris Tutty
From: epross [EMAIL PROTECTED]
 Thanks for the quick response.  Just to note, I only get this with
 Netscape.  With IE it works just fine.  What browser are you using?
 
It's showing a problem that has something to do with cookie 
handling - do you have cookies turned off?

Chris Tutty

-- 
For information on using the PalmSource Developer Forums, or to unsubscribe, 
please see http://www.palmos.com/dev/support/forums/


Re: giving error as app1 just read from memory location 0*000000001,which is in low memory

2005-06-13 Thread Chris Tutty
From: rupesh kumar [EMAIL PROTECTED]
 i am trying to access the contacts database.my application name is app1.
 its compiled well but at runtime when tring to get the data it is giving
error as app1 just read from memory location 0*1,which is in low
memory.
 why this error is coming ?

In general this means that you're passing a null pointer to
an API call, or using a null pointer as a structure reference.
The only strange thing is that the value reported is often
the offset of the value requested from the start of the struct
which should really be an even number because of structure
padding.

Anyway.  The first thing you need to determine is where in
your program this is happening, either by debugging or by
writing to a log as your program operates.  Without this
information it is very difficult to identify which value is incorrect.

You could also work carefully through your code making sure
that every pointer is tested for null.  This is time-consuming
but is useful to ensure that your code is robust.

Chris Tutty


-- 
For information on using the PalmSource Developer Forums, or to unsubscribe, 
please see http://www.palmos.com/dev/support/forums/


Re: HTML

2005-06-09 Thread Chris Tutty
From: Jerome Chapdelaine [EMAIL PROTECTED]
 A while ago I looked at the help widget of FLTK. It can render basic 
 html and it would be very easy to port (only the font handling + box 
 rendering if you don't need bitmaps). But it would probably not handle 
 full web pages very well... I would use it only for formatted text.
 
I have a couple of clients and some potential projects 
that require simple HTML display and would be willing
to contribute to a project such as the port described.  The
only difference is that I'd want to include bitmap display. I
don't have the time to take the whole project on.

Chris Tutty

-- 
For information on using the PalmSource Developer Forums, or to unsubscribe, 
please see http://www.palmos.com/dev/support/forums/


Re: HTML

2005-06-09 Thread Chris Tutty
From: James Fisher [EMAIL PROTECTED]
 Why don't you use the Addit viewer?  It renders html passed through a 
 simple content maker.  Addit is shipping on the ROM of all new palmOne 
 devices. You can call the viewer with appropriate content and include 
 various buttons, links etc to launch back to your app.  It has a ton of 
 functionality available.
 
 It isn't free for commercial use but is free in most cases for 
 developers using it in their own commercial apps.  Their would be a 
 license fee if you developed the app for a commercial end user.
 
Which is all of the apps I'd use it for.  I couldn't find any info on
using AddIt in this way - all documentation assumes that it is downloaded
for use as a software portal and so doesn't talk about distribution 
or licensing for other uses.

Can you point me to the documents that cover the legal and pricing
details?

Chris Tutty

-- 
For information on using the PalmSource Developer Forums, or to unsubscribe, 
please see http://www.palmos.com/dev/support/forums/


Re: White screen with Treo 650?

2005-06-07 Thread Chris Tutty
From: Paul Jensen [EMAIL PROTECTED]
 I distribute a couple of freeware PalmOS apps (mainly as a hobby), 
 and I have received a couple of reports from users with Treo 650s. 
 They claim when they run the apps they get a white screen (or in one 
 case that they can see buttons, but not a drawn image).
 
I've seen that before - now if only I could remember what
caused it  :-)

I haven't worked on a Treo650 and I've accidentally caused
problems like that so it might not be the Treo.  From memory
one of the causes was some old code built to allow custom
drawing onto Palm OS 3.5 and 4 screens that was messing up
under Palm OS 5 and, also from memory, it was related to
changes in the event sequences or timing of events sent when
a form is opened and drawn.

I'm not sure how the speed of the Treo650 relates to the T/E
so can't comment on whether this might be affecting event
sequences (leading to the problem not presenting for you).  If 
one of the users is willing to put in the time as a tester I'd 
suggest cleaning up the form open and draw logic specifically 
for Palm OS 5 and see if that improves things.  Also try to make
sure that you're not assuming too much about the event sequence
you will receive when a form opens.

Chris Tutty

-- 
For information on using the PalmSource Developer Forums, or to unsubscribe, 
please see http://www.palmos.com/dev/support/forums/


Re: Treo 650 question

2005-06-03 Thread Chris Tutty
From: Mikael Esesien [EMAIL PROTECTED]
 I have customer in Germany who can't get my app to run on his Treo 650. He
has it installed on the extension card and keeps receiving the following
message: Nicht gengend Telefonspeicher frei, um die Anwendung von der
Karte zu starten, which he says tranlates as:Not enough telefon storage
avalable to start the application from the card. I asked whether or not he
meant the SIM card - though he didn't answer. I explained that the app
should be copied to the RAM at runtime and not the 'telephone card?' This is
baffling me. I have no experience of the 650, so I can only guess what is
going on.

Is it possible that he's just filled the device up?  You could ask
him to report the amount of free space on the device.  Running
your app on a 650 simulator might tell you if the bloat occurs
and would help point your client in the direction of the information
you want regarding free space.

Chris Tutty


-- 
For information on using the PalmSource Developer Forums, or to unsubscribe, 
please see http://www.palmos.com/dev/support/forums/


Re: A question, v.valev

2005-05-28 Thread Chris Tutty
From: Roger Stringer [EMAIL PROTECTED]
 It also looks like, based on the couple of Palm OS for Linux sessions I
 went to at the Developer Conference this week and some private
 conversations with some technical people from licensees, that PalmSource's
 implementation approach for Palm OS for Linux looks very good.

 Their approach should ensure excellent forward compatibility for
 applications developed for both PACE (68K emulation) and also Protein
 (native mode) environments. Because of the Protein compatibility of Palm
 OS for Linux , licensees who implement Cobalt-based devices shouldn't be
 left out of the application development stream, ...

And, more importantly, we might actually get a Palm OS
platform that doesn't feel ten years behind the times (64K
barriers, no threading, difficulties for C++, etc).  When
the Palms first came out I was amazed that the power of
my old Atari1040 had been squeezed into a 'top-pocket'
device but that was a while ago now and the OS is really
starting to show its age.

What I'm more interested in is whether the Linux kernel
will be accessible or whether it will be locked away the
same way the original threaded kernel was.

Chris Tutty


-- 
For information on using the PalmSource Developer Forums, or to unsubscribe, 
please see http://www.palmos.com/dev/support/forums/


Re: How to make a NOT-EVEN length struct?

2005-05-27 Thread Chris Tutty
From: Logan Shaw [EMAIL PROTECTED]
 Chrix Bell wrote:
  I have make a struct with two offsets and a take-place field
  looks like this:
  struct whatever{
  unsigned Aoffset;
  unsigned Boffset;
  char FirstField;
  } 
  I want to use this to pack the record size,
 
 What does pack the record size mean?
 
Since the original message described writing two fields my guess 
would be to pack string data from multiple fields into a database 
record without unnecessary padding.  This is hardly a new concept
for Palm OS databases :-)

I tend to create the struct ending with a char[2] to indicate that this
is string data rather than an individual char and, more importantly,
comment the struct to indicate to any programmer that follows you
that the record data entends past the end of the struct. 

  data would be write from
  FirstField, write A, then from (FirstField+ Boffset), write B.
 
 What are A and B?  Are the some sort of data you want to write
 into a database?  Are they variables?  Are they instances of
 struct whatever?
 
Doesn't matter.  The concepts are the same regardless of the 
objects - find the size of the first and second, create a buffer 
big enough for the data and any management overhead, write 
the first record to the buffer at offset zero (or just past any record
header), find the size of the second and write at an offset just 
past the end of the first block.  Then (if you want to use the technique 
this poster seems to be following) write the offset for the second
record to the header at the start of the buffer and close the record.

The problem is that you don't write B at (FirstField+ Boffset).  
Generally each field is written at the stored offset matching it
so A would be stored at Aoffset (strictly redundant because
you know it starts at the offset of the FirstField struct member),
then Boffset is calculated as Aoffset + (sizeof(A) or StrLen(A))  
+ 1 (depending on whether you're storing a struct or a string and 
a nasty trap for beginnners) and B is stored at Boffset.  Continue
as required.  The calculation mistake is probably why you're 
getting an out of bound error.

This has been done before so try to find some code that 
implements this and copy it.

  I am wondering if there are some other kind of skills can make
  the record's length not a fixed one.
 
 If by the record you mean the struct, then it is impossible.
 In C, a struct's size is determined at compile time.  
Strictly correct, but slightly misleading...

 If you need
 to write a data structure whose length differs depending on what it
 contains, you will need to write it by hand, one byte at a time.
 (Or with DmWrite() or MemMove() or similar.)
 
I've seen this technique of a using a struct to describe the fixed 
elements and appending strings to the end of it fairly often in
Palm OS apps - I'm sure at least one of the sample apps does 
things this way so it's not only not impossible, it's fairly standard
for Palm OS.  The confusion is that you've got to understand
that the struct is just a guide that simplifies accessing the start
of the record - the actual data extends beyond it so, as you say,
you've got to be careful about deciding whether you're going to
write the struct as a block and then append data or write the 
contents of the struct member by member (generally safer).

If you're only storing strings you actually don't need the offsets
as long as you make sure that each string is null-terminated in the buffer.
You can then read the first string at offset zero and the second
at offset StrLen(firststring) + 1).

Storing the offsets can still be useful if you're writing many strings
and want to quickly extract one without reading the preceeding
strings.

Chris Tutty

-- 
For information on using the PalmSource Developer Forums, or to unsubscribe, 
please see http://www.palmos.com/dev/support/forums/


Re: How to develop an application to support other than english language?

2005-05-27 Thread Chris Tutty
From: babbu cathy [EMAIL PROTECTED]
 Is it possible to create an application in Palm OS for
 supporting of some other languages(Japanese or German
 or French,...) than English?
 
There are a couple of approaches.  Palm OS supports localisation
(see the Palm OS Companion section on localisation).  This basicly
works by copying your resources, modifying them for other 
languages and tagging them with the language they are for.  This is
all you need and is quite straight-forward for the european languages
 - I'm not sure if the localisation supports asian languages, but 
even if it does just modifying the resources and writing your code
becomes more complex because you move into multi-byte
characters.

This approach interacts automatically with the locale in the Palm 
device to show the language the user has chosen but, although
this is handy, means that it isn't always the best answer.  I've had
clients who wanted their customers to be able to change languages
on the fly and for that you'll have to manage langauge selection
and possibly resource loading on your own.  I wrote a simple 
mechanism that stored multiple copies of the bitmaps and string
resources and loaded the appropriate one depending on the 
language the user selected.  

The other problem with localisation that this overcomes is that
localisation turns your app into two files - the prc and a set
of locale overlays.  This works fine if it's all in ROM (which is
how PalmSource distribute their apps) but can be a hassle
for downloaded apps where end users will be doing the install.

There are also commercial localisation frameworks.  These are
powerful and expensive.  If you can afford them they will save
your project money in the long term but there can be quite a
financial hit to pick them  up.

As an aside - the SDK used to have a spreadsheet buried 
somewhere wityh european translations of the standard Palm OS
text.  Useful if you're doing internationalisation yourself on the
cheap.

Chris Tutty

-- 
For information on using the PalmSource Developer Forums, or to unsubscribe, 
please see http://www.palmos.com/dev/support/forums/


Re: displaying a text string that is longer then the screen is wide

2005-05-21 Thread Chris Tutty
From: Jerome Chapdelaine [EMAIL PROTECTED]
 Use FrmCustomAlert with the ^1, ^2 and ^3 replacement placeholders.
 -or-
 Build a custom modal dialog box with a multi-line read-only text field. 
 The dotted underline of text fields can also be removed in the 
 resource editor. If you want to resize your dialog box to fit, you can 
 compute the field height required with FldCalcFieldHeight, resize the 
 controles, then draw your form. etc...
 
There are also text functions that will tell you how much text will fit
on a line at the current font size, screen resolution, etc so if the
answers above aren't usable it isn't that hard to write a function
that wraps text to the screen.  Come back if you need more
detail on this option.

Chris Tutty

-- 
For information on using the PalmSource Developer Forums, or to unsubscribe, 
please see http://www.palmos.com/dev/support/forums/


Re: MemPtrResize

2005-05-09 Thread Chris Tutty
From: Orasanu Iuliana [EMAIL PROTECTED]
 I'm finding very difficult to work with memory allocation on this
platform... :-(
 I'm trying to reallocate a memory chunk, and my code looks like this:

 pDBName = (char**)MemPtrNew( sizeof( char*)*2); // i'm allocating memory
for only 2 fields,

Nope, this problem is reported fairly regularly and there
are some excellent detailed explanations in the forum
archive but the short answer is that a char * isn't a field,
it's a pointer to a field.  You've allocated 8 bytes, enough
to store two pointers, but what you *really* want is a
block of memory large enough to store your two strings
(however large they may be).

You can either use a fixed-size strategy, and allocate 20
chars, or 40 , or 200, and then limit your strings to that size
(less one for the null terminator), or use a packed approach
and allocate enought memory for the StrLen(field) + 1, twice.

Sorry if this is confusing but, as I say, it's been covered very
well just recently by someone.

Chris Tutty



-- 
For information on using the Palm Developer Forums, or to unsubscribe, please 
see http://www.palmos.com/dev/support/forums/


Re: MemPtrResize (oops)

2005-05-09 Thread Chris Tutty
My apologies,

I didn't read your message carefully enough (thanks to Vesselin
for answering properly).  Please ignore my earlier reponse.

From: Orasanu Iuliana [EMAIL PROTECTED]
 I'm finding very difficult to work with memory allocation on this
platform... :-(
 I'm trying to reallocate a memory chunk, and my code looks like this:

 pDBName = (char**)MemPtrNew( sizeof( char*)*2); // i'm allocating memory
for only 2 fields,

 Char *name;
 // then... in a while rutine:

 name = (char*)MemPtrNew(appInfo.nameBufLen);
 StrCopy(name,appInfo.nameP);
 pDBName[*row]=name;
 index++; // this keeps the curent no of fields allocated
 if (index 2)
 MemPtrResize ( pDBName, sizeof(char*)*index); // the error that i'm
caching here is memory locked, but in the documations I read: Call this
routine to resize a locked chunk. 

 What's the error is my code?

 Regards, Iulia
 -- 
 For information on using the Palm Developer Forums, or to unsubscribe,
please see http://www.palmos.com/dev/support/forums/


-- 
For information on using the Palm Developer Forums, or to unsubscribe, please 
see http://www.palmos.com/dev/support/forums/


Re: MemPtrResize

2005-05-09 Thread Chris Tutty
From: Orasanu Iuliana [EMAIL PROTECTED]
 pDBName = (char**)MemPtrNew( sizeof( char*)*2); // i'm allocating memory
for only 2 fields,
 Char *name;
 // then... in a while rutine:

 name = (char*)MemPtrNew(appInfo.nameBufLen);
Perhaps this needs to be appInfo.nameBufLen + 1?  A buffer overrun might
trash the start of the next block on the heap, possibly confusing the OS.

 StrCopy(name,appInfo.nameP);
 pDBName[*row]=name;

Shouldn't this be pDBName[index]=name; ? (although I don't think that
on it's own would produce a problem unless *row wasn't valid).  I also
wouldn't have thought that you need the 'name' variable, since you could
save directly into pDBName[].  Which leads to the question as to whether
you need to resize the array before you store the new pointer, although
it looks like you're always keeping an empty position at the end of the
array.

What can help to reduce memory fragmentation with this sort of logic is
resizing in units of ten or twenty.  You have to store the arraysize and
current element count separately, but it avoids the repeated resizing
involved with this approach.  If you're worried about wasted space you
can always finish by resizing the array to the final size.

 index++; // this keeps the curent no of fields allocated

 if (index 2)
 MemPtrResize ( pDBName, sizeof(char*)*index); // the error that i'm
caching here is memory locked, but in the documations I read: Call this
routine to resize a locked chunk. 

Yeah, I never understood why a Ptr API call would return a locked
error, but my guess was that it was an old doc error, or a side-effect
of the low-level code that handles ptrs and chunks.

Chris Tutty


-- 
For information on using the Palm Developer Forums, or to unsubscribe, please 
see http://www.palmos.com/dev/support/forums/


Re: default application database

2005-05-08 Thread Chris Tutty
From: Vincent Uy [EMAIL PROTECTED]
 what is the format of the resource file for pdb? are there any
documentation on this?

From a recent message on this forum:

- Original Message - 
From: Dr. Vesselin Bontchev [EMAIL PROTECTED]
 I've read the documentation provided by PalmSource


http://www.palmos.com/dev/support/docs/protein_books/File_Formats/Intro.html#970019

http://www.palmos.com/dev/support/docs/protein_books/File_Formats/PDBandPRCFormat.html#972428


With the oft-repeated note that there are a number of tools
available for working with these files (par, pdbc, ...).

Chris Tutty


-- 
For information on using the Palm Developer Forums, or to unsubscribe, please 
see http://www.palmos.com/dev/support/forums/


Re: shut down problem

2005-05-04 Thread Chris Tutty
From: Scott Erickson [EMAIL PROTECTED]
 functions with no problems.  then in appstop i try to free the memory with
 MemPtrFree(currentSettings);  yet the simulator tells me i have an unfreed
 chunk (same as the value of the pointer to the variable), and the device
 softresets at this point.  how can i free the chunk of mem i am using for
 this variable?  below is some relavent code from my app...

  typedef struct{
   Boolean monitor;
   UInt32 aUpdate;
   Char* lastUpdate;
   Char* license;
  } appSettings;
 appSettings *currentSettings;

 (in appstop)
 MemPtrFree(currentSettings);

What are lastUpdate and license pointing to?  Are these allocated
and released elsewhere or could these be the unfreed chunks?

I also have a habit of setting pointers to null after freeing them.
This helps to identify accesses after release and multiple release
attempts.  Certainly the unfreed chunk itself shouldn't produce
a reset so you might be looking for a different problem
completely, with the unfreed chunk just a side-issue.

Chris Tutty


-- 
For information on using the Palm Developer Forums, or to unsubscribe, please 
see http://www.palmos.com/dev/support/forums/


Re: Re[2]: T5 database HotSync file size problem

2005-05-03 Thread Chris Tutty
From: Adrien Regimbald [EMAIL PROTECTED]
 Unfortunately, there is no way around this for now. Perhaps PalmOne
 will issue a patch, but we don't have any news that one is coming as
 of yet. The minimum record size on the T5 is actually 512 bytes, which
(snip)
 physicalIndex = logicalIndex / logicalRecordsPerPhysical;
 physicalOffset = logicalRecordSize * (logicalIndex %
 logicalRecordsPerPhysical);
 
 Of course, it would be a good idea to put this functionality in a
 wrapper class of some sort, so that you have a new logical family of
 database functions to perform all of your physical - logical
 translation for you.

Which is exactly what Palm(One or Source) could do and release 
open-source if they were serious about helping developers
overcome this problem.  For many apps I suspect that a simple
wrapper for the Dm functions would do the job, although I haven't
investigated.

Has anyone that's taken this step got an opinion on whether it 
can be implemented as a wrapper lib without code changes?

Chris Tutty

-- 
For information on using the Palm Developer Forums, or to unsubscribe, please 
see http://www.palmos.com/dev/support/forums/


Re: How to determine available storage space

2005-05-03 Thread Chris Tutty
From: Robert Moynihan [EMAIL PROTECTED]
 Miguel Angel Sotomayor Hernandez wrote:
  relevant. Is there a function, like VFSVolumeSize, but to determine 
  the availbale space in storage ram? I need to let the user know when 
  the device is running out of space and calculate how much data 
 
 You probably need to use MemHeapFreeBytes(), iterating through the 
 individual heaps and tallying them up.  Bob.
 
From memory heap 0 is dynamic and heap 1 is storage, but some
quick testing should tell you which is which.

Remember to keep a good safety margin because things start
getting nasty when storage gets tight - it's worth helping users
to keep some spare space if you can.

Chris Tutty

-- 
For information on using the Palm Developer Forums, or to unsubscribe, please 
see http://www.palmos.com/dev/support/forums/


Re: Strange error when trying to intercept sysNotifyVolumeMountedEvent

2005-04-30 Thread Chris Tutty
From: Dr. Vesselin Bontchev [EMAIL PROTECTED]
 It's just not designed at all with systems programming in mind. 
 Anti-virus programs, device drivers, other deep stuff - hell, even 
 writing libraries isn't exactly trivial there...
 
Actually one of the things that occurred to me after writing that is 
that you're possibly missing what seems to be a base assumption
to Palm OS development - that OS-level programming (which is
what you're doing) will be done by licensees working with 
PalmSource.  Much of this isn't documented simply because 
there are only a handful of apps that will ever be written at that
level and the assumption is that those people approach PalmSource,
demonstrate the usefulness of their application to the platform and
gain NDA-protected access to internal information.

I think you're feeling the pain of being isolated from that process,
but your organisation certainly has the credibility to sign into an 
agreement with PalmSource.  Now I've never done this, but I've
worked with hardware developers for whom it's commonplace.

Has your organisation contacted PalmSource with a view to gaining
access to their internal resources?

Chris Tutty

-- 
For information on using the Palm Developer Forums, or to unsubscribe, please 
see http://www.palmos.com/dev/support/forums/


Re: Strange error when trying to intercept sysNotifyVolumeMountedEvent

2005-04-29 Thread Chris Tutty
From: Dr. Vesselin Bontchev [EMAIL PROTECTED]
(yesterday)
 good old MS-DOS you just intercepted an interrupt vector 
and did whatever you wanted when the interrupt arrived - 

Perhaps your memory is different to mine, but I remember all
sorts of frustrating, nasty, undocumented problems with apps
that just grabbed an interrupt ... and did what they wanted.  
It was a support and maintenance jungle - but possibly you 
remember it differently to me.

 but even Windows 3.x could do cooperative multi-tasking 
 while running over MS-DOS on a 640 Kb machine with a 
 similar CPU... Sigh.
 
Yeah.  With the emphasis on 'cooperative'.  Anything that
broke the rules even slightly brought the whole house of
cards down on it's arse.  Or is this my memory failing me
again  :-).

I'm not going to pretend that Palm OS was brilliantly designed, 
but I think your repeated howls to return to the good old 
days of DOS aren't taking into account that most of what 
you're working with is better designed and better documented
than DOS ever was.  I'm not disagreeing that you could do
what you wanted in DOS and you can't in Palm OS, but that's
life.  I remember a huge mountain of things that just didn't 
work in DOS and do in Palm OS.

Chris Tutty

-- 
For information on using the Palm Developer Forums, or to unsubscribe, please 
see http://www.palmos.com/dev/support/forums/


Re: Strange error when trying to intercept sysNotifyVolumeMountedEvent

2005-04-28 Thread Chris Tutty
From: Dr. Vesselin Bontchev [EMAIL PROTECTED]
 Help? Is this the correct way for an application to launch itself with a
custom launch code and to check whether this is how it has been launched?

If I recall correctly, some apps handle notifications by setting
an alarm that will launch their app normally in a second or
so.  This gives the OS activity associated with the notification
time to settle down.  It seems to me that in attempting to
immediately transfer control to the same app you are setting
yourself up for timing and event-queue issues, although I've
never attempted to do anything like this.

Chris Tutty


-- 
For information on using the Palm Developer Forums, or to unsubscribe, please 
see http://www.palmos.com/dev/support/forums/


Re: DmOpenDatabase returns ErrCantOpen

2005-04-28 Thread Chris Tutty
From: Luc Le Blanc [EMAIL PROTECTED]
 A user sent me a PDB he created with my program some time ago but that
 he can't open anymore (although the database is found by
 SysCreateDataBaseList.). When I try to load it under POSE, the emulator
 reports a Can't open error, but the PDB nonetheless appears in the FileZ
 list view. Deleting it with FileZ and retrying eventually succeeds. Even
 when the PDB is finally loaded into POSE, it can still fail opening. I
 traced the problem: DmOpenDatabase returns 0x206 (dmErrCantOpen); my
 program then offers to delete it, but this fails too (how does FileZ do
 that?).  Ideas? I put that 1.6 Kb PDB on:
 
PDBGo shows a header that looks basicly OK (CRID = AURI, 
Type = Cave, Name = Fieux 2_Cave) with an AppInfoArea at 
offset 224 and 18 data records, 17 at 56 bytes and the last at 
138 bytes.  The category list is just binary data, but then you'd get 
that if you had an AppInfoArea but didn't storing categories (the 
PDB spec doesn't provide any way to identify this).  Does this 
sound about right?

Chris Tutty 

-- 
For information on using the Palm Developer Forums, or to unsubscribe, please 
see http://www.palmos.com/dev/support/forums/


Re: Any ideas when Mac version of Eclipse IDE will be out?

2005-04-27 Thread Chris Tutty
From: [EMAIL PROTECTED]
 A Mac version of Eclipse is already available from eclipse.org but I
expect that you were really asking, When will a Mac version of Palm OS
Developer Suite be available? I can't answer that one but I can say that
I'm open to input from any Mac developers on how important this is to them.
Feel free to email me directly.

Actually I suspect what's needed is a head-count.  I've seen a
few people step up from time to time and complain that the Mac
community isn't supported but I've got no idea what the size
of that community is.  As a manager I'd want to know whether
that's a dozen vocal developers or a thousand quiet ones before
deciding how much money that group gets.

I'm not sure how you'd carry out that head-count.  Perhaps the
easiest way is for someone to establish a Yahoo group and invite
subscriptions.  That's an easy way for the Mac users to say This
is who we are and we want it now.

Chris Tutty



-- 
For information on using the Palm Developer Forums, or to unsubscribe, please 
see http://www.palmos.com/dev/support/forums/


Re: Please explain why this solution works...

2005-04-26 Thread Chris Tutty
From: Dr. Vesselin Bontchev [EMAIL PROTECTED]
 Folks, note that all this still doesn't answer Scott's original question.
Even if he's computing the string size incorrectly, why does his program
behave differently under the simulator and on the real device? It ought to
either fail in both cases or work correctly in both cases.

Not if the mis-calculation is used as the basis for a string
operation.  If, for example, that length was used to do a
StrNCopy or MemCopy and produced a non-terminated
string the behaviour of code that used that string would depend
on what followed it in memory.  The memory allocation
might return clean memory on the simulator and buffer
crap on a device (although I'm not as confident about this
with the simulator as I was with the emulator because the
emulator was known to produce memory allocation with
certain characteristics while the Simulator is, in theory, the
same OS code as the device).

Still, when it comes to how an app functions when the wrong
length is given for a buffer it's easy for the answer to depend
on trivia such as whether the device was reset before the test,
whether the ROM used in the simulator is *exactly* the same
version as the code on the device, whether the protocol used
is exactly the same (this is, after all, a hangup that follows giving
the OS the wrong length for the data being sent - protocol settings
might determine whether the connection survives this or gets into
an invalid state)..  My bet is that it would be possible to identify
the source of the difference, but that it might take weeks of work,
some seriously low-level debugging and disassemblies of the
NetLib code on both the device and the Simulator.

Chris Tutty


-- 
For information on using the Palm Developer Forums, or to unsubscribe, please 
see http://www.palmos.com/dev/support/forums/


Re: error checking and debuging on the device

2005-04-25 Thread Chris Tutty
From: Dr. Vesselin Bontchev [EMAIL PROTECTED]
  It doesnt lock up on the simulator, but it does on the device.
 
 This is an unpleasant one... It is not supposed to happen. 

In practice it will happen for all sorts of things.  I've regularly had 
code work fine on the simulator and lock up the device (generally
intermittently).  It often seems to be related to the hardware
altering the timing of sequences or locking resources differently 
(the most recent I had was an API call that was sometimes causing 
a reset during startup on a T3, but was theoretically sound and 
worked fine in testing. I suspect that that was related to the app 
attempting to call the API early in the startup sequence while the 
OS still had the associated resources locked, since when I altered
the logic to delay the API call the problem went away).

What I found useful over time was to develop a set of logging
functions that wrote to a database.  This database could then be 
picked up from the backup folder and analysed.  It's slower than
debugging, but then I used to spend a lot of time with external
devices connected to the serial port and that pretty much trashes 
your chances of device-based debugging.  It's also impossible to
trace timing-dependent problems by stepping your code. And
finally, you can send a log-enabled copy of your app to that one
person who can reproduce that last intermittent crash and have
them return the log pdb to you.  Try doing *that* over a serial 
port  :-)

The logging functions don't have to be complicated, just open a
database and just write data strings to it.  It's useful to write comma-
-separated strings that start with an incrementing value and a log 
entry type because you can then dump the data out to a text file and 
import into a spreadsheet or database for analysis.  This is useful 
when you've got twenty thousand lines of debug log and you want 
to pick out one type of log entry.  Including the current tick count is 
also sometimes useful.

I keep meaning to package my log routines as a resource for
developers, but it's only an hour or so's work to write your
own so...

Chris Tutty


-- 
For information on using the Palm Developer Forums, or to unsubscribe, please 
see http://www.palmos.com/dev/support/forums/


Re: the specified index is out of range.... when using DmReleaseRecord

2005-04-19 Thread Chris Tutty
From: Mishael Kim [EMAIL PROTECTED]
 //authenticatedH is created and set to false
 recIndex = 2;
 authenticatedH = DmNewRecord(gDB, recIndex, recSize);
 if (authenticatedH)
(snip)
 DmReleaseRecord(gDB, recIndex, true);

 //authenticatedH is set to true later in code
 recIndex = 2;
 recP = MemHandleLock(authenticatedH);
 DmSet(recP,0,1,true);
 MemHandleUnlock(authenticatedH);
 DmReleaseRecord(gDB, recIndex, true);

 The first creating and initializing works fine...but when i release it the
second time i set it to true, i get an error saying that the specified index
is out of range.

From the API documentation for DmReleaseRecord:
   Call this routine when you finish modifying or reading a record that
   youve called DmGetRecord on or created using DmNewRecord.

So you're creating a new record, writing some data to it and
releasing it - fine.  You then tell the OS ok, I'm releasing this
again and the OS replies Huh? you've already released that
record.  Once you've released a record you should stop using
any resources associated with that record.  If you want to write
more data you have to use DmGetRecord to ask for the handle
again.  Just because you've still got a handle lying around from
the last Dm call doesn't mean that it's valid to use it.

You've got to remember that while that memory handle might still
be available and the lock and write might seem to work that this
doesn't necessarily mean that you're following a valid sequence of
API calls.  What you're doing (New, modify, release, modify,
release) would produce bad results in most API's I've seen.  What
you should be doing is (New, modify, release, Edit, modify,
release).

What's confusing is that the MemHandleLock looks like it's locking
the record for editing, but it's not.  Remember that the MemHandleLock
isn't a Dm function - calling it doesn't interact with the database API
at all.  The memory manager and database manager are two layers
so you'll have two levels of lock and unlock for each access (I like
to wrap these up into one function so that it's impossible to access
the handle after releasing the record, but that's just me).

Chris Tutty


-- 
For information on using the Palm Developer Forums, or to unsubscribe, please 
see http://www.palmos.com/dev/support/forums/


Re: one simple question about Delay funcation in Palm OS

2005-04-19 Thread Chris Tutty
From: Alan J. McFarlane [EMAIL PROTECTED]
  Of course in a application one would just sit at EvtGetEvent when
  waiting for an IrDA callback, but doing that in a shared library
  would be bad, no?
  --
Although I haven't followed this in detail, if you're looking for 
a way for a shared library to wait in background for an external
event one way to do this is to expose a function that the parent
app calls as part of their main event loop (with EvtGetEvent set
up for the event loop to cycle several times a second as required). 

This isn't perfect, and is subject to all sorts of uncertainty in that 
you're depending on the parent app to set up their event loop 
properly, but it serves the purpose of giving your library 
background time-slices.  I've done this for background serial 
processing for a shared library used by a family of applications,
but I wrote all of the apps that used the library so I had good 
control over both sides of the relationship.

Chris Tutty.

-- 
For information on using the Palm Developer Forums, or to unsubscribe, please 
see http://www.palmos.com/dev/support/forums/


Re: Flashing Palm Logo

2005-04-15 Thread Chris Tutty
From: Robert Moynihan [EMAIL PROTECTED]
 As soon as your app starts to process the reset launch code, as the 2nd 
 thing you do, set a flag in memory (I've used the prefs database before, 
 setting a small flag that says I'm handling a reset).  When you've 
 finished handling the reset launch, and the last thing you do before 
 returning, clear the flag.  The 1st thing you do when processing the 
 reset launch code is to check that flag.  If that flag is already set, 
 then it means that you did NOT complete the last reset properly, so it's 
 likely a crash happened, so DON'T do it again.  Just bail out and return 
 control to the user.  

Now that's the kind of excellent technique that's obvious once
someone's suggested it.

I'll just steal that idea and tuck it away in my things to add to my
default startup project pile.

Chris Tutty

-- 
For information on using the Palm Developer Forums, or to unsubscribe, please 
see http://www.palmos.com/dev/support/forums/


Re: external databases

2005-04-15 Thread Chris Tutty
From: sachin jesukaran [EMAIL PROTECTED]
  or if can i convert this *.mdb file to *.pdb file and
 access it if yes how do i convert a *.mdb file to a
 *.pdb file.
 
A google search for convert mdb pdb palm gives a long list 
of hits, the first page of which has some items that look useful.
I assume you've checked these out and they're not suitable.

Better still, there's searching this archive using
http://news.palmos.com/read/search.

Do you have some specific questions about the tools you've 
found in your research or are your requirements so unusual 
that the tools you've found won't work?

Chris Tutty

-- 
For information on using the Palm Developer Forums, or to unsubscribe, please 
see http://www.palmos.com/dev/support/forums/


Re: reading stored memory

2005-04-13 Thread Chris Tutty
From: Dr. Vesselin Bontchev [EMAIL PROTECTED]
 Instead, I suggest that on the form that does the scanning, you 
 listen to the nilEvent and scan only a single database when this 
 event occurs. This way you'll give up time to the OS do to other 
 things as well (e.g., alarms to trigger, clocks to be updated, etc.). 
(snip)
 If you don't realize how to implement what I described above, 
 ask me by private e-mail; it's easy but a bit long to type here. (I'm 
 using a rather awkward Web interface to access this forum.)
 
There are a number of discussions in the archive relating to background
processing that describe how to organise your event loop and avoid
hogging the device, many relating to serial comms handling, but
providing generic solutions.

Chris Tutty

-- 
For information on using the Palm Developer Forums, or to unsubscribe, please 
see http://www.palmos.com/dev/support/forums/


Re: C++ Save to Database, from field (codewarrior) problems

2005-04-12 Thread Chris Tutty
From: Andre Augusto [EMAIL PROTECTED]
 I have a function to get text from a field and another function to save 
 the text to a database. But when I call the InsertRecord() function, 
 the simulator craches (I also try the code in PDA, with same results.. 
 ). I can't guess what's the problem can anyone help?

If you're trying to catch a crash start by checking for
null pointers.  The InsertRecord() function uses a number
of pointers without checking them - the GetField result
that's passed to the stratoi, the recP result from the 
memhandlelock, the db value itself.

I'm also not sure about setting index to DmNumRecords 
to add a record at the end.  Although it's probably fine,
is there any reason you can't use dmMaxRecordIndex
as the documentation for DmNewRecord
suggests?

Chris Tutty

-- 
For information on using the Palm Developer Forums, or to unsubscribe, please 
see http://www.palmos.com/dev/support/forums/


Re: DmFindRecordByID API is Failing?? plz help

2005-04-06 Thread Chris Tutty
From: [EMAIL PROTECTED]
 Its getting proper value in typeID 
 It Display the Alert Message as follows
 
 Database:Unique ID not found(Dm 0218)
 
 I'm not sure I guess when the new PDB file is installed does its 
 recordID changes?? May be because of that. Is It?
 
This topic has been covered in the archives. From memory the 
uniqueid generation can be re-initialised by a hard-reset and
there are issues associated with restored databases.  You
might find that the uniqueid isn't suitable for the purpose you 
are using it, but the archive (found by following the auto-attached
link to the palmos dev forums page) has more detail on this.

Chris Tutty

-- 
For information on using the Palm Developer Forums, or to unsubscribe, please 
see http://www.palmos.com/dev/support/forums/


Re: memory

2005-04-05 Thread Chris Tutty
From: Orasanu Iuliana [EMAIL PROTECTED]
 i tryed to use what u told me.. but still when i debug to see what my
structer contains i can see only invalid pointer!!
 i'm using
 AppInfoType* foo = (AppInfoType *)MemPtrNew(sizeof(AppInfoType));
 MemSet(foo,sizeof(AppInfoType),0);
 Heeelllppp!

Do you mean before or after the 'foo =' line?  It will
almost certainly be invalid before that.  If it's still invalid
before the MemSet line (and since any memory allocation
can fail that should be *foo = ; if (foo) {MemSet} else
{error}) then perhaps your AppInfoType is larger than
64K, or the allocation is failing for some other reason.

Chris Tutty


-- 
For information on using the Palm Developer Forums, or to unsubscribe, please 
see http://www.palmos.com/dev/support/forums/


Re: pdb

2005-04-01 Thread Chris Tutty
From: Orasanu Iuliana [EMAIL PROTECTED]
 i have worked before with Appforge compiler in the VB
 programming language, and there was a convertor for .mdb files into .pdb
files
 so.. i have the ideea that the .pbd file have the same structure as
 the .mdb files..

Nope.  Just because one file format can be converted to another
says nothing about the similarity of their structure.  Pdbs are actually
almost completely free-form (and are really just indexed heaps).
The converter will have created a table and record structure of
it's own design within the pdb framework.

 but now i'm stuck in this problem: how can i create in CW a new
 data base...

In general you can create a C structure to store your records and then
copy this to and from the database record being edited or created.
For more information you should read the relevant sections in the
Palm OS Companion and Palm OS Reference and come back to
this group with specific questions.  Reading the source for a sample
such as MemoPad will also provide insight as to how the database
functions work in practice.

Chris Tutty


-- 
For information on using the Palm Developer Forums, or to unsubscribe, please 
see http://www.palmos.com/dev/support/forums/


Re: PDB file format

2005-03-31 Thread Chris Tutty
From: Dr. Vesselin Bontchev [EMAIL PROTECTED]
 I want to construct a PDB database on a PC, so I need to
 understand the file format of the PDB files.

At the risk of sounding negative, I disagree.  I'd prefer to see
I want to construct a PDB database on a PC, so I need to
know which of the many tools I should use.  My requirements
are  Many have been down this path and released source
that does this work.  While this sort of low-levl work can be
entertaining as an inteelectual exercise, it's really not that
productive.

As Ben said, there's par, there's also a COM tool called pdbc
(yes?) and a commercial COM tool called PDBGo, as well as
about a dozen other products I'm not familiar with.  They've all
been built by people who worked out these byte alignment
issues some time ago.

 OK, I understand that the PDB file has a 80-byte header:
(snip)
 What is supposed to follow is numRecords records, each having the
following structure:
(snip)
 Now, if I examine a real PDB file with a hex editor, the stuff after the
80-byte header looks like this:

 02 D0 40 F3 20 01 00 00
 02 F1 40 F3 20 02 00 00
 03 04 40 F3 20 03 00 00
 03 16 40 F3 20 04 00 00

 In fact, in the particular file I'm examining, the first part
 (02 D0) *can* be interpreted like that - indeed the first data
 record resides at offset 0x02D0 from the beginning of the file.
 But where does 40 F3 come from and what is its meaning?

Shrug.  If the first record starts at 0x02D0 then my bet is that
there's 00 00 before that 02 D0 and that the 40 F3 isn't part of
the offset but is the attributes / id pair (40 = dirty? suggesting that
this pdb is taken from a backup).  But I might be wrong, since
getting abyte or two off when deconstructing a binary format
can seriously mess up your interpretation.  Although I suspect
from your bio that I don't need to explain this to you.  :-)

Don't expect anything of value in the UniqueID field, it's only
significant on the device and can be zeros for created PDBs.

Chris Tutty


-- 
For information on using the Palm Developer Forums, or to unsubscribe, please 
see http://www.palmos.com/dev/support/forums/


Re: OS 5.x and the sysNotifyAppLaunchingEvent event

2005-03-27 Thread Chris Tutty
From: Dr. Vesselin Bontchev [EMAIL PROTECTED]
 OK, I have implemented interception of application launching in PalmOS 5.x
only, using the Notification Manager and registering to receive
notifications for the sysNotifyAppLaunchingEvent.

 My question is - is there an easy way of determining whether my
application has received this notification because some application is being
launched - or because some application is quitting? I'm interested only in
the launching events; not in the quitting ones.

 I could, I suppose, check whether the name of the launched application is
Launcher - but is there a more intelligent way to do it?

I tested for CRID == 'lnch', which is slightly better, but not really
an answer.  I think the problem is that, as you've realised, you're
not being notified of the app's quitting, you're being notified of the
launcher app starting up, which is exactly what that notification is
meant to tell you.  Of course most apps aren't interested in the launcher
launch, because it almost always follows an application exit but
Palm OS has to tell you so you have to check for it and ignore it.

Chris Tutty



-- 
For information on using the Palm Developer Forums, or to unsubscribe, please 
see http://www.palmos.com/dev/support/forums/


Re: OS 5.x and the sysNotifyAppLaunchingEvent event

2005-03-27 Thread Chris Tutty
From: Henk Jonas [EMAIL PROTECTED]
 Dr. Vesselin Bontchev wrote:
  I could, I suppose, check whether the name of the launched application
is Launcher - but is there a more intelligent way to do it?
 

 My opinion:
 If the CRID is the same who is registered for vchrLauncher(?) or the
 default launcher, then it's the launcher who gets called.

Now that's much better than my answer, I wasn't detecting custom
launchers at all  (scurries off to change his code).

Chris Tutty


-- 
For information on using the Palm Developer Forums, or to unsubscribe, please 
see http://www.palmos.com/dev/support/forums/


Re: No form event handler error at notification

2005-03-26 Thread Chris Tutty
From: Tam Hanna [EMAIL PROTECTED]
 I already tried out to modify the code, and it now looks like this:
 FormPtr myform;
 myform=FrmInitForm(SyncForm);
 FrmDrawForm(myform);
 FrmSetActiveForm(myform);
 FrmSetEventHandler(myform, HsFormHandleEvent);

Why have you chosen this sequence?  I ask because I would have
thought that FrmSetEventHandler() needed to be set before any
events could possibly arise.

The documentation for FrmSetActiveForm includes the
following: In Palm OS releases earlier than 3.5, this function 
generated a winEnterEvent for the new form immediately following 
the winExitEvent for the old form. Starting in Palm OS 3.5, 
FrmSetActiveForm does not generate the winEnterEvent. The 
winEnterEvent does not occur until the newly active form is drawn.

This suggests that either FrmDrawForm() or FrmSetActiveForm() are
capable of raising events and, in the sequence above, this will happen
before the event handler for the form is in place.  Or am I missing
something?

Chris Tutty

-- 
For information on using the Palm Developer Forums, or to unsubscribe, please 
see http://www.palmos.com/dev/support/forums/


Re: Dates prior to 1904

2005-03-25 Thread Chris Tutty
From: Clive Walden [EMAIL PROTECTED]
 Don't get me wrong. I can do the math if I have to. Just surprised I have
to roll my own for people
 still living today.

How many applications actually want to do date math on
people back to their DoB?  While many apps will record
different significant dates (birth, graduation, marriage, etc)
these are just recorded as fixed points in time.  It's rare
that an application will need to calculate, for example, how
many days a war veteran has lived.

After all, if we're talking about missing functions I would have
thought that not providing a function to parse floats in text
was more of a deficiency than no multi-century date math.

Chris Tutty


-- 
For information on using the Palm Developer Forums, or to unsubscribe, please 
see http://www.palmos.com/dev/support/forums/


Re: Dates prior to 1904

2005-03-25 Thread Chris Tutty
From: Clive Walden [EMAIL PROTECTED]
 Chris Tutty wrote:
  After all, if we're talking about missing functions I would have
  thought that not providing a function to parse floats in text
  was more of a deficiency than no multi-century date math.
 OKs

 I had no intention of starting one of those software religious war
flames.

Oops, there's that 'email has no body language' problem again,
I should have added a smiley, or a wink, or something to
indicate that I was just tossing loose opinion around.

Chris Tutty


-- 
For information on using the Palm Developer Forums, or to unsubscribe, please 
see http://www.palmos.com/dev/support/forums/


Re: How to intercept application launching?

2005-03-23 Thread Chris Tutty
From: Vesselin Bontchev [EMAIL PROTECTED]
 From: Chris Tutty
  The real problem is that HackMaster was created because
  the trap redirection can cause the device to become unstable
  if multiple apps try to hook into the same trap - I can't

 OK, I have researched the issue and here is what I've found.

(Snip of excellent description of the hack removal problem).
Install first...
 First-Original
Install second...
 Second-First-Original
Remove first...
 Second-[never-never-land]-Original

Yup, that's it exactly.

 Third-party hack managers aside, I see only three possible solutions:

I'm not sure how you detect that another app has patched a trap - do
you intend to search the memory of all apps for a stored value that
equals the address of your own routine?  However, if you can do this
reliably it's a step forwards.

 3) By intercepting SysSetTrapAddress, the application can detect if
 some other application is trying to intercept one of the system traps it
 has intercepted. When this happens, it can disable itself by restoring
 the original system trap address, effectively removing itself from the
chain.

I like this because it provides good information to the user.  My only
concern
would be that hackmaster programs are likely to hook the same trap so
you'll still have to be able to reliably detect and manage multiple patches
on the same trap.

Chris Tutty


-- 
For information on using the Palm Developer Forums, or to unsubscribe, please 
see http://www.palmos.com/dev/support/forums/


Re: How to intercept application launching?

2005-03-23 Thread Chris Tutty

- Original Message - 
From: Vesselin Bontchev [EMAIL PROTECTED]
To: Palm Developer Forum palm-dev-forum@news.palmos.com
Sent: Thursday, March 24, 2005 4:03 AM
Subject: Re: How to intercept application launching?


  The real problem is that HackMaster was created because
  the trap redirection can cause the device to become unstable
  if multiple apps try to hook into the same trap - I can't
  remember if the instability occurs immediately or if the problem
  is related to removing your hack. Anyway. If you're going to
  do this it's very important that you also implement logic to
  search for third party hack managers and refuse to run if one
  is installed (because you're messing with the same infrastructure
  they are). You will also need to give a loud warning to the user
  that your hack cannot be used in conjunction with any other
  hack. Annoying, but it's the only option - one hack per device
  or only use HackMaster compatible apps.

 OK, I have researched the issue and here is what I've found.

 Intercepting system traps in PalmOS is pretty much like intercepting
interrupts with a TSR program in MS-DOS (yes, I am old enough to have done
that). The problem occurs when your program is uninstalled after a program
(installed after yours) has intercepted the same thing. Here is what
happens.

 Normally, when you call a system trap, the call goes to the original code
in PalmOS, thought a table containing the addresses of the various traps.

 When your application, let's call it First, intercepts that system trap
and an application calls it, the call goes like this:

 First-Original

 That's because at installation time your application obtained the address
of the original call, saved it somewhere and replaced it with its own
address. This way when an application calls this system trap, your program
receives control. It does its thing and chains to the original system trap
by calling the address it has saved.

 Now, suppose that a second application (imaginatively named Second) is
installed and that it intercepts the same system trap using the same method.
Then, when an application calls this system trap, the call goes like this:

 Second-First-Original

 So far, so good. If, at this point, the user uninstalls the Second
application, everything will be fine (provided that the application
remembers to restore the address of the system trap it has intercepted). The
problem will occur if the user removes the *First* application while the
Second one is still present and active. The First application knows where
the original address of the system trap is, and it can even determine that
somebody after it has intercepted the same system trap (by intercepting
SysSetTrapAddress) - but it has no way of knowing where that somebody has
saved the address of the system trap at installation time. So, if at this
point the Frist application is removed, we get

 Second-[never-never-land]-Original

 In other words, the chain breaks. As soon as some application calls the
intercepted system trap, the Second application will receive control. It
will do its thing and chain to what it thinks was the original address -
except that now it points to a place that doesn't contain the program it
used to contain.

 Now, in MS-DOS, TSR programs usually did not try to uninstall themselves.
Even those that did, usually left a small stub in memory that did the
interrupt vector chaining. Unfortunately, that's not an option under
PalmOS - there, if you delete an application with the memory manager, it is
gone; all of it.

 Third-party hack managers aside, I see only three possible solutions:

 1) An application can refuse to uninstall itself, if it detects that
another application has intercepted the same system traps it has
intercepted - that's relatively easy to implement. However, this will
frustrate the user a lot, given that s/he probably won't know what these
other applications are, in order to remove them.

 2) When uninstalling itself, an application could disable all other
applications that have intercepted the same system trap after it.
Unfortunately, it has no way of knowing where exactly they remember that
they are intercepting something, so they will still think (i.e., tell the
user) that they are active - but will, in fact, be disabled.

 3) By intercepting SysSetTrapAddress, the application can detect if some
other application is trying to intercept one of the system traps it has
intercepted. When this happens, it can disable itself by restoring the
original system trap address, effectively removing itself from the chain.

 Neither of these solutions is good enough, but at least they avoid the
crashing problems that would otherwise occur.

 Regards,
 Vesselin
 -- 
 For information on using the Palm Developer Forums, or to unsubscribe,
please see http://www.palmos.com/dev/support/forums/


-- 
For information on using the Palm Developer Forums, or to unsubscribe, please 
see http://www.palmos.com/dev/support/forums/

Re: How to intercept application launching?

2005-03-23 Thread Chris Tutty
(My apologies for the double post - OE obviously has problems with
multiple messages open for posting).

From: Vesselin Bontchev [EMAIL PROTECTED]
   From: Chris Tutty
   From memory you create a code segment, attach it to your app
   as a resource (Ben's answer to my question on how to do this
   should be in the archive), load and lock it and then redirect the
   trap through that code segment.
  
   Ugh. Why is that necessary? Can't you just use SysSetTrapAddress
   to intercept trap 0xA0A7 (sysTrapsysUIAppSwitch) with a function
   in your normal code segment?

 Hmmm... I just found an application that pretty much does what I want
 (except that it intercepts only application launching and I want to
intercept
 other things too) - and, from looking at the disassembly, it doesn't seem
 to be doing such stuff.

What's it called?  It might be the app I wrote  :-)  Alternatively it's a
competing app.  They both, of course, use the same underlying mechanisms.

 Yup, it checks the OS version and registers a notification under PalmOS
5.x. Under the lower versions it just uses SysSetTrapAddress to point trap
0xA0A7 to a subroutine in its code segment. It also uses FtrSet to remember
that it is intercepting something (because the interception can be turned
off). But it doesn't have additional code segments or anything like that...
In order to make sure that its code segment doesn't disappear, it locates it
(CurAppDatabase, DmOpenDatabase, DmGetResource) and locks it (MemHandleLock)
and protects the database where it resides (DmDatabaseProtect).

Sounds more like a different app.  I didn't want to keep the whole
app in memory so I built a code segment that just does the background
stuff and left that behind when the rest of the app unloaded.  Probably
doesn't matter in the modern devices, but people used to get serious
about a few bytes wasted in the old devices.

  If you were willing to release a code sample that
  implements the hackmaster-independent mechanism as open source
  I'd be happy to contribute some of my existing code to it. I just
  don't have the time to turn that code into a sample and document
  it.

 Unfortunately, the nature of the application I'm developing is such
 that it simply cannot be released as open source
(snip)
 Furthermore, I'm a bit opposed to the concept of the GNU license
 myself. I mean, if I release something like that, it would mean that
anyone
 who uses any part of it in their application, has to release that
application
 as open source too - and I find such a restriction unacceptable.

I agree, as licenses go that sort of virus just forces people to reinvent
the same mechanism.  Not to mention that Ive seen more confusion about
what the the GPL does and does not allow than any other license.  I've
also seen directly conflicting answers to the same question.  If you're
going to give something away then you give it away - the coercion associated
with the GPL has just confused it's use to the point where it becomes a
hindrance rather than an assistance.  I've worked in projects where the
managers issued a blanket ban on using any tool with a GPL license in
it, in spite of the fact that we weren't in violation of the license, simply
out of FUD.

 However, I am perfectly willing to develop a sample demonsrating how
 to intercept things (i.e., not the actual application I'm writing) and
release
 its source in the public domain (i.e., anyone is allowed to use it in any
 way they want).

Now THAT's what I think Palm OS needs more of.  There are a set of
quite complex subjects (accessing the addressbook is another) that
aren't well documented and for which the original PIM app source
code is just confusing.  I've been trying to put together some sample
source code for a while now but just don't have the time.

I'll mail you off-list on this, as I need to investigate the extent to which
I'm limited by an NDA on my original Palm OS 5 work in regards to
my giving away my Palm OS 4 work.

Chris Tutty


-- 
For information on using the Palm Developer Forums, or to unsubscribe, please 
see http://www.palmos.com/dev/support/forums/


Re: DmOpenRef error

2005-03-22 Thread Chris Tutty
From: ULStudent:Robert.Conlon [EMAIL PROTECTED]
 I no longer get the DmOpenRef error but the second database 
 with DmOpenRef declaration db2 still wont create. 

We need more detail on the problem to coment 'wont create'
is just too vague.  Do you get an error? if so, what error? If
you remove the first create does the second start working?
Have you checked that the DBName is different?  How do you
know that it doesn't exist?  Databases and prcs with the same 
CRID are often reported as a lump in the Palm OS info screens
so you need to use an app such as Filez if you want more info.

Chris Tutty



-- 
For information on using the Palm Developer Forums, or to unsubscribe, please 
see http://www.palmos.com/dev/support/forums/


Re: App launch and SysAppLaunch() function.

2005-03-22 Thread Chris Tutty
From: Fred Zheng [EMAIL PROTECTED]
 Q2. SysUIAppSwitch() works well. But sometimes I need to have the
control
 return to the calling application when finished. So I tries
 SysAppLaunch(). This is not that pleasant. it always collapses.

You are better to stick with SysUIAppSwitch() and return to
the calling app by sending a signal of some sort when you launch
it.  The calling app would identify that it has to return control and
would use SysUIAppSwitch() when it's finished.

There are a variety of ways to send the signal - you could set a
feature or set a value in a shared preference block - but what
worked well for me in a similar situation was to define
custom launch codes.  You then use one of these instead of
sysAppLaunchCmdNormalLaunch when calling
SysUIAppSwitch().  Your app uses the same logic as for a
normal launch, but takes note of anything special it should do
when it's finished (one launch code might be appLaunchReturnToApp1,
for instance).  Alternatively you can use one custom launch code
and pass a command block to the app with the special info in it.

The programmer's companion has several sections that discuss
this and SysUIAppSwitch() also includes some notes.

Chris Tutty


-- 
For information on using the Palm Developer Forums, or to unsubscribe, please 
see http://www.palmos.com/dev/support/forums/


Re: How to intercept application launching?

2005-03-21 Thread Chris Tutty
From: Vesselin Bontchev [EMAIL PROTECTED]
 And, of course, I'll have to figure out what to do under PalmOS 
 lower than 5.0. I guess, I'll have to write a hack (snip)
 I don't want my application to depend on the presense of a 
 third-party hack manager... 
 
Did that too.  In fact, since the client decided that they didn't
want Palm OS 4 support I'd be quite happy to sell you the
implementation pre-written  :-).  I get the impression you're
writing this yourself and so that probably isn't an option but
if it is let me know.

You're correct about the hack - the basic theory is documented 
(partly) and from memory I worked from a test app (DemoHack) 
which uses HackMaster support.  This provided a start while I 
worked out how to implement the hack without HackMaster.  
From memory you create a code segment, attach it to your app 
as a resource (Ben's answer to my question on how to do this 
should be in the archive), load and lock it and then redirect the 
trap through that code segment.

The real problem is that HackMaster was created because
the trap redirection can cause the device to become unstable
if multiple apps try to hook into the same trap - I can't 
remember if the instability occurs immediately or if the problem
is related to removing your hack.  Anyway.  If you're going to
do this it's very important that you also implement logic to 
search for third party hack managers and refuse to run if one 
is installed (because you're messing with the same infrastructure
they are).  You will also need to give a loud warning to the user
that your hack cannot be used in conjunction with any other
hack.  Annoying, but it's the only option - one hack per device 
or only use HackMaster compatible apps.

Chris Tutty


-- 
For information on using the Palm Developer Forums, or to unsubscribe, please 
see http://www.palmos.com/dev/support/forums/


Re: How to intercept application launching?

2005-03-21 Thread Chris Tutty
From: Vesselin Bontchev [EMAIL PROTECTED]
  In fact, since the client decided that they didn't
  want Palm OS 4 support I'd be quite happy to sell you the
  implementation pre-written :-). 
 
 Thanks for the offer but I am writing it myself and I'd like to support 
 as lower an OS version as possible. 

I think below 5.0 the same implementation should work down to 
3.5, possibly 3.0.  The trap mechanism is a fairly fundamental part 
of pre-OS5 Palm OS, as far as I'm aware so it's more of a testing
issue than anything else.

 I also want to intercept the fact that an application has just been 
 beamed to the device, that a HotSync operation has completed, 
 ... 
For all of these it's a matter of identifying an OS function that will
interact at the appropriate point in the process and then hook 
your code into that sequence.

  From memory you create a code segment, attach it to your app
  as a resource (Ben's answer to my question on how to do this
  should be in the archive), load and lock it and then redirect the
  trap through that code segment.
 
 Ugh. Why is that necessary? Can't you just use SysSetTrapAddress 
 to intercept trap 0xA0A7 (sysTrapsysUIAppSwitch) with a function 
 in your normal code segment?
 
Because (working from what I remember) your normal code segment 
will be unloaded when your app exits.  You need a chunk of code to 
sit around disconnected from the normal Palm OS app startup and
shutdown.  It's not as big a deal as it sounds, certainly not much more
complicated than the step from single-segment to multi-segment apps.
The only reason it took me a couple of days of frustration is that I'd
assumed I knew how the linking process worked and couldn't build
the app the way I expected.  Once I switched my brain off and 
followed Ben's instructions step by step it just worked.  :-)

  The real problem is that HackMaster was created because
  the trap redirection can cause the device to become unstable
  if multiple apps try to hook into the same trap - I can't
  remember if the instability occurs immediately or if the problem
  is related to removing your hack.
 
 Oh, I don't mind if my application is HackMaster-compatible. What 
 I want to avoid, though, is making it HackMaster-dependent. 

It's possible, but a bit more work.  You have to implement the 
connection points and resource id rules that the hack management
(sorry, System Extension management) apps follow, but you also
have to implement the low-level stuff yourself the hard way.  You
then have to warn the user that using your hack in conjunction with
any other hack without a hack manager will cause unpredictable
crashes.

It's certainly an approach that I think is reasonable - I've had clients
ask for the same non-dependency and I'd like to see it better 
documented.  If you were willing to release a code sample that
implements the hackmaster-independent mechanism as open source
I'd be happy to contribute some of my existing code to it.  I just
don't have the time to turn that code into a sample and document it.

Chris Tutty

-- 
For information on using the Palm Developer Forums, or to unsubscribe, please 
see http://www.palmos.com/dev/support/forums/


Re: Very Urgent (Please respond by the end of today, my job depends on it :)

2005-03-20 Thread Chris Tutty
From: Jamie McMullin [EMAIL PROTECTED]
 2) The database I was given to do this project with IS packed. Although
I'm not sure the format or how to unpack it. It would seem that /30 would
delimete each record.

 The method I've seen is:

 char *s = PackedRecord-key;
 UnpackedRecord-prodno = s;
 s += StrLen(s) + 1;
 Why this makes no sense at all is that PackedRecord-Key equals something
like:

 '2938012/30AUTO_ADD/30100.20/30' etc.

 So I don't see how the above method of unpacking will turn that
 long concatenated string into a bunch of indivdual, accurately
 un-delimeted records.

It won't.  That logic is intended for records that are packed with
each string null-terminated, ie terminated by a character zero.
You can then use StrLen to find the number of characters up to
the next null-terminator.  You can still use this logic, but you
would have to write a function to count the number of characters
from the pointer to the next /30 and then use that instead of StrLen.

All that pack really means is that instead of storing strings padded
with spaces to a constant length
as in
'2938012 AUTO_ADD   100.20 '
'2938013SOME OTHER DATA100.20 '
'2938013THREE  100.20 '
they're terminated and the next field immediately follows them,
as in
'2938012\0AUTO_ADD\0100.20\0'
'2938013\0SOME OTHER DATA\0100.20\0'
'2938013\0THREE\0100.20\0'
etc.

The main advantage to packing is that you don't waste space
padding strings out to the same length, the disadvantage is that
you can't just dump the record into a C struct and access it
immediately - you've got to copy the fields item by item into
the structure you want to use.

Part of your problem would seem to be the way this database
was created, particularly since numeric data seems to have been
turned into strings and might need to be converted back into
numbers before you can calculate with it.  On the other hand
if you're just displaying these values it doesn't matter.

Chris Tutty


-- 
For information on using the Palm Developer Forums, or to unsubscribe, please 
see http://www.palmos.com/dev/support/forums/


Re: Very Urgent (Please respond by the end of today, my job depends on it :)

2005-03-20 Thread Chris Tutty
To be correct, this needs changing from:
From: Chris Tutty [EMAIL PROTECTED]
 All that pack really means is that instead of storing strings padded
 with spaces to a constant length
 as in
 '2938012 AUTO_ADD   100.20 '
 '2938013SOME OTHER DATA100.20 '
 '2938013THREE  100.20 '

to 
 All that pack really means is that instead of storing strings padded
 with spaces to a constant length
 as in
 '2938012 AUTO_ADD\0   100.20 '
 '2938013SOME OTHER DATA\0100.20 '
 '2938013THREE\0  100.20 '

so that the strings are properly null-terminated when copied into 
a C struct.  And they probably wouldn't be space-padded - might
be null-padding, might be whatever crap followed the null terminator
in the original edit buffer.

Chris Tutty

-- 
For information on using the Palm Developer Forums, or to unsubscribe, please 
see http://www.palmos.com/dev/support/forums/


  1   2   3   4   5   6   >