Page 1 of 1
simple problem with addition
Posted: Sun Jul 19, 2009 11:11 pm
by Glenn Boyce
I've looked at this line and can't figure out why it won't work. Syntax problem of some kind but no doubt someone will see what I can't! I have it in a repeat loop and it just errors. Appreciate any help
Code: Select all
add item 7 of line n of fld "resultByMaterial" to gmatweight
Posted: Sun Jul 19, 2009 11:16 pm
by SparkOut
What's the error you get? Is it on every iteration through the loop. At first glance I can't see why you'd get an error, so I think the only thing you can do is check your data (are you trying to add a non numeric value to the integer in gmatweight? have you got any dirty data with nulls or spaces that are causing the problem?) and step through the code in the debugger checking what values are being read and added.
EDIT: this is a line in a table field, presumably tab delimited, so have you set the item delimiter to tab in your routine before reading the values in the loop? theItemDelimiter resets itself back to the default value of comma at the end of each handler, so you may need to explicitly set it in this handler again if you had already changed it in another handler and thought that would be remembered.
figured it out
Posted: Sun Jul 19, 2009 11:44 pm
by Glenn Boyce
One of the numbers has a comma in it i.e. 5,000.00 and its obviously reading it as text.
Posted: Mon Jul 20, 2009 2:59 pm
by shadowslash
Glenn Boyce wrote:One of the numbers has a comma in it i.e. 5,000.00 and its obviously reading it as text.
Yep that's right. Therefore you must come up with a solution that will convert 5,000.00 to an integer. You may want to try a code somehow like this.
replace comma with empty in myVariable
Posted: Mon Jul 20, 2009 9:22 pm
by Glenn Boyce
Thank you