Arrays and repeat loop
JacKal
Posts: 4
Hello there,
I'm fairly new to programming and totally new to microprocessors, but as a summer project from school I have started to get to know little bit about propeller.
Currently I am having trouples with arrays and repeat loops.
I just cant figure it out why this wont work. it reads the first value fine, but after that nothing. Is it some limitation on arrays that I cant use repeat loops to shorten my work, or have I misunderstood something?
Any help is greatly appreciated.
Post Edited (JacKal) : 7/8/2009 8:51:15 AM GMT
I'm fairly new to programming and totally new to microprocessors, but as a summer project from school I have started to get to know little bit about propeller.
Currently I am having trouples with arrays and repeat loops.
pub compare| i,j repeat i from 0 to 63 j := place ' just a public method that returns values between 0 and 8191 if left_wall[noparse][[/noparse] i ] == j return 1 else return 0
I just cant figure it out why this wont work. it reads the first value fine, but after that nothing. Is it some limitation on arrays that I cant use repeat loops to shorten my work, or have I misunderstood something?
Any help is greatly appreciated.
Post Edited (JacKal) : 7/8/2009 8:51:15 AM GMT
Comments
Please update your post.
You talk about an array. Where is the array in your code?
If this is what you wrote (including the indentation), I can't see a problem yet. Then you should provide the whole code.
Post Edited (MagIO2) : 7/8/2009 8:53:03 AM GMT
Actually, your code can be shortened to this and still does the same:
Nick
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Never use force, just go for a bigger hammer!
The DIY Digital-Readout for mills, lathes etc.:
YADRO
the problem is that what I am trying to shorten here is this:
left_wall[noparse][[/noparse] 0 ] == j
left_wall[noparse][[/noparse] 1 ] == j
left_wall[noparse][[/noparse] 2 ] == j
.
.
.
left_wall[noparse][[/noparse] 63 ] == j
to this:
left_wall[noparse][[/noparse] i ] == j
the i variable should change between 0-63, but I can only read the first value [noparse][[/noparse] 0 ], after that it wont work. if i use the manual method above, it works as it should.
Yea, but then you should tell your compare what location you want to inspect.
Read: you have to pass the index you want to inspect to compare -> Compare needs a parameter.
Nick
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Never use force, just go for a bigger hammer!
The DIY Digital-Readout for mills, lathes etc.:
YADRO
sorry if I'm not making much sense, but as English isn't my first language, I'm bit struggling to convey the meaning I'm after
Or maybe you want to know the index? Then you should return that.
Nick
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Never use force, just go for a bigger hammer!
The DIY Digital-Readout for mills, lathes etc.:
YADRO
thank you !
Post Edited (JacKal) : 7/8/2009 10:11:38 AM GMT