View Full Version : incrementing question..

01-09-2008, 04:54 AM
hi all its been a while.. Ive been super busy. I could explain but it would take longer then the question i have.. so.. I wont:)

so I have this problem of not being able to find how to itterate a var. at least not in spin. Im use to something like

i = i ++

.. what im trying to do is find out how many pings I can do in 1 second using the ping.spin object. so im thinking something like

OBJ ''define the objects used.
rPing : "Ping"
Debug : "FullDuplexSerialPlus"

long i '' variable for incrementing

PUB Main ''define the repeat loop.
repeat until cnt := cnt + 12_000_000 ''using default clock speed
rPing.Ticks(16) '' using the ping object and passing pin 16 to it.
for i = i++ '' this is where I would increment i, but I dont know what operator to use..please advise



IC layout designer
Austin Texas

01-09-2008, 04:55 AM
hmm this thing does not seem to maintain spacing that is there when I wrote it..


IC layout designer
Austin Texas

01-09-2008, 05:03 AM
oh wait.. all i have to say is "i++"?


IC layout designer
Austin Texas

01-09-2008, 05:05 AM
You use:

i += 1

Which is the spin equivelent of the C/C++:


or the general


And to show the formatting - use the # on the toolbar of the reply/post form


Edit - Ooops. Was thinking in the wrong language..!

Post Edited (Javalin) : 1/8/2008 9:39:03 PM GMT

Nick Mueller
01-09-2008, 05:35 AM
> i=i+1

But it is i:= i + 1


Never use force, just go for a bigger hammer!

The DIY Digital-Readout for mills, lathes etc.:
YADRO (http://www.yadro.de)

01-09-2008, 05:37 AM
Thanks Nick - was thinking in the wrong languge (VB) - have updated!