Question about VAR
I need a little help with this. I trying to assign a three digit number to the VAR pulsDuration from a terminal program. For example when I send 170 from the terminal program with the code as it is now it displays back in the terminal program fine but doesn't work with Turn.Start(pulsDuration). When I remove the comment out from the line pulsDuration := 170 and comment out
pulsDiration := pDuration it works.
pulsDiration := pDuration it works.
CON
_clkmode = xtal1' + pll16x
_xinfreq = 5_000_000
OBJ
Comm : "FullDuplexSerial"
Turn : "ServoSteer"
VAR
pulsDuration long
DAT
pDuration long
PUB Main
Comm.start(31,30,%0000, 2_400)
bytefill(@pDuration[noparse][[/noparse]0], Comm.rx,1)
bytefill(@pDuration, Comm.rx,1)
bytefill(@pDuration, Comm.rx,1)
Comm.tx(byte[noparse][[/noparse]@pDuration[noparse][[/noparse]0]])
Comm.tx(byte[noparse][[/noparse]@pDuration])
Comm.tx(byte[noparse][[/noparse]@pDuration])
'pulsDuration := 170
pulsDuration := pDuration
Comm.rxtime(50)
Comm.tx($0D)
Comm.tx($0D)
Comm.rxtime(50)
Turn.Start(pulsDuration)

Comments
VAR
LONG PulsDuration, PDuration
Brian
Post Edited (truckwiz) : 12/7/2006 4:31:22 AM GMT
VAR
Long PulsDuration, PDuration
but I still get the same resaults.
You might have noticed that under VAR in the sample code I have VAR PulsDuration long not VAR long PulsDuration as it should be. Somehow this go reversed when I was cutting and pasting the sample code. It is in the proper order in the actual code.
Thanks
pulsDuration := 0 repeat idx from 0 to 2 pulsDuration := pulsDuration * 10 + (pDuration[noparse][[/noparse]idx] - '0')I'm pretty sure I have the syntax wrong for getting the ASCII value of zero, but I hope you understand my meaning.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
OS-X: because making Unix user-friendly was easier than debugging Windows
links:
My band's website
Our album on the iTunes Music Store
CON _clkmode = xtal1' + pll16x _xinfreq = 5_000_000 OBJ Comm : "FullDuplexSerial" Turn : "ServoSteer" Num : "Numbers" VAR long pulsDuration[noparse][[/noparse]2], pDuration[noparse][[/noparse]2] PUB Main Comm.start(31,30,%0000, 2_400) Num.Init bytefill(@pDuration[noparse][[/noparse]0], Comm.rx,1) bytefill(@pDuration[noparse][[/noparse]1], Comm.rx,1) bytefill(@pDuration[noparse][[/noparse]2], Comm.rx,1) Comm.tx(byte[noparse][[/noparse]@pDuration[noparse][[/noparse]0]]) Comm.tx(byte[noparse][[/noparse]@pDuration[noparse][[/noparse]1]]) Comm.tx(byte[noparse][[/noparse]@pDuration[noparse][[/noparse]2]]) pulsDuration := Num.FromStr(@pDuration[noparse][[/noparse]0],Num#DEC)*100+Num.FromStr(@pduration[noparse][[/noparse]1],Num#DEC)*10+Num.FromStr(@pduration[noparse][[/noparse]3],Num#DEC) Comm.tx($0D) Comm.tx($0D) Comm.rxtime(50) Turn.Start(pulsDuration)▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
OS-X: because making Unix user-friendly was easier than debugging Windows
links:
My band's website
Our album on the iTunes Music Store