Basically, the app will be used in my volunteer work as a radio operator with the sea rescue. It accepts inputs of multiple vessels, with their names and estimated return times (ETRs). So far the app works exactly as expected for the first vessel input. That is, when a vessel's ETR equals system time, an answer dialog allow a response of "Out" or "Returned". If Returned, "Back" is reported on the table and no more action for that vessel. If it is still Out, ETR is incremented by 10 minutes and the ETR shows in orange. And so on to the next phase as shown in the script.
However, when I input a second vessel, the thing goes haywire in that when the time is triggered, the ETR field in the table goes orange at the same time as the dialog appears, before I have responded. Even more puzzling, I can ignore the dialog and the sequence continues, changing to red after 10 minutes and then to "ALERT" without any dialog inputs stating what the vessel status actually is. I wonder if it is a logic error, or I am asking LiveCode to do something that it can't. Anyway, here is the script and I would be grateful for some help with it. I apologise if it is too long to be posting here.
Thanks
Don
Code: Select all
local B, V, x, y, tResult
/* Vessels use 24 hour clock, so 12 hour time set to false in card script
Vessel estimated return (ETR) in V[x][1] and name in V[x][2]
Vessel status (Out or Returned) in B[x] */
on mouseUp
if x >= 1 then
add 1 to x
else
put 1 into x
end if
put field "Hour" into V[x][1]
put ":" after V[x][1]
put field "Min" after V[x][1] -- format nn:nn
put field "Name" into V[x][2]
put "Out" into B[x] -- we log vessel as having left
put V[x][2] into line x of field "Vessel" --Names and times in table
put V[x][1] into line x of field "ETR"
put "Mariner " into field "Name" -- default prefix for our area
put empty into field "Hour"
put empty into field "Min"
set forecolor of line x of field "ETR" to black
focus on field "Name"
put " " after character 7 of field "Name"
send checkTime to me in 1 sec
end mouseUp
on checkTime
repeat with y = 1 to x
If V[y][1] = system time and B[y] is not "Back" then
answer V[y][2] with "Out" and "Returned"
put it into tResult
switch B[y]
case "Out"
if tResult is "Returned" then
backIn
else
put "Call1" into B[y]
set forecolor of line y of field "ETR" to orange
addTen
end if
break
case "Call1"
if tResult is "Returned" then
backIn
else
set forecolor of line y of field "ETR" to red
addTen
end if
break
case "Call2"
if tResult is "Returned" then
backIn
else
put "ALERT" into line y of field "ETR"
Beep 10
answer "Call Coordinator" with OK
Put "Back" into B[y]
end if
break
end switch
end if
end repeat
send checkTime to me in 1 sec
end checkTime
on addTen
put V[y][1] into tTime
put char 1 of tTime into tHour
put char 2 of tTime after tHour
put char 4 of tTime into tMin
put char 5 of tTime after tMin
Add 10 to tMin
if tMin > 60
then
add 1 to tHour
subtract 60 from tMin
if tMin < 10 then put 0 before tMin
end if
put tHour into tTime
put ":" after tTime
put tMin after tTime
put tTime into V[y][1]
end addTen
on backIn
put "Back" into B[y]
set forecolor of line y of field "ETR" to black
put "Back" into line y of field "ETR"
end backIn