issues with the zero element when using it with objects. They
compile just fine but something happens when it runs that causes the
first element to work incorrectly. For example, I tried to use 5 A2D
lines as an array and it would only work if I defined an array or 6
and did not use the zero index. I have not seen this problem when
using variables [i.e. Dim Array(4) As Byte]. Your code at the bottom
of this page should not have this problem because you skipped the
zero element. It was defined and does take up memory space, meaning
that you have defined 7 servos instead of 6.
--- In oopic@yahoogroups.com, ooPIC Tech Support <dennis.clark@...>
wrote:
>
> This is a case where the documentation isn't in step. V.6 compiler
> arrays are zero (0) indexed. to the best of my knowledge.
>
> DLC
>
> tuandung248 wrote:
> > hi all,
> > the document on the website at http://www.oopic.com/pgchap3.htm
says
> > that an array of objects always start at 1. however the compiler
> > 6.1.1 shows that index starts from 0.
> >
> > eg. declare: Dim Leg(6) as New oServo in the oopic IDE it says i
have
> > 7 oServo objects
> >
> > but then why is it when I declare for it to start at 1, the array
> > seems to start at 0 instead? why is this not consistent? in my
> > program below, after I call SetUp, when I want to move my Leg(1)
whose
> > IOLine is at 28, it moves the servo at IOLine 30, which is Leg(2)
(!!!)
> > Similarly (also in the Main), i call Leg(5) it moves the one that
is
> > supposed to be Leg(6). Everything is off by 1: change position
of
> > Leg(0) would show at Leg(1) and Leg(6) didn't do anything. I had
to
> > get around by naming the servos Leg1, Leg2, ..., Leg6 instead.
But
> > it's convenience to expand my code. Has anybody had a similar
problem?
> >
> > thanks in advance for your help and guidance,
> > HT
> >
> > Code:
> >
> > Dim Leg(6) as New oServo
> >
> > Sub Main()
> > Call Setup
> > Leg(1)=10
> >
> > End Sub
> >
> > Sub SetUp()
> > leg(2).InvertOut = cvTrue 'The servos on the right side
> > leg(4).InvertOut = cvTrue ' need to turn in reverse.
> > leg(6).InvertOut = cvTrue
> >
> > leg(1).Center = 24
> > leg(2).Center = 36
> > leg(3).Center = 27
> > leg(4).Center = 45
> > leg(5).Center = 33
> > leg(6).Center = 37
> >
> > leg(1).IOLine = 30
> > leg(2).IOLine = 28
> > leg(3).IOLine = 14
> > leg(4).IOLine = 12
> > leg(5).IOLine = 10
> > leg(6).IOLine = 8
> >
> > leg(1).Operate = cvTrue 'Turn the servos on.
> > leg(2).Operate = cvTrue
> > leg(3).Operate = cvTrue
> > leg(4).Operate = cvTrue
> > leg(5).Operate = cvTrue
> > leg(6).Operate = cvTrue
> > End Sub
> >
> >
> > ------------------------------------
> >
> > Yahoo! Groups Links
> >
> >
> >
> >
> >
> >
>
> --
> ------------------------------------------------------
> Dennis Clark ooPIC Tech Support
> www.oopic.com
> ------------------------------------------------------
>
------------------------------------
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/oopic/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
http://groups.yahoo.com/group/oopic/join
(Yahoo! ID required)
<*> To change settings via email:
mailto:oopic-digest@yahoogroups.com
mailto:oopic-fullfeatured@yahoogroups.com
<*> To unsubscribe from this group, send an email to:
oopic-unsubscribe@yahoogroups.com
<*> Your use of Yahoo! Groups is subject to:
No comments:
Post a Comment