Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3368: Cannot modify header information - headers already sent by (output started at /includes/bbcode.php:472)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3370: Cannot modify header information - headers already sent by (output started at /includes/bbcode.php:472)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3371: Cannot modify header information - headers already sent by (output started at /includes/bbcode.php:472)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3372: Cannot modify header information - headers already sent by (output started at /includes/bbcode.php:472)
OrbWorks Community Forum • View topic - Easy question (beginner)

Easy question (beginner)

Postby guilly on Fri Nov 26, 2004 9:59 am

Hello.

I have a string variable with a numeric content, and I want to multiply it with a float number (that is, StringVariable * FloatNumber). Note that the float number is not a variable.

I tried many ways but I get weird results (the resulting number has the decimal point two positions ahead).

Any suggestions? Thank you!
guilly
 
Posts: 3
Joined: Mon Jun 30, 2003 8:32 am

Postby Mikael on Fri Nov 26, 2004 12:22 pm

I don't know if this is any help to you:

//StringXFloat
@cid "STF1";
@ver "1.0";
@dbname "StringXFloat";
@name "StringXFloat";
main(){
string testString = "123";
float result;
result = (int) testString * 7.3;//cast the string as an integer - or a float - by stating: (variable type)variable name
alert("Result = " + format(result,3));//state the number of decimal places to display with 'format(variable name,number of decimal places)'
exit();

I'd love to know how you got the program to run without casting your string variable first. When I tried, I got an alert saying, 'Attempt to multiply strings'.

Mikael
Mikael
 
Posts: 156
Joined: Sun Apr 13, 2003 9:19 am
Location: Denmark

Postby guilly on Sun Nov 28, 2004 7:38 pm

Uhm.

That is very close to what I actually do (I do data casting, so I do not get the annoying "cannot multply strings" message).

It might seem to me that the problem is coming from the Ccontrol library, with which I was experimenting with.

This is my code (sorry, quite long).

<font color="blue">
@cid "tr01";
@name "Training 01";
@dbname "tr01";

include "Ccontrols.c"

Chandle Boton, Euros, Pesetas;

main() {

int e;
float xEuros,xPesetas;

graph_on();
clearg();
setcolordepth(2);
text(10,10,"Conversor EURO/PTA (Training)");
frame(1,9,22,151,151,5);

Boton = Cbutton(50,100,65,12,1,5);
Csetcontent( Boton, "Convertir" );
Cdraw( Boton );

Euros = Cedit(14,30,40,2,2,0);
Csetcontent( Euros, "Euros" );
Cdraw( Euros );

Pesetas = Cedit(67,30,40,2,2,0);
Csetcontent( Pesetas, "0" );
Cdraw( Pesetas );

while(1) {
e = event(1);
if(Cevent(Boton,e)) {
Csetcontent( Pesetas, xEuros );
Cdraw( Pesetas ); }
else if(Cevent(Euros,e)) {
xEuros = (float)Cgetcontent(Euros);
xEuros = format(xEuros, 2); }
else if(Cevent(Pesetas,e));
}

wait();
exit();

}</font id="blue">

Yes yes, I know, it is another bloody Euroconverter. Don't worry I won't release it to the public. I just made it for learning reasons.

Getting back to the point, has anyone encountered this problem when using Ccontrols? Did I do anything wrong?.
guilly
 
Posts: 3
Joined: Mon Jun 30, 2003 8:32 am


Return to PocketC for Palm OS KB

Who is online

Users browsing this forum: No registered users and 1 guest

cron