LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
Glenn Boyce
- Posts: 137
- Joined: Thu Jul 24, 2008 11:22 pm
Post
by Glenn Boyce » Thu Oct 30, 2008 11:35 pm
The following script hangs up in line 13. I put everything into variables to make it easy to read but can't see whats wrong with the line that stops putting the calculated Qty into an item of a line in a table field:
Code: Select all
on mouseUp
if item 1 of line 6 of fld "Substrates" = "" then
answer "You need to enter substrate details before calculating adhesive requirements"
exit mouseup
else
put item 1 of line 6 of fld "substrates" into tlength
put item 1 of line 3 of fld "substrates" into twidth
Set itemdelimiter to tab
repeat with n = 1 to the number of lines in fld "Adhesives"
put item 7 of line n of fld "Adhesives" into tGSM
put item 4 of line n of fld "Adhesives" into tratioA
put item 6 of line n of fld "Adhesives" into tratioB
put tratioA + tratioB into tTotal
put tlength * twidth / 1000 * tGSM * tratioA / tTotal into item 9 of line n of fld "Adhesives"
put tlength * twidth / 1000 * tGSM * tratioB / tTotal into item 10 of line n of fld "Adhesives"
end repeat
end if
end mouseUp
-
SparkOut
- Posts: 2947
- Joined: Sun Sep 23, 2007 4:58 pm
Post
by SparkOut » Fri Oct 31, 2008 12:15 am
I thought it should work OK, so to try and see the problem in real I made a little test stack with a button and two fields, "substrate" and "adhesives" and pasted your code into the button.
I made dummy data in the fields and everything worked fine. Adding spaces here and there in the substrate and adhesive fields did not affect it, as Rev does its best to translate strings to numbers when performing calculations. So I can't tell what's wrong, but I would think it has to be a data issue. Either you have an empty item in the table, or some non-numeric data that can't be parsed as a number value, or your calculation is involving an illegal operation (eg div by zero, although that's not an appropriate error for adding tratioA and tratioB).
How has the data in the field been determined?
Was it cut and pasted? Maybe there are some legacy non printable characters that were pasted into the field?
-
Glenn Boyce
- Posts: 137
- Joined: Thu Jul 24, 2008 11:22 pm
Post
by Glenn Boyce » Fri Oct 31, 2008 3:52 am
I've got it working. I had the "set itemdelimiter" on the wrong line!! and I was getting a string in the variable for length and width.