List Box

Postby Bob Hall on Fri Jun 13, 2003 12:36 pm

I am trying to get the list box to return a value that is a #define statement. It only returns the string that appears in the list box.
The code is as follows:

#define Pi 3.141


selection = Cgetcontent(Constants);

The output is the string Pi.
I wamt the output to be the value 3.141.

the following code works

selection = Cgetcontent;
if (selection = Pi)
puts(selection2);(output is 3.141)

while this works it makes for many lines of code when there are many constants in the list.

Is there a better method to get the Cgetcontent to return the value rather than the string.

Bob Hall
Posts: 10
Joined: Tue May 29, 2001 8:25 am
Location: USA

Postby soinsg on Sat Jun 14, 2003 7:53 pm

Is selection or selection2 a float?
Code: Select all
puts((float)selection); //Use format() to specifiy decimal places

Code: Select all
if (selection = Pi) //Should be ==
  selection2 = Pi;

But I assume that was just a typo :D.
Posts: 198
Joined: Thu May 17, 2001 4:26 pm

Postby Bob Hall on Mon Jun 16, 2003 3:05 pm

Thanks for the reply Soinsg.

I had previously tried casting as a float and that didn't work.

When using Clist you can add to the list box two ways

Cadditme (listbox, "Pi")

which is a string


Cadditem (listbox, Pi)

which will return 3.141 if previously defined but the list box says 3.141.

Looks like I will have to use the if statement solution.

Thanks anyway.

Bob Hall
Bob Hall
Posts: 10
Joined: Tue May 29, 2001 8:25 am
Location: USA

Return to PocketC for Palm OS KB

Who is online

Users browsing this forum: No registered users and 0 guests