code help
Posted: Tue Mar 15, 2016 12:31 pm
The file is attached, takes in 9 names and match attendance. I can't get it to output to = output 1, and output 2 error at line 51. button "Button 1": execution error at line 51 (Chunk: error in range start expression), char 1. Anyone like to help me, please. Here is the code for this attempt.
global nameOfperson, gigsGone, calc, money, ticket?, winner1, winner2
on mouseUp
declareVariables
repeat with index=1 to 9
nameOf
NoOfGigs
calculateLoyalFanness
finalOutput
end repeat
end mouseUp
on declareVariables //Declareing variables and emptying field
put "" into nameOfperson
put 0 into NoOfGigs
put empty into field "output 1"
put empty into field "output 2"
put 1 into index
end declareVariables
on nameOf //Their information
ask "What is your first name?"
if the result = "Cancel" then exit to top
put it into nameOfperson[index]
end nameOf
on NoOfGigs //The number of gigs they have been to
ask "How many of their gigs have you been to?"
if the result = "Cancel" then exit to top
put it into gigsGone[index]
if gigsGone[index] >2 and gigsGone[index] <6 and gigsGone[index] is an integer then
else
answer "Sorry, that number of gigs is not viable for loyal fandom."
end if
end NoOfGigs
on calculateLoyalFanness //Calculate the price of thier ticket
if gigsGone[index] = 3 then
put 0.7 into calc
end if
if gigsGone[index] = 4 then
put 0.6 into calc
end if
if gigsGone[index] = 5 then
put 0.5 into calc
end if
put 15 * calc into money[index]
end calculateLoyalFanness
on finalOutput //Output the information that really matters
put nameOfperson[index]& "the cost of your final concert ticket with the appropriate discount is £"&money[index]& "" into line index of field "output 1"
//put ""&nameOfperson[index]&"the cost of your final concert ticket with the appropriate discount is £" &money[index]& "" into line index of field "output 1"
repeat until winner1 <> winner2
put random(9) into winner1
put random(9) into winner2
end repeat
put nameOfperson[winner1] into line 1 of field "output 2"
put nameOfperson[winner2] into line 2 of field "output 2"
end finalOutput
global nameOfperson, gigsGone, calc, money, ticket?, winner1, winner2
on mouseUp
declareVariables
repeat with index=1 to 9
nameOf
NoOfGigs
calculateLoyalFanness
finalOutput
end repeat
end mouseUp
on declareVariables //Declareing variables and emptying field
put "" into nameOfperson
put 0 into NoOfGigs
put empty into field "output 1"
put empty into field "output 2"
put 1 into index
end declareVariables
on nameOf //Their information
ask "What is your first name?"
if the result = "Cancel" then exit to top
put it into nameOfperson[index]
end nameOf
on NoOfGigs //The number of gigs they have been to
ask "How many of their gigs have you been to?"
if the result = "Cancel" then exit to top
put it into gigsGone[index]
if gigsGone[index] >2 and gigsGone[index] <6 and gigsGone[index] is an integer then
else
answer "Sorry, that number of gigs is not viable for loyal fandom."
end if
end NoOfGigs
on calculateLoyalFanness //Calculate the price of thier ticket
if gigsGone[index] = 3 then
put 0.7 into calc
end if
if gigsGone[index] = 4 then
put 0.6 into calc
end if
if gigsGone[index] = 5 then
put 0.5 into calc
end if
put 15 * calc into money[index]
end calculateLoyalFanness
on finalOutput //Output the information that really matters
put nameOfperson[index]& "the cost of your final concert ticket with the appropriate discount is £"&money[index]& "" into line index of field "output 1"
//put ""&nameOfperson[index]&"the cost of your final concert ticket with the appropriate discount is £" &money[index]& "" into line index of field "output 1"
repeat until winner1 <> winner2
put random(9) into winner1
put random(9) into winner2
end repeat
put nameOfperson[winner1] into line 1 of field "output 2"
put nameOfperson[winner2] into line 2 of field "output 2"
end finalOutput