Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

PICBASIC-L Problem with arrays

18 views
Skip to first unread message

Peter Meyer

unread,
Nov 14, 2000, 3:47:03 AM11/14/00
to picba...@qunos.net
If I declare an array (i.e. test var byte[10]) and other byte or bit
variables, some of the byte and bit variables change their values when I
write to the array. As soon as I declare the variables as word it works just
fine...
Any ideas??

Thanks
Peter

-------------------------
PIC BASIC Mailing List
Crownhill Associates Ltd
www.crownhill.co.uk
www.picbasic.co.uk
-------------------------

To remove yourself from this list, please send email to
majo...@qunos.net
with this text in its body: unsubscribe picbasic-l

Timothy Box

unread,
Nov 14, 2000, 2:52:29 PM11/14/00
to picba...@qunos.net

Peter


Make sure you read the info in the manual about the numbering in arrays.

test var byte[10] will declare a 10 byte array

test[0] is the first byte in that array and test[9] is the last.

Tim

(London England)

John Lighton

unread,
Nov 15, 2000, 1:13:56 AM11/15/00
to picba...@qunos.net
<snip>
Actually I beleive a var byte[10] is an eleven byte array elements 0 through
10.
<snip>

Belief doesn't hack it, pal. If, rather than believing, you will read the
manual, you will see that var byte[10] is a 10 byte array, numbered 0 to 9.
Try counting your toes, starting with zero.

Yikes.

John

Peter Meyer

unread,
Nov 15, 2000, 3:11:35 AM11/15/00
to picba...@qunos.net
Tim

I'm not even using the whole array. I also tried to alter the size ([8] ,
[12] , [11] ...) - still the same problem.
What really makes me nervous is that the whole thing works perfect when I
declare all the other variables as words!
The program is about 4k words in size and I'm using 18 word variables and
two arrays (one has 10 bytes the other 16 bytes).

Peter


>
>
>
> Peter
>
>
> Make sure you read the info in the manual about the numbering in arrays.
>
> test var byte[10] will declare a 10 byte array
>
> test[0] is the first byte in that array and test[9] is the last.
>
> Tim
>
> (London England)
>
>
>
>
> > -----Original Message-----
> > From: owner-pi...@ns.qunos.net
> > [mailto:owner-pi...@ns.qunos.net]On Behalf Of Peter Meyer
> > Sent: 14 November 2000 08:05
> > To: picba...@qunos.net
> > Subject: PICBASIC-L Problem with arrays
> >
> >
> > If I declare an array (i.e. test var byte[10]) and other byte or bit
> > variables, some of the byte and bit variables change their values when I
> > write to the array. As soon as I declare the variables as word it
> > works just
> > fine...
> > Any ideas??
> >
> > Thanks
> > Peter
> >

Reg Smith

unread,
Nov 15, 2000, 5:52:20 AM11/15/00
to picba...@qunos.net
Peter,

Are you sure that you are writing a byte to the array?. If you have another
variable defined as a word, and the value in this variable is 255 or less,
you may think that you could safely write this value to the byte array. This
is not the case, the value will still need to be stored in a word array.

I came across this by mistake a while ago.

Regards


Reg Smith

Wayne

unread,
Nov 15, 2000, 8:52:38 PM11/15/00
to picba...@qunos.net
We could stop half the posts on here if we would read the manual.
I stand corrected and appoligize.
I hope your Highness can forgive!

----- Original Message -----
From: "John Lighton" <lig...@sablesys.com>
To: <picba...@qunos.net>
Sent: Tuesday, November 14, 2000 11:29 PM
Subject: Re: PICBASIC-L Problem with arrays


> <snip>
> Actually I beleive a var byte[10] is an eleven byte array elements 0
through
> 10.
> <snip>
>
> Belief doesn't hack it, pal. If, rather than believing, you will read the
> manual, you will see that var byte[10] is a 10 byte array, numbered 0 to
9.
> Try counting your toes, starting with zero.
>
> Yikes.
>
> John
>
>
>

Peter May

unread,
Nov 15, 2000, 10:07:59 PM11/15/00
to picba...@qunos.net
Maybe I am wrong here and I hope I am and someone points it out but most of
the printed stuff seems to be in assembler (or whatever it is called) and
the likes of me might as well row up a crocodile infested Queensland river
in a barbed wire canoe without a paddle and would find that easier than
trying to learn assembler..
0 new messages