structure variable acess problem
Moderators: David Barker, Jerry Messina
structure variable acess problem
Here is my sample program. Program compile ok.
Structure ttemp
id As Byte
ltemp As Byte
htemp As Byte
End Structure
Dim sample(13) As ttemp
Dim cnt As Byte
main:
For cnt = 0 To Bound(sample)
sample(cnt).id =10
sample(cnt).ltemp = 10
sample(cnt).htemp = 10
Next
my problem is only element 0 of sample hold value of 10. others are blank
where is my mistake .
Structure ttemp
id As Byte
ltemp As Byte
htemp As Byte
End Structure
Dim sample(13) As ttemp
Dim cnt As Byte
main:
For cnt = 0 To Bound(sample)
sample(cnt).id =10
sample(cnt).ltemp = 10
sample(cnt).htemp = 10
Next
my problem is only element 0 of sample hold value of 10. others are blank
where is my mistake .
ROSHAN
- David Barker
- Swordfish Developer
- Posts: 1214
- Joined: Tue Oct 03, 2006 7:01 pm
- Location: Saltburn by the Sea, UK
- Contact:
Works fine here
output
Code: Select all
include "usart.bas"
include "convert.bas"
Structure ttemp
id As Byte
ltemp As Byte
htemp As Byte
End Structure
Dim sample(13) As ttemp
Dim cnt As Byte
setbaudrate(br19200)
For cnt = 0 To Bound(sample)
sample(cnt).id = cnt
sample(cnt).ltemp = cnt + 1
sample(cnt).htemp = cnt + 2
Next
For cnt = 0 To Bound(sample)
write(dectostr(cnt), ":",
dectostr(sample(cnt).id),",",
dectostr(sample(cnt).ltemp),",",
dectostr(sample(cnt).htemp),13,10)
Next
Code: Select all
0:0,1,2
1:1,2,3
2:2,3,4
3:3,4,5
4:4,5,6
5:5,6,7
6:6,7,8
7:7,8,9
8:8,9,10
9:9,10,11
10:10,11,12
11:11,12,13
12:12,13,14
Dear Sir,
I test it & it really works. Its ok.
I see result in isis> show variable. It still does not show other values. It may be problem of labcenter.
here is picture you can see.
http://hotfile.com/dl/7324431/d48ea94/error.JPG.html
BTW thanks for help.
Regards
I test it & it really works. Its ok.
I see result in isis> show variable. It still does not show other values. It may be problem of labcenter.
here is picture you can see.
http://hotfile.com/dl/7324431/d48ea94/error.JPG.html
BTW thanks for help.
Regards
ROSHAN
The code is probably working fine, but Isis is showing you the wrong memory for the array except for the first element.
The first element is at 0x005B, but Isis thinks the next one is at 0x0082, 39 bytes away. This happens to be the size of the whole array, so either Swordfish is outputing incorrect information or Isis isn't interpreting it correctly.
The first element is at 0x005B, but Isis thinks the next one is at 0x0082, 39 bytes away. This happens to be the size of the whole array, so either Swordfish is outputing incorrect information or Isis isn't interpreting it correctly.
- David Barker
- Swordfish Developer
- Posts: 1214
- Joined: Tue Oct 03, 2006 7:01 pm
- Location: Saltburn by the Sea, UK
- Contact: