Page 1 of 1
structure help
Posted: Wed Sep 14, 2005 2:11 pm
by szerda
hi first sorry my bad english
i want creat a structure orelse like this:
Code: Select all
structure barstr
start.l
end.l
endstructure
filenum.l
file[filenum]
name$
date.l
barcount.l
bar.barstr[barcount]
so my question how can i make this
filenum,barcount : alwasy different and value's i will know when i read from file
if it possible to make anyway like structure,array,list ...
pleas help
thanks
Posted: Wed Sep 14, 2005 5:00 pm
by GedB
SZerda,
The problem is that Structures are a static item, the same as constants.
Static items are resolved at compile time. The compiler uses the Structures to resolve all of the addresses, but then uses those addresses in the final executable. This means that the final executable has no knowledge of the structure.
For example, consider the following code:
Code: Select all
#S_Count = 10
Structure t
s.b[#S_Count]
t.b[4]
u.l
EndStructure
Debug SizeOf(t)
Debug OffsetOf(t\u)
The compiler knows at compile time that the offset of u will be 14 because it knows that s is an array of 10 bytes and t is an array of 4.
Variables, on the other hand, are dynamic. They can change value at run time. For this reason you cannot use them when defining a structure.
Posted: Thu Sep 15, 2005 11:12 am
by szerda
thanks GedB
yes i know the structure is static
so my question: ther is any other way to creat it?
i tried use 2 list: 1 for file, and 1 for bar
Code: Select all
structure filestr
name$
date.l
barcount.l
endstructure
structure barstr
start.l
end.l
endstructure
NewList file.filestr
NewList bar.barstr
but how can i make that every file list has an own bar list?
it is possible?
i hope i was clear
Posted: Thu Sep 15, 2005 11:18 am
by Dare2
Perhaps make the barlist a pointer to an allocated block of memory, and the memory as big as required for each instance?
Posted: Thu Sep 15, 2005 12:45 pm
by lexvictory
this should work:
Code: Select all
structure filestr
name$
date.l
barcount.l
endstructure
structure barstr
start.l
end.l
endstructure
dim filestrthing.filestr(999) ; well, change it from 999 lol
dim barstrthing.barstr(999)
Posted: Thu Sep 15, 2005 9:21 pm
by Fou-Lu
Code: Select all
structure tbarstr
start.l
end.l
endstructure
structure tfilestr
name$
date.l
barcount.l
endstructure
structure alphastr
barstr.tbarstr
filestr.tfilestr
endstructure
NewList file.alphastr
I've never tried to put and structure inside the other, but I think it's possible (I've got no PB on this machine to try). Anyway, if you do like that, everytime you create a file there will be fields for barstr and for filestr inside it.

Posted: Fri Sep 16, 2005 12:34 am
by okasvi
see help file for "Extends" within structures topic...
Posted: Fri Sep 16, 2005 8:34 am
by szerda
thanks
but how can i make that every fileList has an own barList?
barList in fileList
it is possible?
Posted: Fri Sep 16, 2005 10:57 am
by GedB
Szerda,
Based on what you've told us, probably not.
What exactly are you trying to achieve?
Posted: Fri Sep 16, 2005 3:00 pm
by szerda
i found answer
i use tinman's double_linked_list
thanks everybody