splitting up an Array[s]
I am trying to take a number from 0 - 100 and fill an array with it. i.e
How do i write a loop using a bit shif?
help me please...
long stringdata <------array long X <------varable Pub Start X = 100 loop: stringdata[noparse][[/noparse]0] := 1 stringdata := 0 stringdata := 0 end loop
How do i write a loop using a bit shif?
help me please...

Comments
2) There are no labels in Spin. Read the description of the REPEAT statement. This combines the FOR / NEXT loop and the DO / LOOP statements in Parallax Basic.
I want to do a repeat so that the variable X is broke up into an array named data
x = 100 ||| data [noparse][[/noparse] 0 ] <-||| data [noparse][[/noparse] 1 ] <--|| data [noparse][[/noparse] 2 ] <---|so that when the "repeat until" is done I will have this --> data [noparse][[/noparse] 0 ] = 1 and data [noparse][[/noparse] 1 ] = 0 and data [noparse][[/noparse] 2 ] = 0
Post Edited (grasshopper) : 3/7/2008 9:54:12 PM GMT
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Paul Baker
Propeller Applications Engineer
Parallax, Inc.
Post Edited (Paul Baker (Parallax)) : 3/7/2008 11:12:34 PM GMT
All i want to do is put a three digit number like 100 into an array so that i can display this on my LCD screen. Why is it so hard to program the propeller. I figured i could do this but i have no such luck: Thank god you are all here...
con esc = $1B 'Escape code cr = $0D 'Carriage Return code lf = $0A 'Line Feed code eos = $FF 'End of string code eog = $FF 'End of graphics code space = $20 'Space character code max_duty = 100 pwm1pin = 7 VAR long stringdata[noparse][[/noparse] 7 ] long x long number long stringdata1[noparse][[/noparse] 4 ] obj LCD : "LCDDEMO2" pwm1 : "pwmasm" pub main repeat DISPLAY PULS_STIRR waitcnt(100_000_000 + cnt) PUB DISPLAY | Y LCD.init 'Initialize the display lcd.clS RETURN PUB PULS_STIRR | Y pwm1.start(pwm1pin) pwm1.SetPeriod(1_000_000) 'high period will allow for a slow motor repeat x from max_duty to 100 'linearly advance parameter from 0 to 100 pwm1.SetDuty(x) waitcnt(1_000_000 + cnt) 'wait a little while before next update repeat y from 0 to 3 stringdata1[noparse][[/noparse] Y ] := (x ~> Y - 1) ' pack the characters into a long lcd.cls lcd.writeout(stringdata1[noparse][[/noparse] 0 ]) lcd.writeout(stringdata1[noparse][[/noparse] 1 ]) lcd.writeout(stringdata1[noparse][[/noparse] 2 ]) returnPUB dec(value) | i '' Print a decimal number if value < 0 -value out("-") i := 1_000_000_000 repeat 10 if value => i out(value / i + "0") value //= i result~~ elseif result or i == 1 out("0") i /= 10but instead of using the out method, you would assign it to your·data array.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Paul Baker
Propeller Applications Engineer
Parallax, Inc.
Plenty of scope to optimise the code there, but shown longhand for clarity.
If you want ascii characters in yourArray[noparse]/noparse rather than numbers ...
Post Edited (hippy) : 3/8/2008 2:48:32 PM GMT
I figured it out using both of your examples .