This is just one of many possible solutions:
when green flag clicked
set [index v] to [1]
set [product code v] to []
set [total 1 v] to [0]
set [total 2 v] to [0]
set [total v] to [0]
ask [Enter a 12 digit product code:] and wait
change [product code v] by (answer)
if <(length of (product code)) = [12]> then
repeat (6)
set [total 1 v] to ((total 1) + (letter (index) of (product code)))
change [index v] by (1)
set [total 2 v] to ((total 2) + (letter (index) of (product code)))
change [index v] by (1)
end
set [total v] to (((total 1) * (3)) + (total 2))
if <((total) mod (10)) = [0]> then
say [Valid product code!]
else
say [Invalid product code!]
end
else
say [Please enter a 12 digit number!]
end