PDA

View Full Version : Variable problem



Pesticida
- 23rd May 2008, 19:21
Hi
I have a Variable Problem!

I have a Variable DataIn:

Datain VAR Byte [3]
Dummy VAR Byte [3]

now for example i want to use this to compare the bits and to found what bit have change:

For N = 0 to 2
For S = 0 to 7 ' My Bits
If Dummy [N].0[S] <> Datain[N].0[S] Then .......
Next S
Next N

But this is the wrong variable syntax (Unsupported array syntax!)
Thank You for any help

Regards Pesti

skimask
- 23rd May 2008, 20:39
Hi
I have a Variable Problem!
So your problem keeps changing?

http://www.picbasic.co.uk/forum/showthread.php?t=544&highlight=bits+bytes+arrays

Pesticida
- 23rd May 2008, 21:20
Thank you very much for the answer.

Now I understand!

You are the best!

regards Pesti

Pesticida
- 27th May 2008, 21:51
hi

Ok I try but I have a Problem!

I have this :
ML_Seconds Var Word [24]
ML_Verz Var Word [24]

Here is wrong too!

Timer_Int:
for M= 0 to 23
ML_Seconds.lowbyte[M] = ML_Seconds.lowbyte[M] + 1
Next M


and now I must to compare this two Words

for N = 0 to 23
If ML_Seconds.lowbyte[N] => ML_Verz.lowbyte[N] Then ...
Next N
But I compare now just the lowest two Bytes,I need the word Data

How I can do that ?!

Thanks
regards Pesti

skimask
- 28th May 2008, 17:16
ML_Seconds.lowbyte[M] = ML_Seconds.lowbyte[M] + 1
Not sure what the problem is, but are you sure you don't really want to have:

ML_Seconds.lowbyte[M] = ML_Seconds.lowbyte[ M + 1 ]

And this:

for N = 0 to 23
If ML_Seconds.lowbyte[N] => ML_Verz.lowbyte[N] Then ...
Next N
But I compare now just the lowest two Bytes,I need the word Data


Easy enough:


temp1 var byte
temp2 var byte
....................
temp1 = ML_Seconds.lowbyte[N]
temp2 = ML_Verz.lowbyte[N]
if temp1 => temp2 Then.....
Next N

Pesticida
- 28th May 2008, 18:58
Hi Skimask

thanks

Ok but what is when the value for ML_Seconds.lowbyte[N] is grater then 255 I must to compare the highbyte too!?

How is that are the two bytes in a word connected,i mean that when i increase the value in my ML_Seconds[N] and the value is going out of 255 then increase the highbyte automatically or not?

regards Pesti

skimask
- 29th May 2008, 13:55
Jeeze...then don't limit your inital compare to just the lowbyte...use the whole thing...

Pesticida
- 30th May 2008, 16:37
Jeeeze....Can not Help me ;-)

Jumper
- 30th May 2008, 16:51
But I am seriously confused... I understand you have a problem comparing variables

and I gather you want to compare 2 words from a word array


for N = 0 to 23
If ML_Seconds(N) => ML_Verz(N) Then ...
Next N


this should give you the N word from your array

/me

Pesticida
- 30th May 2008, 19:16
Ok


Thanks Jumper,can I word arrays just increase like this:

ML_Second var Word[24]
ML_Alarm var bit [24]
ML_End_Time var Word [24]

for S = 0 to 23
ML_Alarm[S] = 0
ML_Second[S] = 0
next S
ML_End_Time[0] = 10 ' Seconds
...
...
ML_End_Time[12] = 1000 ' Seconds
...
...
ML_End_Time[23] = 10000 ' Seconds
.......
.......
Tmr0_Int: 'Timer0 = 1 Seconds
TMR0IF = 0
for N = 0 to 23
If ML_Alarm[N]= 1 then ML_Second[N] = ML_Second[N] + 1 'Start the Counter for that ML
if ML_Second[N] = > ML_End_Time[N] then ML_Alarm[N]= 0: Gosub ......
Next N
Resume

Regards Pesti

Pesticida
- 30th May 2008, 21:25
hi

I found it! the problem was somewhere else .

All is ok with my word Variables :-)

Thank you all for help!

regards Pesti