I am new to programing in turring and I'm trying to make a custom dice roller app that first asks the user how many dice the user wants followed by the amount of sides the die has.
since I don't want the program to crash when the user accidentally inputs a non-numeric input I used the strintok command.
the problem is that this makes me have to put all of the error messages at the end of the code because of the way that the else then statments are which is making it very dificult to debug the code
does anyone have anyway I could put the error message before the rest of the code?
Quote:
%simple dice
%May 12 2014
loop
locate (1,1)
%sets the variables
var input : string
var in2 : string
var i : int
var final : int
var c : int
%ask for total dice
loop
put "How many dice are you rolling?"
get input
if strintok (input)
then
c:= strint (input)
else
put "That is not a number, try again."
end if
end loop
%asks for total sides
put "How many sides does the die have?"
loop
get in2
if strintok (in2) then
i:= strint (in2)
else
put "That is not a number, try again?"
%roll's die
put "Rolling..."
for counter : 1 .. c %counts down how many dice to roll
randint (final, 1, i)
put final
%outputs
if final = i
then
put "Critical Hit"
end if
if final = 1
then
put "Critical Miss"
end if
%Ending Cleanup
delay (100)
end for
put"###################################" %makes for cleaner seperation
end if
end loop