Pascal question lazarus / 8-Other ---------------------------------------------------------------------- JimBodkins · 2006-08-22 00:32 (Sorry, Its been years ... ) I have created a library using C. I have declared the functions in the library in the pascal. That all works. I have a function that takes a pointer to int as an arg (foo(P : pchar)) ...   arg : integer;   LB : TListBox;   foo(@arg);   LB.Items.Add(IntToStr(arg)); ... so far this works ok. I get an error when I attempt to StrToInt(LB.GetSelectedText) that the string is an invalid integer. (Presumably because of the last char which is nonprinting)  There appears to be an extra character at the end. Any idea what that extra char at the end might be? I would assume it to be the null, which doesnt explain why the initial IntToStr worked. I'm confused. ... foo can return a value in P as either an integer or a pchar.    Thanks ---------------------------------------------------------------------- JimBodkins · 2006-08-22 22:40 I think you have a bug. This ... arg : integer; LB : TListBox; foo(@arg); LB.Items.Add(IntToStr(arg)); with LB.Items.Add(IntToStr(stuff)) is not invertable. Meaning ... StrToInt(LB.Items.GetSelectedText) <> stuff; I had to create an array of records and save an entry in the array as it is added to LB. Items then using the index of LB.Items when I double click it to generate an index into the array or records to retrieve stuff. I think there may be a bug in the GetSelected Text method for the ListBox class. ---------------------------------------------------------------------- Marc · 2006-08-23 09:32 ehmm... what if a pchar is returned ? you display the pointer to it as number ? 2nd, is there something selected, does GetSelectedText return something ? ---------------------------------------------------------------------- JimBodkins · 2006-08-23 21:07 GetSelectedText displays a string with a mystery char at the end. (If assigned to a caption somewhere). The error - if there is one (It has been a while after all ) - is this; Add(StrToInt(buff)) works but IntToStr(GetSelectedText) throws an exception (invalid integer "123). It doesnt appear to be invertable. I am saving the ListBox items (strings) off in an array of records as ints and use the LB.Index to index the array or records to get the int and it works like a charm. It may be that GetSelectedText returns a NL or something (\n) at the end of the selected string. That may be the mystery char. Your question about a pchar .. good point. In C that isnt an issue, but I fear the worse in Pascal (I prefer the rigor or Pascal to the laxness of C). At this point I deal with that by having a seperate Function that only does pchars (it works). This is database stuff. Legacy apps linked to dot A's that are curses based. I am attempting to bring it all into the modern world. Lazarus is great - it runs like good beta code - but that is to be expected - it is beta. It has some twitchy elements (as does FPC actually). But so far nothing that is a deal breaker. (I never could get kylix to actually work) ---------------------------------------------------------------------- Vincent Snijders · 2006-08-24 08:03 I read this thread and I feel at a loss, because the code is so incomplete. Can you give a more or less compilable example? ---------------------------------------------------------------------- JimBodkins · 2006-08-26 22:06 I will get back to you shortly. Thanks for the response. I have been out of town on a job. Thanks