I don't understand this error I'm getting
Posted: Wed Jul 10, 2019 4:29 pm
I have a datagrid and a button. In the daragrid I have about 9 rows of data that i need to work with. in the putton is the following script
I'm getting this error
button "Cut": execution error at line 25 (Operators /: error in left operand), char 1
If you look in the script there is this line:
answer cutlist_tWeight
and it answers with the correct number.
Now. If I click the button again without selecting new line I don't get the error and it works as intended.
Am I missing something obvious or is this a bug, I am still running LiveCode 8.1.10
Code: Select all
on mouseUp
if cutlist_ItemStatus = "Cut" then
answer "Already Cut"
BREAK
end if
--lock screen
put the dgHilitedLines of group "DataGridPartsCutList" into theLines
repeat for each item tLine in theLines
put the dgDataOfLine[tLine] of group "DataGridPartsCutList" into theDataA
put theDataA["id"] into cutlist_tID
put theDataA["qt"] into cutlist_tQT
put theDataA["weight"] into cutlist_tWeight
put theDataA["Piece_mark"] into cutlist_tPcMk
answer cutlist_tWeight
put cutlist_tWeight / cutlist_tQT into cutlist_tWeight ----This line is where the error happens
if cutlist_tID is not empty then
if cutlist_tQT <> "1" then
answer "How many did you cut?" & cr & "PcMk: " & cutlist_tPcMk with "All" and "Some"
if it is "Some" then
ask "How many did you cut? (MAX: " & cutlist_tQT - 1 & ")"
put it into tNumberToCut
if tNumberToCut > cutlist_tQT - 1 then
answer "Invalid Quantity"
BREAK
else
send dbOpen to stack "MFC Tracking System"
put cutlist_tQT - tNumberToCut into tLeftToCut
Put "SELECT material_group, job, lot, sequence, piece_mark, weight, qt, shape, main_mark, dimension, width, grade, length, station, item_status, cutlist_done, material_group_comment, pcmk_comment FROM parts_cutlist WHERE id = '" & cutlist_tID & "'" into tSQL
put revDataFromQuery(comma, cr, gConnectionID, tSQL) into tLeftToCut2
put tLeftToCut into item 7 of tLeftToCut2
put tLeftToCut * cutlist_tWeight into item 6 of tLeftToCut2
replace "," with "','" in tLeftToCut2
put "INSERT INTO parts_cutlist (material_group, job, lot, sequence, piece_mark, weight, qt, shape, main_mark, dimension, width, grade, length, station, item_status, cutlist_done, material_group_comment, pcmk_comment) VALUES ('" & tLeftToCut2 & "')" into tSQL
revExecuteSQL gConnectionID, tSQL
put "UPDATE parts_cutlist SET item_status = 'Cut', qt = '" & tNumberToCut & "', weight = '" & tNumberToCut * cutlist_tWeight & "' WHERE id = '" & cutlist_tID & "'" into tSQL
put "SELECT count(id) FROM parts_cutlist WHERE lot = '" & tSL & "' and item_status <> 'Cut'" into cSQL
put "INSERT INTO parts_cutlist_log (cutlistID, user, action, dateandtime) VALUES ('" & cutlist_tID & "', '" & qcUser & "', 'Cut', now());" into lSQL
revExecuteSQL gConnectionID, tSQL
put revDataFromQuery(tab, cr, gConnectionID, cSQL) into tData
revExecuteSQL gConnectionID, lSQL
if tData = 0 then
put "UPDATE parts_cutlist SET cutlist_done = '1' WHERE lot = '" & tSL & "'" into cdSQL
revExecuteSQL gConnectionID, cdSQL
end if
send dbClose to stack "MFC Tracking System"
end if
else
send dbOpen to stack "MFC Tracking System"
put "UPDATE parts_cutlist SET item_status = 'Cut' WHERE id = '" & cutlist_tID & "'" into tSQL
put "SELECT count(id) FROM parts_cutlist WHERE lot = '" & tSL & "' and item_status <> 'Cut'" into cSQL
put "INSERT INTO parts_cutlist_log (cutlistID, user, action, dateandtime) VALUES ('" & cutlist_tID & "', '" & qcUser & "', 'Cut', now());" into lSQL
revExecuteSQL gConnectionID, tSQL
put revDataFromQuery(tab, cr, gConnectionID, cSQL) into tData
revExecuteSQL gConnectionID, lSQL
if tData = 0 then
put "UPDATE parts_cutlist SET cutlist_done = '1' WHERE lot = '" & tSL & "'" into cdSQL
revExecuteSQL gConnectionID, cdSQL
end if
send dbClose to stack "MFC Tracking System"
end if
end if
end if
end repeat
put empty into cutlist_tID
send updateDGCutList to card "parts cutlists"
send updateDGPartsCutList to card "parts cutlists"
unlock screen
end mouseUp
button "Cut": execution error at line 25 (Operators /: error in left operand), char 1
If you look in the script there is this line:
answer cutlist_tWeight
and it answers with the correct number.
Now. If I click the button again without selecting new line I don't get the error and it works as intended.
Am I missing something obvious or is this a bug, I am still running LiveCode 8.1.10