If and elsif error.
Author |
Message |
KevinW
|
Posted: Sat Sep 08, 2007 12:16 pm Post subject: If and elsif error. |
|
|
Can anyone help with this program? I haven't used Turing in a while, but i'm trying to create a randomized password maker. Here's the script, the problem is that the "word (i)= num/letter" isn't allowed.
code: | var word : string
var letter : string
var num, num2, choose, number : int
for i : 1 .. 10
randint (num, 0, 9)
randint (num2, 0, 26)
letter := intstr (num2)
randint (choose, 0, 1)
if choose = 0 then
word (i) := num
elsif choose = 1 then
word (i) := letter
end if
end for
put "Your new randomized password is ", word |
[/quote] |
|
|
|
|
|
Sponsor Sponsor
|
|
|
HeavenAgain
|
Posted: Sat Sep 08, 2007 12:40 pm Post subject: Re: If and elsif error. |
|
|
something like?
Turing: |
var word : string := ""
var letter : char
var num, num2 : int
for i : 1 .. 10
randint (num, 0, 9)
randint (num2, 65, 90)
if num > 4 then %% instead of having choose, just use the previous num, 0 - 4 its the same chance of getting 5-9 so its 50 - 50
letter := chr (num2 )
else
letter := intstr (num )
end if
word := word + letter
end for
put word
|
could be a simpler way o_o but i cant think on top of my head right now
your problem was, trying to add an int to a string, which is not allowed, so "cast" the int to a char or a string then add on to itself |
|
|
|
|
|
Clayton
|
Posted: Sat Sep 08, 2007 7:50 pm Post subject: RE:If and elsif error. |
|
|
or just...
code: |
...
word (i) := intstr (num) %or letter, whatever it is
...
|
|
|
|
|
|
|
|
|