BBC BASIC for Windows
Programming >> BBC BASIC language >> RND(X%)
http://bb4w.conforums.com/index.cgi?board=language&action=display&num=1444834557

RND(X%)
Post by TalkBASICToMe on Oct 14th, 2015, 2:55pm

I was going through the tutorials, when it said this:

"RND(X%) where X% is a positive integer value greater than 1. This will return a random number in the range 1 up to and including X%"

I tried that with some positive integer values of X and got the "missing bracket" error message. Obviously, I checked to see if there was a missing bracket and there wasn't.

Please advise.
Re: RND(X%)
Post by sbracken on Oct 14th, 2015, 3:50pm

After playing around, I think your problem must be that you are doing this:

Code:
PRINT RND(3%) 


rather than this:

Code:
PRINT RND(3) 


X% is an example of an integer variable, so the % should not be included in the RND statement unless it is part of a variable name:

Code:
X%=3
PRINT RND(X%) 


More info on variable types can be found here:

http://bbcbasic.co.uk/bbcwin/manual/bbcwin2.html#types

If this is not the problem, please post an example of the sort of code that throws the error.

Simon