Changing Array Values En Masse
Author |
Message |
Dragon20942

|
Posted: Thu Dec 23, 2010 3:31 pm Post subject: Changing Array Values En Masse |
|
|
What is it you are trying to achieve?
I am currently trying to change the values of an array in a similar manner as initializing, only its not initialization.
What is the problem you are having?
Evidently there is some sort of syntax error in my attempts to reassign array values.
Describe what you have tried to solve this problem
I tried changing my syntax. I also came to this site
Post any relevant code
Turing: |
type wave :
record
enemyLives : array 0 .. 19 of int
enemyX : array 0 .. 19 of int
enemyY : array 0 .. 19 of int
enemyType : array 0 .. 19 of int
end record
var waves : array 1 .. 75 of wave %75 waves
waves (1).enemyLives := (2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
waves (1).enemyX := ((maxx div 6), (maxx div 6) * 2, (maxx div 6) * 3, (maxx div 6) * 4, (maxx div 6) * 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
waves (1).enemyY := (((maxy - 100) div 5) * 4 + 100, ((maxy - 100) div 5) * 3 + 100, ((maxy - 100) div 5) * 2 + 100, ((maxy - 100) div 5) * 3 + 100, ((maxy - 100) div 5) * 1 + 100, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
waves (1).enemyType := (1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
|
Do not ask about enemyType.
Please specify what version of Turing you are using
4.1.1
|
|
|
|
|
 |
Sponsor Sponsor

|
|
 |
Tony

|
Posted: Thu Dec 23, 2010 4:11 pm Post subject: RE:Changing Array Values En Masse |
|
|
The init syntax might be available only for the initialization step. But it looks like you have very well defined patterns for the initial values (n*1, n*2, n*3...), so a few clever for-loops will get all of your 75 waves initialized (you don't really want to type out 300 lines of numbers, do you?). |
Tony's programming blog. DWITE - a programming contest. |
|
|
|
 |
Dragon20942

|
Posted: Sat Jan 01, 2011 12:36 pm Post subject: RE:Changing Array Values En Masse |
|
|
So essentially, I make predefined values for the X and Y and use i (in a for statement) to declare them based on multiplication? Lives and type will be a little trickier because they aren't necessarily in a patterned order.
Still, is there any way to change the values of the whole array? I think that is the easiest, most defined way out of this mess. |
|
|
|
|
 |
Tony

|
Posted: Sat Jan 01, 2011 2:13 pm Post subject: RE:Changing Array Values En Masse |
|
|
There usually are ways of mathematically generating all kinds of data and patterns, even if it gets to be as ridiculous as "digits of Pi after 42,000th place"
You can try using init, but it has its limitations. Read the documentation and experiment with using it, to see if it does what you want. Otherwise for-loops are the way to go. |
Tony's programming blog. DWITE - a programming contest. |
|
|
|
 |
Dragon20942

|
Posted: Sat Jan 01, 2011 2:47 pm Post subject: RE:Changing Array Values En Masse |
|
|
So your saying that there is no other commands other than init that can change all the values in an array; the other option (than individually changing them) is to use for?
With init, I can do this once, but the "record" invalidates this.
Ill take your advice and use for-loops and if there is no pattern on some variables, I'll just declare them manually. Thanks for the help  |
|
|
|
|
 |
|
|