This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2013-04-28 07:37:38

dinosaur1995
New Scratcher
Registered: 2013-04-18
Posts: 8

Repeat Until

I'd like to tell the user to input a digit from 1-9 (inclusive). The program is meant to repeat until the user has input a number from within that restrictions. However, the application will reject the input and not be recorded if the user gives an invalid input such as special characters or digits above 9 or below 0.

Unfortunately, it doesnt seem to work.......here is the code below....can someone help me out? thank you!


http://imgur.com/HmLVLhD

Offline

 

#2 2013-04-28 10:24:01

LeDerpy123
Scratcher
Registered: 2013-01-26
Posts: 100+

Re: Repeat Until

I don't think you need the "If answer if a number" factor.


http://www.winpenpack.com/en/e107_files/downloadthumbs/logo_mixxx.png

Offline

 

#3 2013-04-28 10:45:14

mathfreak231
Scratcher
Registered: 2012-10-24
Posts: 80

Re: Repeat Until

set [valid? v] to [false]
repeat until <(valid?) = [true]>
ask [Integer 1-9?] and wait
if <not <<(answer) = [0]> and <((answer) + (1)) = [0]>>> //This checks if it's a number or not.
if <<(answer) > [1]> or <(answer) = [1]>>
if <<(answer) < [9]> or <(answer) = [9]>>
if <((answer) mod (1)) = [0]>
set [valid? v] to [true]
end
end
end
end
end
I think that should work.

Last edited by mathfreak231 (2013-04-28 10:47:32)


~This sig is false~
I'm on teh wiki!

Offline

 

Board footer