4-331
Detailed Explanation of Functions
4MELFA-BASIC IV
Rnd
[Function]
Generates a random number.
[Format]
[Terminology]
<Equation>
Specifies the initial value of random numbers. If this value is set to 0, subsequent random numbers
will be generated without setting the initial value of random numbers.
<Numeric Variable>
A value in the range of 0.0 to 1.0 will be returned.
[Reference Program]
1 DIM MRnd(10)
2 C1=Right$(C_Time,2)
' Initializes random numbers using the clock.
3 MRndBS=Cvi(C1))
' in order to obtain different sequence of numbers.
4 MRnd(1)=Rnd(MRndBS)
' Sets the initial value of random numbers and extracts the first random
number.
5 For M1=2 TO 10
' Obtain other nine random numbers.
6 MRnd(M1)=Rnd(0)
7 Next M1
[Explanation]
(1) Initializes random numbers using the value provided by the argument and extracts a random number.
(2) If the equation provided as the argument evaluates to 0, initialization of random numbers will not take
place and the next random number will be extracted.
(3) When the same value is used to perform initialization of random numbers, identical random number
sequence will be obtained.
Right$
[Function]
Obtains a string of the specified length starting from the right end.
[Format]
[Reference Program]
1 C1$=Right$("ABCDEFG",3)
' "EFG" is assigned to C1$.
[Explanation]
(1) Obtains a string of the specified length starting from the right end.
(2) An error will be generated if the value of the second argument is a negative value or is longer than the
first string.
(3) It is not possible to describe a function that contains an argument in <Character String> and <Equation>.
If such a function is described, an error will be generated during execution.
[Reference]
,
<Numeric Variable>=Rnd(<Equation>)
<Character String Variable >=Right$(<Character String>, <Equation>)