[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Notice: in file [ROOT]/includes/session.php on line 2208: Array to string conversion
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4688: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3823)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4690: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3823)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4691: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3823)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4692: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3823)
Poco Forums • View topic - ChatToInt

ChatToInt

Scripting questions and ideas

Moderators: Eric, Tomas, robin, Michael

ChatToInt

Postby ronenya » Fri Feb 04, 2005 10:58 am

Hello,

I am trying to convert string like: $ 5.34 or EUR 5,34 into Integers. I have tried just to assign a string to a number varaible like:

Code: Select all
Set #ItemPrice $ItemPriceStr


but Poco complains : Non-Integer assigned to Integer value...

Poco offers CharToInt which gives back the number for the FIRST char of the String. One could go on this way and get a char by char out of the string.

Is there a better way to do it?

Thanks,
Ronen.
Try to live every day as if it was the last day of your life.
ronenya
Drop-in Visitor
 
Posts: 5
Joined: Wed Sep 29, 2004 8:27 pm

Postby Andreas » Fri Feb 04, 2005 7:55 pm

To store values like 5.34 and 5,34, you would need floating-point variables (or strings), not integers.
Andreas
Poco Enthusiast
 
Posts: 380
Joined: Sun Jul 25, 2004 5:30 pm
Location: Germany

Postby Michael » Tue Feb 08, 2005 3:57 am

Since PocoScript only supports integers I would suggest parsing for the decimal separator (period or comma) and splitting the amount value into two values and processing them separately. E.g.,
Code: Select all
StringPos #ix "." $Amount
Set $Whole $Amount
ChopString $Whole #ix 9999
Set $Decimals $Amount
ChopString $Decimals 1 #ix


Warning: The above is off the top of my head, I have not tested this.
Michael
Moderator
 
Posts: 866
Joined: Mon Jul 26, 2004 12:14 pm
Location: Victoria BC, Canada


Return to PocoScript Help and How-To

Who is online

Users browsing this forum: No registered users and 1 guest

cron