Something is wrong with my code.
Author |
Message |
ProgrammedAlec
|
Posted: Tue Nov 11, 2008 9:41 pm Post subject: Something is wrong with my code. |
|
|
so me and a friend were experimenting, trying to figure out how to create an accurate matrix text-fall.
here is the code he sent me which I "think" is somewhat completed, but when I try to run it, it gives me an error on this part:
var four, five, six, seven, eight, nine, ten, eleven, twelve: int
right on the FOUR. I don't know why.
If I can get to run this properly I can continue to work with this but I cant run it for some reason!
Can anyone help me out?
PS. This forum has friendly users.
code: | var one: int
var two: int
var three: int
var four: int
var five: int
var six: int
var seven: int
var eight: int
var nine: int
var ten: int
var eleven: int
var twelve: int
var four, five, six, seven, eight, nine, ten, eleven, twelve: int
loop
randint (one, 0, 1000)
randint (two, 0, 1000)
randint (three, 0, 1000)
randint (four, 0, 1000)
randint (five, 0, 1000)
randint (six, 0, 1000)
randint (seven, 0, 1000)
randint (eight, 0, 1000)
randint (nine, 0, 1000)
randint (ten, 0, 1000)
randint (eleven, 0, 1000)
randint (twelve, 0, 10)
end loop |
Mod edit: Remember to use [ code ] [ /code ] tags when posting code! |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
[Gandalf]
![](http://compsci.ca/v3/uploads/user_avatars/189297994e4c716fec7f1.png)
|
Posted: Tue Nov 11, 2008 9:46 pm Post subject: RE:Something is wrong with my code. |
|
|
You're redeclaring four and all the other 'number' variables. What's the purpose of the twelve previous lines if you have that one there?
Also, before continuing I strongly suggest you look into arrays and for loops. |
|
|
|
|
![](images/spacer.gif) |
ProgrammedAlec
|
Posted: Tue Nov 11, 2008 9:57 pm Post subject: RE:Something is wrong with my code. |
|
|
Okay, now here's what I got after Editing according to half of Tony's details.
code: | var four: int
var five: int
var six: int
var seven: int
var eight: int
var nine: int
var ten: int
var eleven: int
var twelve: int
var four, five, six, seven, eight, nine, ten, eleven, twelve: int
loop
randint (four, 0, 1000)
randint (five, 0, 1000)
randint (six, 0, 1000)
randint (seven, 0, 1000)
randint (eight, 0, 1000)
randint (nine, 0, 1000)
randint (ten, 0, 1000)
randint (eleven, 0, 1000)
randint (twelve, 0, 10)
end loop |
|
|
|
|
|
![](images/spacer.gif) |
BigBear
|
Posted: Tue Nov 11, 2008 10:45 pm Post subject: Re: Something is wrong with my code. |
|
|
No he means you declare your variables one on each line as an int. Then you declare them again. |
|
|
|
|
![](images/spacer.gif) |
Tony
![](http://wiki.compsci.ca/images/f/f4/OniTony.gif)
|
Posted: Wed Nov 12, 2008 12:00 am Post subject: Re: RE:Something is wrong with my code. |
|
|
ProgrammedAlec @ Tue Nov 11, 2008 9:57 pm wrote: according to half of Tony's details
What? |
Tony's programming blog. DWITE - a programming contest. |
|
|
|
![](images/spacer.gif) |
[Gandalf]
![](http://compsci.ca/v3/uploads/user_avatars/189297994e4c716fec7f1.png)
|
Posted: Wed Nov 12, 2008 2:32 am Post subject: Re: Something is wrong with my code. |
|
|
Ya I just banged my head against my keyboard and closed the page. Another case of your name popping up where by all means it doesn't make sense! Perhaps we all truly are Tony clones.
Sorry Alec, but you're making the same mistake again in your new code. Try removing the first 9 lines of your new code, they're just repeats of your later variables. |
|
|
|
|
![](images/spacer.gif) |
Euphoracle
![](http://compsci.ca/v3/uploads/user_avatars/11170373664bf5f25f636f1.png)
|
Posted: Wed Nov 12, 2008 6:50 am Post subject: RE:Something is wrong with my code. |
|
|
Your title says "Tony's Clone"... People are silly (: |
|
|
|
|
![](images/spacer.gif) |
sierius
|
Posted: Mon Nov 17, 2008 9:24 pm Post subject: RE:Something is wrong with my code. |
|
|
What are you trying to get the script to do ? You could use arrays if you wanted.
code: |
%% decales the variable number
%% the variable number holds arrays 1 to 12
var numbers : array 1 .. 12 of int
%% assign each array with a rand int from 0 - 1000
for i : 1.. upper (numbers)
randint (numbers(i), 0, 1000)
end for
%% this is to check if it worked
%% shows what number value was assigned
%% to each array
for i : 1 .. upper (numbers)
put " The number in the array ", i," is : ", numbers(i)
end for
|
Hope this helps.
You question would be easier to understand if you stated what the script is for.
Edit : Forgot to code
Edit : One more note
By changing the value in
code: |
var numbers : array 1 .. 12 of int
|
currently represented by '12'
You change the entire script in terms of how many numbers will be inserted to be randomized and printed.
Ie. You input
code: |
var numbers : array 1 .. 20 of int
|
20 numbers will be given a randomized value and which be printed |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
andrew.
|
Posted: Tue Nov 18, 2008 6:17 pm Post subject: RE:Something is wrong with my code. |
|
|
You are declaring your variables (var one : int) and then after you go to 12, you redeclare it again which causes an error. Take out some of the declarations so that there is one var one, one var two, etc. Also, instead of doing that, I highly recommend you look into arrays. Just head over to the Turing tutorials section. |
|
|
|
|
![](images/spacer.gif) |
|
|