More on number formatting problems

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
Ron Zellner
Posts: 106
Joined: Wed May 31, 2006 9:56 pm
Contact:

More on number formatting problems

Post by Ron Zellner » Tue Jul 28, 2009 4:49 am

I have a repeat loop that creates an array with this line inside it

Code: Select all

  put round(item 7 of line i of field 1,0) & return before tClose2
Then this line is used below the loop:

Code: Select all

  put max (tClose2) into field "Scale"
But it results with this error:
button "Calculate": execution error at line n/a (Function: is not a number) near "43"
How do I convert it to a number? Or calculate it differently?

espais
Posts: 14
Joined: Thu Jun 22, 2006 12:16 am

Post by espais » Tue Jul 28, 2009 9:04 am

Without see more code, I think that some value, like decimal symbols can produce an error. Check it step by step with a breakpoint inside the loop and see what values are processing.

Salut,
Josep

SparkOut
Posts: 2943
Joined: Sun Sep 23, 2007 4:58 pm

Post by SparkOut » Tue Jul 28, 2009 9:44 am

Also check for the item in question having no extra whitespace input in the original field, which would make it interpreted as a string, not a number.

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10043
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Post by FourthWorld » Tue Jul 28, 2009 3:30 pm

Is the field named "1,0"? If so, try putting that name in quotes (a good habit with all string literals):

put round(item 7 of line i of field "1,0") & "," before tClose2

I've also changed the return to a comma because the max function expects a comma-delimited list.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

Ron Zellner
Posts: 106
Joined: Wed May 31, 2006 9:56 pm
Contact:

Yes, commas, not lines

Post by Ron Zellner » Tue Jul 28, 2009 7:09 pm

That's what I ended up doing-

Code: Select all

   put round(item 7 of line i of field "MainData",1) &"," after Temp
I had been trying to get the max from the lines in the field and switched to using comma delimited data in a variable. I didn't know that max & min didn't work on lines.
The full code is in my reply to the previous posting: "revMedia ALPHA .. Financial Chart script".
I also changed the name of the data field from "1" to "MainData" to avoid confusion or error.

Post Reply