RE: LstSetListChoices()
h... I think what it means is this : The list automaticly free's the old array storage (so you dont have to), and then uses the new array for the list contents. So it doesnt make a copy!.. correct me if i'm wrong :) Jimmy -Original Message- From: Magnus Drougge [mailto:[EMAIL PROTECTED]] Sent: 16. marts 2000 12:03 To: Palm Developer Forum Subject: LstSetListChoices() Hi! Does anyone know if the LstSetListChoices() method makes a copy of the array of strings it's fed with? I other words, can I safely free the memory used to build the array prior to a call to this method? According to the SDK reference the old entries are erased and that statement makes me believe that it _does_ make a copy but I'm not certain... /Drougge == Magnus Drougge Wireless Independent Provider AB +46-455-389809, +46-708-319109 == -- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palm.com/devzone/mailinglists.html -- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palm.com/devzone/mailinglists.html
Re: LstSetListChoices()
No. if you change the array its list will be changed too. > Hi! > > Does anyone know if the LstSetListChoices() method makes a copy of the array > of strings it's fed with? I other words, can I safely free the memory used > to build the array prior to a call to this method? > > According to the SDK reference the old entries are erased and that statement > makes me believe that it _does_ make a copy but I'm not certain... > > /Drougge > == > Magnus Drougge >Wireless Independent Provider AB > +46-455-389809, +46-708-319109 > == > > -- > For information on using the Palm Developer Forums, or to unsubscribe, please see >http://www.palm.com/devzone/mailinglists.html -- = | ___ | | / \ Campanha contra e-mail com HTML | | \ / FITA ASCII | | \ / | | X ASCII RIBBON| | / \ Against HTML e-mail | | / \ | = -- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palm.com/devzone/mailinglists.html
Re: LstSetListChoices()
>Does anyone know if the LstSetListChoices() method makes a copy of the array >of strings it's fed with? In the 3.0 source code, it doesn't make a copy, as least as far as I can tell from a quick scan. Regards, Steve Mann --- Creative Digital Publishing Inc. 1315 Palm Street, San Luis Obispo, CA 93401-3117 --- 805.784.9461 805.784.9462 (fax) [EMAIL PROTECTED] http://www.cdpubs.com -- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palm.com/devzone/mailinglists.html
Re: LstSetListChoices()
You cannot frre the array until the list is being used. Even when you have done "LstSetListChoices" and drawn the list, you cannot free it coz you'll need the list for Selection ie whenever you select an item in the list. You need to free it when you are finished with your with the list, or, if u need to populate the array again, then fee it at that time. Steve Mann <[EMAIL PROTECTED]> on 03/16/2000 10:01:20 PM Please respond to "Palm Developer Forum" <[EMAIL PROTECTED]> To: "Palm Developer Forum" <[EMAIL PROTECTED]> cc: (bcc: Malik Sumita-SWD-ITIL-UB/Itilmail) Subject: Re: LstSetListChoices() >Does anyone know if the LstSetListChoices() method makes a copy of the array >of strings it's fed with? In the 3.0 source code, it doesn't make a copy, as least as far as I can tell from a quick scan. Regards, Steve Mann --- Creative Digital Publishing Inc. 1315 Palm Street, San Luis Obispo, CA 93401-3117 --- 805.784.9461 805.784.9462 (fax) [EMAIL PROTECTED] http://www.cdpubs.com -- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palm.com/devzone/mailinglists.html -- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palm.com/devzone/mailinglists.html
Re: LstSetListChoices
I have strings separates with chr(9) in a record and this works fine: static Boolean CreaEtiquetasList (void) { ListPtrlst; CharPtrselectionText; UInttextLen,i; CharPtrchoicesEtiquetasP; VoidHand choicesEtiquetasH; VoidHandchoicesEtiquetasPtrsHandle; UInt numEtiquetas = 0; if (!(PedidosLineasDBCurrentArticulo.Etiquetas)) return false; textLen = StrLen(PedidosLineasDBCurrentArticulo.Etiquetas); choicesEtiquetasH = MemHandleNew(textLen+1); if (choicesEtiquetasH!=NULL) { choicesEtiquetasP = MemHandleLock(choicesEtiquetasH); for (i = 0; i < textLen; i++) { if (PedidosLineasDBCurrentArticulo.Etiquetas[i] == 9) { choicesEtiquetasP[i] = '\0'; numEtiquetas++; } else choicesEtiquetasP[i] = PedidosLineasDBCurrentArticulo.Etiquetas[i]; } choicesEtiquetasP[textLen++] = 0; numEtiquetas++; choicesEtiquetasPtrsHandle = SysFormPointerArrayToStrings(choicesEtiquetasP, numEtiquetas); lst = GetObjectPtr (PedidosDetalleEtiquetasList); LstSetListChoices(lst, MemHandleLock(choicesEtiquetasPtrsHandle), numEtiquetas); } return true; } Amadeu > De: "Rob Graber" <[EMAIL PROTECTED]> > Responder a: "Palm Developer Forum" <[EMAIL PROTECTED]> > Fecha: Wed, 26 Apr 2000 09:34:32 -0500 > Para: "Palm Developer Forum" <[EMAIL PROTECTED]> > Asunto: LstSetListChoices > > Here is the deal. I have a database with a record containing a bunch of > NULL-terminated strings. Some of the strings are valid for inclusion in my > listbox, others are not. I want to write some code that will do the > following. > > while (still more strings) { > determine if the string is valid(I can handle that part myself) > if (valid) { > write a pointer value to the > beginning of the string to the end of > a record in the database (essentially > create a record that is an array of > character pointers) > } > next string > } > > //now that there is a record containing an array of character pointers.. > LstSetListChoices(listP, itemsText, numStrings); > > My problem is that I can't seem to figure out the declarations/syntax to set > and pass the itemsText variable. Any ideas? Anyone already done something > similar they can share? > > I am attaching the SDK ref for LstSetListChoices for convenience. > > Very truly yours, > > Rob G. > > > Prototype void LstSetListChoices (ListPtr ListP, > char ** itemsText, UInt numItems) > Parameters ListP Pointer to a list object. > itemsText Pointer to an array of text strings. > numItems Number of choices in the list. > Result Returns nothing. > > > -- > For information on using the Palm Developer Forums, or to unsubscribe, please > see http://www.palm.com/devzone/mailinglists.html > -- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palm.com/devzone/mailinglists.html
RE: LstSetListChoices
Hello Rob, I have a similar situation and basically iterate through a database and grep strings. Here is an example - for string char(9): VoidHand LstH = MemHandleNew(1); VoidHand H; Char *tmp; int i, k = 0; while (still more strings) { determine if the string is valid(I can handle that part myself) if (valid) { k ++; if (MemHandleResize(lstH,10 * k) == 0) { //if can be resize, add the next string tmp = MemHandleLock(lstH); for (i = 1; i < k; i++) tmp += StrLen(tmp) + 1; StrNCat(tmp, value, 10);//value = value from database MemHandleUnlock(lstH); } else { //if cannot resize, just dump out what you got k--; break; } //if next string } H = SysFormPointerArrayToString(MemHandleLock(lstH),k); MemHandleUnlock(lstH); LstSetListChoices(LstPtr, MemHandleLock(H), k); MemHandleUnlock(H); Hopes this helps. Eric Sun Developer - RAD systems Q. Data Inc. 4/26/00 11:31 AM -Original Message- From: Rob Graber [SMTP:[EMAIL PROTECTED]] Sent: Wednesday, April 26, 2000 10:35 AM To: Palm Developer Forum Subject:LstSetListChoices Here is the deal. I have a database with a record containing a bunch of NULL-terminated strings. Some of the strings are valid for inclusion in my listbox, others are not. I want to write some code that will do the following. while (still more strings) { determine if the string is valid(I can handle that part myself) if (valid) { write a pointer value to the beginning of the string to the end of a record in the database (essentially create a record that is an array of character pointers) } next string } //now that there is a record containing an array of character pointers.. LstSetListChoices(listP, itemsText, numStrings); My problem is that I can't seem to figure out the declarations/syntax to set and pass the itemsText variable. Any ideas? Anyone already done something similar they can share? I am attaching the SDK ref for LstSetListChoices for convenience. Very truly yours, Rob G. Prototype void LstSetListChoices (ListPtr ListP, char ** itemsText, UInt numItems) Parameters ListP Pointer to a list object. itemsText Pointer to an array of text strings. numItems Number of choices in the list. Result Returns nothing. -- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palm.com/devzone/mailinglists.html -- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palm.com/devzone/mailinglists.html
Re: LstSetListChoices
>My >question is how can I define the first item to display? LstSetTopItem. Regards, Steve Mann -- --- Creative Digital Publishing Inc. 1315 Palm Street, San Luis Obispo, CA 93401-3117 --- 805.784.9461 805.784.9462 (fax) [EMAIL PROTECTED] http://www.cdpubs.com -- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/tech/support/forums/
Re: LstSetListChoices
>I'm getting a fatal error "MemoryMgr.c, Line 4342, NULL handle" when >running an application on the palm, I think the error comes from the >following code: Why not use the symbolic debugger and POSE to find out _exactly_ where the error occurs. It's much easier to track down problems that way. Regards, Steve Mann -- --- Creative Digital Publishing Inc. 1315 Palm Street, San Luis Obispo, CA 93401-3117 --- 805.784.9461 805.784.9462 (fax) [EMAIL PROTECTED] http://www.cdpubs.com -- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/tech/support/forums/
Re: LstSetListChoices
I'd recommend putting an error check after your "DmGetResource". Also ... CharPtr unlock=(CharPtr)MemHandleLock(gStringArrayH); looks like it should be CharPtr unlock=(CharPtr)MemHandleLock(theListItems); Or ... theListItems = (Handle) SysFormPointerArrayToStrings( theRecPtr, theListCount ); should be gStringArrayH = (Handle) SysFormPointerArrayToStrings( theRecPtr, theListCount ); The rest of the code looks correct. "Nancy Kho" <[EMAIL PROTECTED]> wrote in message news:52183@palm-dev-forum... > > I'm getting a fatal error "MemoryMgr.c, Line 4342, NULL handle" when > running an application on the palm, I think the error comes from the > following code: > > I'm basically just trying to take a list of strings & displaying it in > a List object. > > VoidPtr theListPtr; > Handle theListItems; > DWord theListCount; > VoidHand theRecHand; > char* theRecPtr; > > theRecHand = DmGetResource( 'tSTL', abbrevStringList ); > theRecPtr = (char*) MemHandleLock( theRecHand ); > theRecPtr += StrLen(theRecPtr)+1; > theListCount = (theRecPtr[0] << 8) + theRecPtr[1]; > theRecPtr += sizeof( SWord ); > theListItems = (Handle) SysFormPointerArrayToStrings( theRecPtr, > theListCount ); > theListPtr = MemHandleLock( theListItems ); > ListPtr list = (ListPtr) FrmGetObjectPtr(frm, > FrmGetObjectIndex(frm, PartTwoAbility1List)); > CharPtr unlock=(CharPtr)MemHandleLock(gStringArrayH); > LstSetListChoices(list, &unlock, theListCount); > > does someone have an idea where my error is? > > thanks, > [EMAIL PROTECTED] > > -- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/tech/support/forums/
Re: LstSetListChoices
From: "Karen M Serafino" <[EMAIL PROTECTED]> Subject: LstSetListChoices > Does anyone have a WORKING example or explanation of how to set the items > of a list to string values read from a database? I do not have a > stringtable resource with the items all set up; I need to read them from > a database. I set up a packed string of null-terminated strings and > called SysFormPointerArrayToStrings to create the array of pointers to > pass to LstSetListChoices, but it just blanks out the old items in the > list and leaves it empty after I draw the form again.. Thank you. Sounds like you might not have properly set up the packed string. One thing to keep in mind is that the packed string you pass in and the MemHandle that SysFormPointerArrayToStrings returns both have to exist as long as the list exists for this to work. -- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/tech/support/forums/
Re: LstSetListChoices
Actually, the list is not displaying correctly, although declaring the list globally did solve a big problem. When you tap the popup trigger, it will display the first item with a little down-arrow to the right of it, but none of the other items. Then if I select this item, it will put it in the popup trigger text, but with the popup symbol (solid triangle) to the left of it versus to the right. A call to LstGetNumberOfItems returns the correct number, but they are not all getting displayed. When there is only 1 item in the list, it does not have the down-arrow, but after I select the item, it still puts the popup symbol to the left of it versus to the right. Also, do you know how to explicitly change the popup trigger text to match the top item of what you have just put in the list? The resource file was compiled using the PilRC plugin, and the original list text items and popup trigger text were set up explicitly in a .RCP file. Thanks. Karen Serafino On Sun, 22 Oct 2000 14:14:13 -0500 "Richard Burmeister" <[EMAIL PROTECTED]> writes: > From: "Karen M Serafino" <[EMAIL PROTECTED]> > Subject: LstSetListChoices > > > > Does anyone have a WORKING example or explanation of how to set > the items > > of a list to string values read from a database? I do not have a > > stringtable resource with the items all set up; I need to read > them from > > a database. I set up a packed string of null-terminated strings > and > > called SysFormPointerArrayToStrings to create the array of > pointers to > > pass to LstSetListChoices, but it just blanks out the old items in > the > > list and leaves it empty after I draw the form again.. Thank you. > > Sounds like you might not have properly set up the packed string. > One thing > to keep in mind is that the packed string you pass in and the > MemHandle that > SysFormPointerArrayToStrings returns both have to exist as long as > the list > exists for this to work. > > > > -- > For information on using the Palm Developer Forums, or to > unsubscribe, please see > http://www.palmos.com/dev/tech/support/forums/ -- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/tech/support/forums/
Re: LstSetListChoices
From: "Karen M Serafino" <[EMAIL PROTECTED]> Subject: Re: LstSetListChoices > ..., but with the popup symbol (solid triangle) > to the left of it versus to the right. If you position the list too far to the right, the OS will put the popup arrow to the left. Try moving the list left about 8 pixels. > Also, do you know how to explicitly change the > popup trigger text to match the top item of what you have > just put in the list? Use CtlSetLabel(). See http://www.egroups.com/message/palm-dev-forum/36217 for sample code. > The resource file was compiled using the PilRC plugin, and > the original list text items and popup trigger text were set up > explicitly in a .RCP file. Thanks. When you say "the original list text items..." this implies that you change them dynamically. Why set up the list choices at design time with Pilrc if you are going to change them dynamically? -- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/tech/support/forums/
RE: LstSetListChoices
> From: Karen M Serafino [mailto:[EMAIL PROTECTED]] > When you tap the popup trigger, it will display the first item with > a little down-arrow to the right of it, but none of the other items. OK, when you dynamically populate a popup list, you should always call LstSetHeight to make it display as many items as possible. Just pass the total item count to LstSetHeight (even if it is more than will actually fit on the screen). > Then if I select this item, it will put it in the popup trigger text, > but with the popup symbol (solid triangle) to the left of it That's correct. The arrow you see on the right side of the popped up list is the scroll arrow, since there are more items than are visible. Then the triangle on the left side of the trigger is the standard style of all popup triggers. > When there is only 1 item in the list, it does not have the > down-arrow, but after I select the item, it still puts the popup > symbol to the left of it versus to the right. Right. If only one item, then there is no scroll arrow. -slj- -- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/tech/support/forums/
RE: LstSetListChoices
> From: Karen M Serafino [mailto:[EMAIL PROTECTED]] > I do not have a stringtable resource with the items all set up; > I need to read them from a database. I set up a packed string > of null-terminated strings and called SysFormPointerArrayToStrings Consider a different technique: don't create a list of strings and pointers at all, but use LstSetDrawFunction and a custom draw function that draws each item by reading it directly from your database. If there is a 1-to-1 correspondence between rows in the list and records in the database, this should be fairly straightforward. This technique is usually more memory-efficient since you don't create copies of any data that already resides in database records. -slj- -- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/tech/support/forums/
Re: LstSetListChoices
Am Don, 2002-07-25 um 22.53 schrieb Steve Mann: Hi, > >My question: is it legal to pass a null pointer to LstSetListChoices > > Yes, in the 2nd parameter. Of course :) > >and/or what might be other reasons for this behaviour? > > CtlnewControl may invalidate any previous form pointers you have. > Make sure you update any form pointers you are using by calling > FrmGetFormPtr. I do this. Furthermore, the error occurs WITHIN the first call to CtlNewControl, anyway. It really looks like this: fillList(...) <--- see previous mail LstSetSelection(...) setTrigger(...) <--- changes the popup trigger FrmDrawForm(...) CtlNewControl <--- error happens here If I remove LstSetListChoices from the fillList routine, the error is gone. If I pass a nonsense pointer to it, the error is gone as well. Note that this only happens on PalmOS 3.5. On 4.x there is no problem at all. Idea: I read of a bug in 3.5 when using CtlNewControl is (unsuccessfully) trying to adapt every ptr in a dynamically created form. Might it be that on 3.5 the CtlNewControl goes through all other form elements that already exist in the form and does something with 'em? Daniel -- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/
Re: LstSetListChoices
>Idea: I read of a bug in 3.5 when using CtlNewControl is >(unsuccessfully) trying to adapt every ptr in a dynamically created >form. Might it be that on 3.5 the CtlNewControl goes through all other >form elements that already exist in the form and does something with >'em? There were problems with dynamic form elements in 3.5 and earlier. They were kind of delicate. That would be my guess as to the problem. Do you need to be able to run on 3.5? Regards, Steve Mann -- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/
Re: LstSetListChoices
Am Fre, 2002-07-26 um 07.54 schrieb Steve Mann: Hi, > There were problems with dynamic form elements in 3.5 and earlier. > They were kind of delicate. That would be my guess as to the problem. > Do you need to be able to run on 3.5? Definitely yes. The OS 3.5 fraction is just too big to ignore them. I think I can solve the issue by swapping the lines of code - first using CtlNewControl and afterwards filling in the list. That way CtlNewControl only finds a static form with no modifications by me. With kind regards, Daniel Seifert -- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/
Re: LstSetListChoices
On Thu, 7 Aug 2003 23:46:16 -0700, "Steve K" <[EMAIL PROTECTED]> wrote: > >I have read many a posts on this question, however, none seem to be working >for me. I have attempted to simplify this with no results. I am no longer >getting fatal exceptions, however nothing is happening. > >What is the key ingredient i'm missing here? >static char* gPlateString = >"PL3/16x\0PL1/4x\0PL5/16x\0PL3/8x\0PL1/2x\0PL5/8x\0"; The above doesn't work. The compiler knows that dquote strings end with \0 so there is nothing in the .o image after PL3/16x. If you want to do it that way: static char gPlateString[]={'P','L','3','/','1','6','x',0,'P' Putting this in the resource file as a StringTable would be easier though. >static char** gListString; > >static Boolean PopulateList(void) >{ > FormType* frmP = FrmGetActiveForm(); > ListType* lstP = (ListType*) FrmGetObjectPtr(frmP, lstDesc); > > gListString = (char**) MemPtrNew(StrLen(gPlateString)); No. You have confused/combined two different methods: With gPlateString re-stated as above, you are prepared for SysFormPointerArrayToStrings(). This is all you do: MemHandle h=SysFormPointerArrayToStrings(gPlateList,6); ErrFatalDisplayIf(h==0,"SysFormPointerArrayToStrings failed"); gListString=MemHandleLock(h); LstSetListChoices(lstP, gListString,6); // when you are done with the list, unlock the handle and call MemHandle Free // SysForm allocated it for you, disposal is your problem If you are going to allocate yourself: // this looks more complicated than it really is. //declare the strings like this instead: char *gPlateString[] ={"PL3/16x","PL1/4x","PL5/16x","PL3/8x","PL1/2x","PL5/8x"}; ...in your function: char *dst; int i; // you can get the count automatically int cnt=sizeof(gPlateList)/sizeof(char*); //this will be 6 //you have 6 strings in your list //so you need room for 6 char * int amt = cnt*sizeof(char*); //each of the elments is 7 characters long plus the terminating zero total(8) amt += cnt*8; gListString= MemPtrNew( amt ); //this is big enough for 6 char* + 6 strings of 7 chars dst=(char*)(&gListString[cnt]); //point to first byte after the 6th char * for(i=0; i"PL3/16x\0PL1/4x\0PL5/16x\0PL3/8x\0PL1/2x\0PL5/8x\0"; These are the Char *'s (and they point to the data that follows): v 02468ACE : 000C 0014 001C 0024 002C 0034 'PL' '3/' 0010: '16' 'x'0 'PL' '1/' '4x' 'PL' '5/' 0020: '16' 'x'0 'PL' '3/' '8x' 'PL' '1/' 0030: '2x' 'PL' '5/' '8x' We wasted four bytes by allocating 8 bytes per string when four of them only had 7...but what the heck. If you want, you can track the actual string lengths and call MemPtrResize() with the final tally, but it's not worth the trouble for a list this small. > gListString = (char**) SysFormPointerArrayToStrings(gPlateString, 6); Double No. SysFormPointerArrayToStrings allocates and return a Handle. See above. Either allocate yourself, or use SysForm...not both and the Handle that it returns needs to be locked before use in LstSetListChoices. > > LstSetListChoices(lstP, gListString, 6); > LstDrawList(lstP); > > return true; >} bullshark -- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/
Re: LstSetListChoices
On Thu, Aug 07, 2003 at 11:46:16PM -0700, Steve K wrote: > I have read many a posts on this question, however, none seem to be working > for me. I have attempted to simplify this with no results. I am no longer > getting fatal exceptions, however nothing is happening. > > What is the key ingredient i'm missing here? > static char* gPlateString = > "PL3/16x\0PL1/4x\0PL5/16x\0PL3/8x\0PL1/2x\0PL5/8x\0"; > static char** gListString; > > static Boolean PopulateList(void) > { > FormType* frmP = FrmGetActiveForm(); > ListType* lstP = (ListType*) FrmGetObjectPtr(frmP, lstDesc); > > gListString = (char**) MemPtrNew(StrLen(gPlateString)); This will create an array of 7 pointers. Why are you doing this, and what information do you think that StrLen is telling you here? > gListString = (char**) SysFormPointerArrayToStrings(gPlateString, 6); SysFormPointerArrayToStrings returns a MemHandle, not a char** pointer. Coercing a MemHandle to a char** doesn't make it one. Second, you've now lost the pointer to the original chunk of memory you allocated with MemPtrNew (you overwrote its value with the result of SysFormPointerArrayToStrings). This is a memory leak because you'll never be able to free that pointer. You should be doing MemHandle h = SysFormPointerArrayToStrings(gPlateString, 6); gListString = (char**)MemHandleLock(h); ... MemHandleFree(h); -- Dave Carrigan Seattle, WA, USA [EMAIL PROTECTED] | http://www.rudedog.org/ | ICQ:161669680 UNIX-Apache-Perl-Linux-Firewalls-LDAP-C-C++-DNS-PalmOS-PostgreSQL-MySQL -- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/
Re: LstSetListChoices
I thought about that and have tried that, still nothing. I also tried commenting out the MemHandleFree line to see if it would crash... which it isn't doing either. So after calling this function, I get no error, and no data showing up in the list. I am at a total loss as to what is going on. I thought it might have something to do with the frmP and or lstP so have made a few changes as follows: static char* gPlateString = "PL3/16x\0PL1/4x\0PL5/16x\0PL3/8x\0PL1/2x\0PL5/8x\0"; static char** gListString; MemHandle gStringH; static Boolean PopulateList(FormType* frmP, ListType* lstP) { gStringH = SysFormPointerArrayToStrings(gPlateString, 6); gListString = (char**)MemHandleLock(gStringH); LstSetListChoices(lstP, gListString, 6); MemHandleUnlock(gStringH); return true; } ... case frmCloseEvent: MemHandleFree(gStringH); break; tia, Steve "Dave Carrigan" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > > On Fri, Aug 08, 2003 at 03:00:09PM -0700, Steve K wrote: > > Dave, > > > > Thank you for the advice. I am having a real hard time dealing with > > Memhandles and char*s. Been awhile since i'm done C programming and never > > played on a palm before. Anyway, you have cleared things up quite a bit > > with your advice, however, I am still not getting the list to load. > > > > I have modified to the code to your suggestions as follows: > > (maybe I misread the ... but who knows) > > > > static char* gPlateString = > > "PL3/16x\0PL1/4x\0PL5/16x\0PL3/8x\0PL1/2x\0PL5/8x\0"; > > static char** gListString; > > MemHandle gStringH; > > > > static Boolean PopulateList(void) > > { > > FormType* frmP = FrmGetActiveForm(); > > ListType* lstP = (ListType*) FrmGetObjectPtr(frmP, lstDesc); > > > > gStringH = SysFormPointerArrayToStrings(gPlateString, 6); > > gListString = (char**)MemHandleLock(gStringH); > > > > LstSetListChoices(lstP, gListString, 6); > > LstDrawList(lstP); > > MemHandleUnlock(gStringH); > > > > MemHandleFree(gStringH); > > This handle must remain allocated for the lifetime of the > list. Basically, until the form that contains the list is closed. Do the > MemHandleFree when you handle frmCloseEvent, and don't forget to call > LstSetListChoices with a null pointer just to be on the extra safe side. > > -- > Dave Carrigan > Seattle, WA, USA > [EMAIL PROTECTED] | http://www.rudedog.org/ | ICQ:161669680 > UNIX-Apache-Perl-Linux-Firewalls-LDAP-C-C++-DNS-PalmOS-PostgreSQL-MySQL > > Dave is currently listening to Jason and the Scorchers - Harvest Moon (Fervor) > > -- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/
Re: LstSetListChoices
I think I should also note that I am using this list with a pop-up list. Not sure if that makes a difference or not, but thought I would mention it. tia, Steve K "Steve K" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > > Dave, > > Thank you for the advice. I am having a real hard time dealing with > Memhandles and char*s. Been awhile since i'm done C programming and never > played on a palm before. Anyway, you have cleared things up quite a bit > with your advice, however, I am still not getting the list to load. > > I have modified to the code to your suggestions as follows: > (maybe I misread the ... but who knows) > > static char* gPlateString = > "PL3/16x\0PL1/4x\0PL5/16x\0PL3/8x\0PL1/2x\0PL5/8x\0"; > static char** gListString; > MemHandle gStringH; > > static Boolean PopulateList(void) > { > FormType* frmP = FrmGetActiveForm(); > ListType* lstP = (ListType*) FrmGetObjectPtr(frmP, lstDesc); > > gStringH = SysFormPointerArrayToStrings(gPlateString, 6); > gListString = (char**)MemHandleLock(gStringH); > > LstSetListChoices(lstP, gListString, 6); > LstDrawList(lstP); > MemHandleUnlock(gStringH); > > MemHandleFree(gStringH); > > return true; > } > > Also I hate to be too much of a bother, if you have any links to some good > reading on the subject that might help me out as well. > > tia, > > Steve > > > "Dave Carrigan" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > > > > On Thu, Aug 07, 2003 at 11:46:16PM -0700, Steve K wrote: > > > > > I have read many a posts on this question, however, none seem to be > working > > > for me. I have attempted to simplify this with no results. I am no > longer > > > getting fatal exceptions, however nothing is happening. > > > > > > What is the key ingredient i'm missing here? > > > static char* gPlateString = > > > "PL3/16x\0PL1/4x\0PL5/16x\0PL3/8x\0PL1/2x\0PL5/8x\0"; > > > static char** gListString; > > > > > > static Boolean PopulateList(void) > > > { > > > FormType* frmP = FrmGetActiveForm(); > > > ListType* lstP = (ListType*) FrmGetObjectPtr(frmP, lstDesc); > > > > > > gListString = (char**) MemPtrNew(StrLen(gPlateString)); > > > > This will create an array of 7 pointers. Why are you doing this, and > > what information do you think that StrLen is telling you here? > > > > > gListString = (char**) SysFormPointerArrayToStrings(gPlateString, 6); > > > > SysFormPointerArrayToStrings returns a MemHandle, not a char** > > pointer. Coercing a MemHandle to a char** doesn't make it one. > > > > Second, you've now lost the pointer to the original chunk of memory you > > allocated with MemPtrNew (you overwrote its value with the result of > > SysFormPointerArrayToStrings). This is a memory leak because you'll > > never be able to free that pointer. > > > > You should be doing > > > > MemHandle h = SysFormPointerArrayToStrings(gPlateString, 6); > > gListString = (char**)MemHandleLock(h); > > > > ... > > > > MemHandleFree(h); > > > > -- > > Dave Carrigan > > Seattle, WA, USA > > [EMAIL PROTECTED] | http://www.rudedog.org/ | ICQ:161669680 > > UNIX-Apache-Perl-Linux-Firewalls-LDAP-C-C++-DNS-PalmOS-PostgreSQL-MySQL > > > > > > > > -- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/
Re: LstSetListChoices
On Fri, Aug 08, 2003 at 03:41:24PM -0400, bullshark wrote: > On Fri, 8 Aug 2003 09:51:28 -0700, Dave Carrigan <[EMAIL PROTECTED]> wrote: > > > > >On Fri, Aug 08, 2003 at 12:26:13PM -0400, bullshark wrote: > > > >> >static char* gPlateString = > >> >"PL3/16x\0PL1/4x\0PL5/16x\0PL3/8x\0PL1/2x\0PL5/8x\0"; > It's still a cumbersome thing, hard to read, and fraught with peril. I didn't say it was necessarily good practice; but it is legal C. > What happens if the following character is numeric, instead of a 'P'? Use string concatenation: char* foo = "1st place\0" "2nd place\0" "3rd place" That will create an array of chars with 30 elements. -- Dave Carrigan Seattle, WA, USA [EMAIL PROTECTED] | http://www.rudedog.org/ | ICQ:161669680 UNIX-Apache-Perl-Linux-Firewalls-LDAP-C-C++-DNS-PalmOS-PostgreSQL-MySQL Dave is currently listening to Mozart - 3. Rondo (Allegro assai) (Piano Concerto in D minor, K. 466) -- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/
Re: LstSetListChoices
On Fri, 8 Aug 2003 09:51:28 -0700, Dave Carrigan <[EMAIL PROTECTED]> wrote: > >On Fri, Aug 08, 2003 at 12:26:13PM -0400, bullshark wrote: > >> >static char* gPlateString = >> >"PL3/16x\0PL1/4x\0PL5/16x\0PL3/8x\0PL1/2x\0PL5/8x\0"; >> >> The above doesn't work. The compiler knows that dquote strings end with \0 >> so there is nothing in the .o image after PL3/16x. > >What are you talking about? That's simply not true for any C compiler >I've ever seen. You're absolutely right (I just checked), thanks for correcting that. It's one of those "I been programming too long" memories... It's still a cumbersome thing, hard to read, and fraught with peril. What happens if the following character is numeric, instead of a 'P'? ...it's probably that kind of 'gotcha' that forever purged my consciousness of that type of expression (c: bullshark -- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/
Re: LstSetListChoices
On Fri, Aug 08, 2003 at 03:00:09PM -0700, Steve K wrote: > Dave, > > Thank you for the advice. I am having a real hard time dealing with > Memhandles and char*s. Been awhile since i'm done C programming and never > played on a palm before. Anyway, you have cleared things up quite a bit > with your advice, however, I am still not getting the list to load. > > I have modified to the code to your suggestions as follows: > (maybe I misread the ... but who knows) > > static char* gPlateString = > "PL3/16x\0PL1/4x\0PL5/16x\0PL3/8x\0PL1/2x\0PL5/8x\0"; > static char** gListString; > MemHandle gStringH; > > static Boolean PopulateList(void) > { > FormType* frmP = FrmGetActiveForm(); > ListType* lstP = (ListType*) FrmGetObjectPtr(frmP, lstDesc); > > gStringH = SysFormPointerArrayToStrings(gPlateString, 6); > gListString = (char**)MemHandleLock(gStringH); > > LstSetListChoices(lstP, gListString, 6); > LstDrawList(lstP); > MemHandleUnlock(gStringH); > > MemHandleFree(gStringH); This handle must remain allocated for the lifetime of the list. Basically, until the form that contains the list is closed. Do the MemHandleFree when you handle frmCloseEvent, and don't forget to call LstSetListChoices with a null pointer just to be on the extra safe side. -- Dave Carrigan Seattle, WA, USA [EMAIL PROTECTED] | http://www.rudedog.org/ | ICQ:161669680 UNIX-Apache-Perl-Linux-Firewalls-LDAP-C-C++-DNS-PalmOS-PostgreSQL-MySQL Dave is currently listening to Jason and the Scorchers - Harvest Moon (Fervor) -- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/
Re: LstSetListChoices
On Fri, Aug 08, 2003 at 03:29:21PM -0700, Steve K wrote: > I think I should also note that I am using this list with a pop-up list. > Not sure if that makes a difference or not, but thought I would mention it. If it's for a popup list, you definitely have to avoid freeing the handle until there is no chance that the list will be popped up. Also, you don't need the LstDrawList call. -- Dave Carrigan Seattle, WA, USA [EMAIL PROTECTED] | http://www.rudedog.org/ | ICQ:161669680 UNIX-Apache-Perl-Linux-Firewalls-LDAP-C-C++-DNS-PalmOS-PostgreSQL-MySQL Dave is currently listening to Jason and the Scorchers - Both Sides Of The Line (Fervor) -- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/
Re: LstSetListChoices
On Fri, Aug 08, 2003 at 12:26:13PM -0400, bullshark wrote: > >static char* gPlateString = > >"PL3/16x\0PL1/4x\0PL5/16x\0PL3/8x\0PL1/2x\0PL5/8x\0"; > > The above doesn't work. The compiler knows that dquote strings end with \0 > so there is nothing in the .o image after PL3/16x. What are you talking about? That's simply not true for any C compiler I've ever seen. -- Dave Carrigan Seattle, WA, USA [EMAIL PROTECTED] | http://www.rudedog.org/ | ICQ:161669680 UNIX-Apache-Perl-Linux-Firewalls-LDAP-C-C++-DNS-PalmOS-PostgreSQL-MySQL -- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/
Re: LstSetListChoices
Dave, Thank you for the advice. I am having a real hard time dealing with Memhandles and char*s. Been awhile since i'm done C programming and never played on a palm before. Anyway, you have cleared things up quite a bit with your advice, however, I am still not getting the list to load. I have modified to the code to your suggestions as follows: (maybe I misread the ... but who knows) static char* gPlateString = "PL3/16x\0PL1/4x\0PL5/16x\0PL3/8x\0PL1/2x\0PL5/8x\0"; static char** gListString; MemHandle gStringH; static Boolean PopulateList(void) { FormType* frmP = FrmGetActiveForm(); ListType* lstP = (ListType*) FrmGetObjectPtr(frmP, lstDesc); gStringH = SysFormPointerArrayToStrings(gPlateString, 6); gListString = (char**)MemHandleLock(gStringH); LstSetListChoices(lstP, gListString, 6); LstDrawList(lstP); MemHandleUnlock(gStringH); MemHandleFree(gStringH); return true; } Also I hate to be too much of a bother, if you have any links to some good reading on the subject that might help me out as well. tia, Steve "Dave Carrigan" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > > On Thu, Aug 07, 2003 at 11:46:16PM -0700, Steve K wrote: > > > I have read many a posts on this question, however, none seem to be working > > for me. I have attempted to simplify this with no results. I am no longer > > getting fatal exceptions, however nothing is happening. > > > > What is the key ingredient i'm missing here? > > static char* gPlateString = > > "PL3/16x\0PL1/4x\0PL5/16x\0PL3/8x\0PL1/2x\0PL5/8x\0"; > > static char** gListString; > > > > static Boolean PopulateList(void) > > { > > FormType* frmP = FrmGetActiveForm(); > > ListType* lstP = (ListType*) FrmGetObjectPtr(frmP, lstDesc); > > > > gListString = (char**) MemPtrNew(StrLen(gPlateString)); > > This will create an array of 7 pointers. Why are you doing this, and > what information do you think that StrLen is telling you here? > > > gListString = (char**) SysFormPointerArrayToStrings(gPlateString, 6); > > SysFormPointerArrayToStrings returns a MemHandle, not a char** > pointer. Coercing a MemHandle to a char** doesn't make it one. > > Second, you've now lost the pointer to the original chunk of memory you > allocated with MemPtrNew (you overwrote its value with the result of > SysFormPointerArrayToStrings). This is a memory leak because you'll > never be able to free that pointer. > > You should be doing > > MemHandle h = SysFormPointerArrayToStrings(gPlateString, 6); > gListString = (char**)MemHandleLock(h); > > ... > > MemHandleFree(h); > > -- > Dave Carrigan > Seattle, WA, USA > [EMAIL PROTECTED] | http://www.rudedog.org/ | ICQ:161669680 > UNIX-Apache-Perl-Linux-Firewalls-LDAP-C-C++-DNS-PalmOS-PostgreSQL-MySQL > > -- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/
RE: LstSetListChoices
How many visible items are there? -Original Message- From: Steve K [mailto:[EMAIL PROTECTED] Sent: Wednesday, August 13, 2003 1:10 PM To: Palm Developer Forum Subject: LstSetListChoices It has been a few days and I have not heard on this, so I thought I would post again. I am trying to set the choices in a list using LstSetListChoices, and know I am getting very close to getting it to work. I call my function to populate the list and I receive no error and I get no data displayed in my list. Here is the function. static char* gPlateString = "PL3/16x\0PL1/4x\0PL5/16x\0PL3/8x\0PL1/2x\0PL5/8x\0"; static char** gListString; MemHandle gStringH; static Boolean PopulateList(FormType* frmP, ListType* lstP) { gStringH = SysFormPointerArrayToStrings(gPlateString, 6); gListString = (char**)MemHandleLock(gStringH); LstSetListChoices(lstP, gListString, 6); MemHandleUnlock(gStringH); return true; } ... case frmCloseEvent: MemHandleFree(gStringH); break; tia, Steve -- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/ -- The information in this transmittal and any attachments are confidential and intended only for the recipient(s) listed above. You are hereby notified that any unauthorized distribution or copying of this transmittal or its attachments is prohibited. If you have received this transmittal in error, please notify invivodata immediately at (831) 438-9550. -- -- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/
Re: LstSetListChoices
According to the Palm OS Reference, if the list is visible when you call LstSetListChoices, you will need to call LstDrawList to update the list. -Tom > It has been a few days and I have not heard on this, so I thought I would > post again. > > I am trying to set the choices in a list using LstSetListChoices, and know I > am getting very close to getting it to work. > > I call my function to populate the list and I receive no error and I get no > data displayed in my list. > > Here is the function. > > static char* gPlateString = > "PL3/16x\0PL1/4x\0PL5/16x\0PL3/8x\0PL1/2x\0PL5/8x\0"; > static char** gListString; > MemHandle gStringH; > > static Boolean PopulateList(FormType* frmP, ListType* lstP) > { > gStringH = SysFormPointerArrayToStrings(gPlateString, 6); > gListString = (char**)MemHandleLock(gStringH); > > LstSetListChoices(lstP, gListString, 6); > MemHandleUnlock(gStringH); > > return true; > } > > ... > > case frmCloseEvent: > MemHandleFree(gStringH); > break; > > tia, > > Steve > > -- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/
Re: LstSetListChoices
Thanks guys, but I have solved this issue already. Steve K "Tom Hoelscher" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > > According to the Palm OS Reference, if the list is visible when you call > LstSetListChoices, you will need to call LstDrawList to update the list. > > > -Tom > > > > It has been a few days and I have not heard on this, so I thought I would > > post again. > > > > I am trying to set the choices in a list using LstSetListChoices, and know I > > am getting very close to getting it to work. > > > > I call my function to populate the list and I receive no error and I get no > > data displayed in my list. > > > > Here is the function. > > > > static char* gPlateString = > > "PL3/16x\0PL1/4x\0PL5/16x\0PL3/8x\0PL1/2x\0PL5/8x\0"; > > static char** gListString; > > MemHandle gStringH; > > > > static Boolean PopulateList(FormType* frmP, ListType* lstP) > > { > > gStringH = SysFormPointerArrayToStrings(gPlateString, 6); > > gListString = (char**)MemHandleLock(gStringH); > > > > LstSetListChoices(lstP, gListString, 6); > > MemHandleUnlock(gStringH); > > > > return true; > > } > > > > ... > > > > case frmCloseEvent: > > MemHandleFree(gStringH); > > break; > > > > tia, > > > > Steve > > > > > > > -- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/
Re: LstSetListChoices trouble
> Can anyone who has created a dynamic List please tell me > what's wrong with the following code snippet: > > char items[10][5]; ^^ this aint dynamic :P > StrCopy(items[0], "AAC"); > StrCopy(items[1], "BBD"); > StrCopy(items[2], "CCA"); > StrCopy(items[3], "ADD"); > ... > > LstSetListChoices (listP, items, 4); try this: LstSetListChoices(listP, (Char **)&(items[0][0]), 4); this might help :) otherwise dynamically allocate the list. az. -- Aaron Ardiri Java Certified Programmer http://www.hig.se/~ardiri/ University-College i Gävle mailto:[EMAIL PROTECTED] SE 801 76 Gävle SWEDEN Tel: +46 26 64 87 38 Fax: +46 26 64 87 88 Mob: +46 70 656 1143 A/H: +46 8 668 78 72 if you enjoy it, then it aint work :) - rule #106 of life -- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palm.com/devzone/mailinglists.html
RE: LstSetListChoices trouble
LstSetListChoices expects a list of character pointers (a list of addresses). You are creating an array of actual strings. Using: static char *items[] = { "AAC", "BBD", "CCA", "ADD" }; LstSetListChoices (listP, items, 4); Should work. Good Luck, -jjf -Original Message- From: Stephen Bentley [mailto:[EMAIL PROTECTED]] Sent: Monday, March 27, 2000 12:47 PM To: Palm Developer Forum Subject: LstSetListChoices trouble Can anyone who has created a dynamic List please tell me what's wrong with the following code snippet: char items[10][5]; StrCopy(items[0], "AAC"); StrCopy(items[1], "BBD"); StrCopy(items[2], "CCA"); StrCopy(items[3], "ADD"); ... LstSetListChoices (listP, items, 4); I get this compile time error: Error : cannot convert 'char (*)[5]' to 'char **' test.c line 4599 LstSetListChoices (listP, items, 4); I've also tried &items in the function call but it doesn't work either. What am I doing wrong? Steve -- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palm.com/devzone/mailinglists.html -- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palm.com/devzone/mailinglists.html
Re: LstSetListChoices trouble
> LstSetListChoices expects a list of character pointers (a list of > addresses). You are creating an array of actual strings. Using: > > static char *items[] = { "AAC", "BBD", "CCA", "ADD" }; > LstSetListChoices (listP, items, 4); > > Should work. That works, except on PalmOS 1.x, for what that's worth. I forget what was the exact issue with this; either PalmOS 1.x couldn't access this type of list when global, or maybe it was the compiler which wouldn't compile this properly, or some combination of the two. Another option for a static list of strings is to put the strings in a tAIS resource ("App Info String List" in Constructor) and then build the list of char pointers w/ SysFormPointerArrayToStrings(), eg: MemHandle rscHandle, listHandle ; Char *rsc, **list ; rscHandle = DmGetResource(appInfoStringsRsc,ListRscID) ; if ( rscHandle ) { rsc = MemHandleLock(rscHandle) ; listHandle = SysFormPointerArrayToStrings(rsc,nItems) ; list = MemHandleLock(listHandle) ; } SysFormPointerArrayToStrings() doesn't copy the strings in the resource--it only allocates storage for the list of pointers pointing to the strings in the resource--so you need to keep the resource loaded and its handle locked for the lifetime of the list (I believe). When you're done w/ the list, then you can unlock the handle and unload the resource. Speaking of which, what about the memory allocated by SysFormPointerArrayToStrings()? I assume the system will dispose of it when an application exits, but would it be better if we freed this ourselves w/ MemHandleFree()? John -- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palm.com/devzone/mailinglists.html
RE: LstSetListChoices - Solved!
Thanks to everyone that responded. Your code definitely helped! My basic problem had to do with not having the correct type for the second parameter of the LstSetListChoices call. Once I got that fixed, all went well! Very truly yours, Rob G. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On Behalf Of Eric Sent: Wednesday, April 26, 2000 10:54 AM To: Palm Developer Forum Subject: RE: LstSetListChoices Hello Rob, I have a similar situation and basically iterate through a database and grep strings. Here is an example - for string char(9): VoidHand LstH = MemHandleNew(1); VoidHand H; Char *tmp; int i, k = 0; while (still more strings) { determine if the string is valid(I can handle that part myself) if (valid) { k ++; if (MemHandleResize(lstH,10 * k) == 0) { //if can be resize, add the next string tmp = MemHandleLock(lstH); for (i = 1; i < k; i++) tmp += StrLen(tmp) + 1; StrNCat(tmp, value, 10);//value = value from database MemHandleUnlock(lstH); } else { //if cannot resize, just dump out what you got k--; break; } //if next string } H = SysFormPointerArrayToString(MemHandleLock(lstH),k); MemHandleUnlock(lstH); LstSetListChoices(LstPtr, MemHandleLock(H), k); MemHandleUnlock(H); Hopes this helps. Eric Sun Developer - RAD systems Q. Data Inc. 4/26/00 11:31 AM -Original Message- From: Rob Graber [SMTP:[EMAIL PROTECTED]] Sent: Wednesday, April 26, 2000 10:35 AM To: Palm Developer Forum Subject:LstSetListChoices Here is the deal. I have a database with a record containing a bunch of NULL-terminated strings. Some of the strings are valid for inclusion in my listbox, others are not. I want to write some code that will do the following. while (still more strings) { determine if the string is valid(I can handle that part myself) if (valid) { write a pointer value to the beginning of the string to the end of a record in the database (essentially create a record that is an array of character pointers) } next string } //now that there is a record containing an array of character pointers.. LstSetListChoices(listP, itemsText, numStrings); My problem is that I can't seem to figure out the declarations/syntax to set and pass the itemsText variable. Any ideas? Anyone already done something similar they can share? I am attaching the SDK ref for LstSetListChoices for convenience. Very truly yours, Rob G. Prototype void LstSetListChoices (ListPtr ListP, char ** itemsText, UInt numItems) Parameters ListP Pointer to a list object. itemsText Pointer to an array of text strings. numItems Number of choices in the list. Result Returns nothing. -- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palm.com/devzone/mailinglists.html -- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palm.com/devzone/mailinglists.html -- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palm.com/devzone/mailinglists.html
Re: LstSetListChoices() crashes
Hi nisha When you add items to a list dynamically, you either pass the entire array of strings to the list and let the OS take care of allocation, dealloc and other things yourself or use a callback function to draw the list yourself. The latter approach is more flexible but the former is easier. See my code snippet given below -> just a starting point. --- char **gFileListElements; Char **filelist; filelist = (Char**)MemPtrNew(4 * sizeof(Char*)); gFileListElements = filelist; for(i = 0; i < 4; i++) { recordH = DmGetRecord(dbMainRef, i); myrec = (Maindbrec*)MemHandleLock(recordH); temprec = *myrec; filelist[i] = (Char*)MemPtrNew(20); StrCopy(filelist[i], temprec.fileno); MemHandleUnlock(recordH); DmReleaseRecord(dbMainRef, i, 0); } LstSetListChoices(lstFileNo, filelist, 4); -- Make sure you free the memory allocated in form close event. for(i = 0; i < 4; i++) MemPtrFree((MemPtr)gFileListElements[i]); MemPtrFree((MemPtr)gFileListElements); --- Regards Sridhar On Tue, 30 Jul 2002 Akhil Bhandari wrote : >Hi, > >I am using list control in my GUI application in palm >OS CodeWarrior. > >I am adding data in the list dynamically. I am using >method >LstSetListChoices() . It works fine. > >Now like this if a add no. of items more than the list >visible item, a >scroll bar appears and if i click it, program crashes. > >anyway if through resource if no. of items added are >more than no. of >visible item. program works fine.. > >I think this scroll bar problem appears only if i add >list items >dynamically. > >Please guide me on the same. > >rgds, >Nisha. > > > > > > > > > >-- >For information on using the Palm Developer Forums, or to >unsubscribe, please see >http://www.palmos.com/dev/support/forums/ The way you work tells the world who you are - Sridhar -- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/
Re: LstSetListChoices() crashes
--- Akhil Bhandari <[EMAIL PROTECTED]> wrote: > > I am adding data in the list dynamically. I am using > method LstSetListChoices() . It works fine. > > Now like this if a add no. of items more than the list > visible item, a scroll bar appears and if i click it, > program crashes. > Maybe you aren't using a global to hold the list choices? See the Lists recipe at http://www.palmos.com/dev/support/docs/recipes/lists.html, then if you can't figure out what is wrong, post your code. __ Do You Yahoo!? Yahoo! Health - Feel better, live better http://health.yahoo.com -- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/
Re: LstSetListChoices limit?
32767, because all functions which work with list wotk with Int16 +i noticed that on some devices if you have many items and you scroll to position more then 2800 or something near it list will start to behave bad - it will draw items and then delete them all so items will be visible on screen only during scrolling Darren wrote: Hello, am trying to get a simple database listing. Is there a limit to the number items that can be passed to LstSetListChoices. Many thanks regards Darren -- For information on using the ACCESS Developer Forums, or to unsubscribe, please see http://www.access-company.com/developers/forums/
Re: LstSetListChoices limit?
My two cents. You can work around this, like using an array or list of selected items, this list should contain the index of the element that has selection on, so you only work the list with the displayed items, and update the display checking against the list of select items. So you can add or delete items on this list when you select or unselect them. Eduardo Orea. Darren escribió: Hello, am trying to get a simple database listing. Is there a limit to the number items that can be passed to LstSetListChoices. Many thanks regards Darren -- For information on using the ACCESS Developer Forums, or to unsubscribe, please see http://www.access-company.com/developers/forums/
Re: LstSetListChoices limit?
with your approach there would be problem with scrolling, search based on typed character and such things. all this could be solved, but it wouldn't be simple for such cases it may be better to use table+scrollbar, or custom control based on gadget. Eduardo Orea wrote: My two cents. You can work around this, like using an array or list of selected items, this list should contain the index of the element that has selection on, so you only work the list with the displayed items, and update the display checking against the list of select items. So you can add or delete items on this list when you select or unselect them. Eduardo Orea. Darren escribió: Hello, am trying to get a simple database listing. Is there a limit to the number items that can be passed to LstSetListChoices. Many thanks regards Darren -- For information on using the ACCESS Developer Forums, or to unsubscribe, please see http://www.access-company.com/developers/forums/
Re: LstSetListChoices limit?
Michal Seliga. Ok, I respect that the path seems to be complicated, but it is not right to make the assumption that it's complicated for everyone. Darren could find it simple or complicated and may or may not use it, it's up to him to decide that on behalf of what he wants to do. My opinion it's just for Darren to know about other options, the "simple database listing" it's just an appreciation. You already gave him IMHO the most direct answer to his question, I just tried to give him another perspective. Regards. Eduardo Orea. Michal Seliga escribió: with your approach there would be problem with scrolling, search based on typed character and such things. all this could be solved, but it wouldn't be simple for such cases it may be better to use table+scrollbar, or custom control based on gadget. Eduardo Orea wrote: My two cents. You can work around this, like using an array or list of selected items, this list should contain the index of the element that has selection on, so you only work the list with the displayed items, and update the display checking against the list of select items. So you can add or delete items on this list when you select or unselect them. Eduardo Orea. Darren escribió: Hello, am trying to get a simple database listing. Is there a limit to the number items that can be passed to LstSetListChoices. Many thanks regards Darren -- For information on using the ACCESS Developer Forums, or to unsubscribe, please see http://www.access-company.com/developers/forums/
Re: LstSetListChoices trouble CONT'D
On Tue, 28 Mar 2000, Stephen Bentley wrote: > Thanks to many of you kind souls, I now have a list created > at run time. With these statements I can see my list: > > LstNewList (&frmP, MyNewList, 94, 129, 20, 20, stdFont, 5, 0); > popupList = UtilGetObjectPtr( MyNewList ); > LstSetListChoices(popupList, items, 5); > LstDrawList ( popupList ); > > However, I want to use the list with a popup trigger. When I > do this: > > LstNewList (&frmP, MyNewList, 94, 129, 20, 20, stdFont, 5, > ExistingPopupTrigger); > > I get a bus error upon tapping the trigger. If I set visible items to 0 > in the call, I get no bus error, but an empty list pops up. Any > suggestions? > > Steve Do you need to dynamically create the list? Why not create it in Constructor/as a resource? Then you can drop the "LstNewList" line. Resources are much easier to deal with than dynamically creating it, especially for a beginner. You can still dynamically populate the list data from your program. I suggest getting "Palm Programming: The Developer's Guide" By Neil Rhodes & Julie McKeehan. http://www.oreilly.com/catalog/palmprog/ It addresses all your issues and gives you a good background on what;s going on. It'll also help you out with anything else you might run into. -- Brian Mathis Direct Edge http://www.directedge.com -- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palm.com/devzone/mailinglists.html
Re: LstSetListChoices and Memory
From: "Steve" <[EMAIL PROTECTED]> > Does this behave differently in PalmOS 5 ? > > On the Emulator (M505 ROM), if I don't manually free up > the memory I allocated for the ListItems (an array of Strings), > I get warnings about leaked memory upon application exit > (Form Close). So my application frees the memory itself. > > On the Garnet Simulator, if I free the Memory I get a > MemFreePtr error when I call LstSetChoices (it seems that it > tries to free the previous list contents, so I mustn't). > When you free the memory do you call LstSetChoices() with null? This is what's done to stop Palm OS freeing the memory when it destroys the form, although I would have thought that earlier OS's would complain if you weren't doing this. Chris Tutty -- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/
Re: LstSetListChoices and Memory
> I think what might be happening is your list is trying to use the > pointer between freeing the old pointer and setting the new > pointer. > Try reversing the order; set the new pointer first, then free the > old memory. Top tip Thanks for that, it's much happier now :-) -- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/
Re: LstSetListChoices keeps crashing on me :(
Robert Baruch wrote: Hi all, Can someone tell me what's wrong? In my program, when LstSetListChoices is hit, the emulator dies with an array index out of bounds. Here's the code fragment: static void displayCallLog() { ListType *list; char *duration; char *testArray[] = {"one", "two", "three", "four", "five"}; list = FrmGetObjectPtr( FrmGetFormPtr(GetCallLogForm), CallLogTable); LstSetListChoices(list, testArray, 5); LstDrawList(list); } You are telling the LstHandler to use a pointer to a list array that only exists in this one function. As soon as the list does it's initial draw the function will return and the pointer that you gave will no longer be valid. You could declare the list as a global variable, then it will be persistent. Bob. -- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/
Re: LstSetListChoices keeps crashing on me :(
Robert Baruch wrote: Hi all, Can someone tell me what's wrong? In my program, when LstSetListChoices is hit, the emulator dies with an array index out of bounds. Here's the code fragment: static void displayCallLog() { ListType *list; char *duration; char *testArray[] = {"one", "two", "three", "four", "five"}; list = FrmGetObjectPtr( FrmGetFormPtr(GetCallLogForm), CallLogTable); LstSetListChoices(list, testArray, 5); LstDrawList(list); LstSetListChoices doesn't copy the contents of your pointer. So, as soon as you leave displayCallLog and testArray is removed from memory the list has an invalid pointer. Luciano -- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/
Re: LstSetListChoices keeps crashing on me :(
OK, I have made the testArray global, and the crash with index out of bounds still happens... what else could be wrong? static char *testArray[] = {"one", "two", "three", "four", "five"}; static void displayCallLog() { // etc } Thanks for any help! --Rob -- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/
Re: LstSetListChoices keeps crashing on me :(
> Can someone tell me what's wrong? In my program, when LstSetListChoices is > hit, the emulator dies with an array index out of bounds. As the others said, the variables has an implizit "auto" modifier and it is not longer valid when the list is drawn. I think you should add the modifiers "const" and "static" to keep the list alive. Concerning your other problem, I think you have to call LstSetHeight() also. Bodo -- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/
Re: LstSetListChoices keeps crashing on me :(
You can't make the array const... otherwise you couldn't have lists whose content changes. I also added LstSetHeight, but that failed to help. I think I'm going to have to fork over $125 to Palm Support to get them to figure it out :( --Rob -- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/
Re: LstSetListChoices keeps crashing on me :(
Robert Baruch wrote: You can't make the array const... otherwise you couldn't have lists whose content changes. I also added LstSetHeight, but that failed to help. I think I'm going to have to fork over $125 to Palm Support to get them to figure it out :( You really shouldn't have to do that. This is an implementation problem in your code, not a problem with some esoteric function that may or may not be broken in the OS. There are TONS of apps that handle lists with dynamic content. Off the top of my head, try this: Create a global list: Char *days[7]={"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}; Set up your list: ListType*listP=GetObjectPointer(yourListID); LstSetListChoices(listP, days, 7); LstSetSelection(listP,3); //sets the initial selection as "Wednesday", just for kicks. LstSetHeight(7); Now draw the list: LstDrawList(listP); Now, with the declaration of "days" above, it doesn't allow much room for dynamically changing the list. You can overwrite those strings (StrCopy(days[1],"Snd2"); for instance) but you are stuck with the string lengths that you initially set, or you will run into the other strings and overwrite your trailing NULL characters, both bad things. You could declare more inital space, or declare them as 32byte character arrays, or whatever you want. Bob. --Rob -- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/
Re: LstSetListChoices keeps crashing on me :(
"Robert Baruch" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hi all, > > Can someone tell me what's wrong? In my program, when LstSetListChoices is hit, the emulator dies with an array index out of bounds. > > Here's the code fragment: > > static void displayCallLog() > { > ListType *list; > char *duration; > char *testArray[] = {"one", "two", "three", "four", "five"}; > > list = FrmGetObjectPtr( > FrmGetFormPtr(GetCallLogForm), > CallLogTable); > LstSetListChoices(list, testArray, 5); > LstDrawList(list); > > } > > . > Thanks for any help and advice! > > --Rob > Actually, CallLogTable must be an object index not an object ID. Is it? void *FrmGetObjectPtr (const FormType *formP, UInt16 objIndex) Parameters -> formP Pointer to the form object (FormType structure). -> objIndex Index of an object in the form. You can obtain this by using FrmGetObjectIndex --- Ralph -- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/
Re: LstSetListChoices keeps crashing on me :(
Robert Baruch wrote: > I also added LstSetHeight, but that failed to help. > > I think I'm going to have to fork over $125 to Palm Support to get > them to figure it out :( You could try using setting callback to draw the list items. Your callback and then just do WinDrawChars(), and it can use whatever you want -- a switch, an array, a random number generator, whatever -- to figure out what to draw on each line. - Logan -- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/
Re: LstSetListChoices keeps crashing on me
Subject: Re: LstSetListChoices keeps crashing on me :( From: "Robert Baruch" <[EMAIL PROTECTED]> You can't make the array const... otherwise you couldn't have lists whose content changes. I also added LstSetHeight, but that failed to help. I think I'm going to have to fork over $125 to Palm Support to get them to figure it out :( But you can have a static pointer. Assign memory to it and then copy the contents of the list to it. Then you has a persistent pointer you can use to initialize the list. Do all this when processing the "frmLoadEvent" Then release the memory when processing the "frmCloseEvent", though this gets tricker on a modal form which don't have that event. Roger Stringer Marietta Systems, Inc., P.O. Box 71506, Marietta, Georgia 30007, USA 770-565-1560 PDE, RF-TP and piDB are trademarks of Marietta Systems, Inc. http://www.rf-tp.com -- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/
RE: ?LstSetListChoices -- Must it point to a static array?
> From: Al Macy [mailto:[EMAIL PROTECTED]] > LstSetListChoices takes a pointer to an array of text > strings. Are those strings copied into storage for that list, > or do they need to remain around The strings are not copied, only the pointers to them. Your code needs to keep them valid for the lifetime of the list. Or consider using a draw callback, which lets you omit supplying strings at all. Depending on your app, this may be easier. -slj- -- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palm.com/devzone/mailinglists.html
Re: ?LstSetListChoices -- Must it point to a static array?
Scott L. Johnson wrote in message <7020@palm-dev-forum>... > >> From: Al Macy [mailto:[EMAIL PROTECTED]] >> LstSetListChoices takes a pointer to an array of text >> strings. Are those strings copied into storage for that list, >> or do they need to remain around > >The strings are not copied, only the pointers to them. Your code needs to >keep them valid for the lifetime of the list. > >Or consider using a draw callback, which lets you omit supplying strings at >all. Depending on your app, this may be easier. > As far as I can tell, implementing the list draw callback is -always- as easy, if not easier, than the other way. It is also more flexible. You might just want to get into the habit of always using the drawing callback method with lists and that way you never have to think "which way should I do it with -this- list?" -- -Richard M. Hartman [EMAIL PROTECTED] 186,000 mi/sec: not just a good idea, it's the LAW! -- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palm.com/devzone/mailinglists.html
Re: ?LstSetListChoices -- Must it point to a static array?
> As far as I can tell, implementing the list draw callback is > always- as easy, if not easier, than the other way. It is also > more flexible. You might just want to get into the habit of > always using the drawing callback Just remember - when using a drawing callback the list doesn't keep track of what text is displayed. If you want text from the list on a popSelect or lstSelect event you can't go though the List pointer. You have to use the same method to get the text after the event that you used to get the text for drawing. (Sorry if this is too basic...) trib -- David Tribble, INRI Hawaii (808) 625 2118 (v) (808) 625 6315 (f) -- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palm.com/devzone/mailinglists.html
Re: ?LstSetListChoices -- Must it point to a static array?
David Tribble wrote in message <7051@palm-dev-forum>... > >> As far as I can tell, implementing the list draw callback is >> always- as easy, if not easier, than the other way. It is also >> more flexible. You might just want to get into the habit of >> always using the drawing callback > >Just remember - when using a drawing callback the list doesn't keep track of what text is >displayed. If you want text from the list on a popSelect or lstSelect event you can't go though >the List pointer. You have to use the same method to get the text after the event that you >used to get the text for drawing. > Correct. I hadn't even thought of mentioning it because generally I don't use the list text anyway, I use the list selection #. And yes, that selection # is used to index into an array of objects upon which I then do the work. -- -Richard M. Hartman [EMAIL PROTECTED] 186,000 mi/sec: not just a good idea, it's the LAW! -- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palm.com/devzone/mailinglists.html
Re: ?LstSetListChoices -- Must it point to a static array?
Where can i find the newest printcap and msr stuff? i have a device that i doubt is updated in the existing printcap and want to know if it is at all supported, if not, i will manually hafta put all the guts into it. is there anything i should know about if i go about that road? i already have a successful serial connection and am getting garble back so i know i'm talking to it, right now its the 'hit and miss' type figuring out. any thoughts welcome -- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palm.com/devzone/mailinglists.html