Qbasicnews.com

Full Version: Bug with UDTs?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi!

Tryed the following but got an error about invalid data types...

Code:
type hiscorestruct
   names as string
   punkte as integer
end type

dim hiscore(10) as hiscorestruct

temp$ = hiscore(tempnum).names

Is it a bug or did i do something wrong?

So Long, The Werelion!
Is there more to your code? What was posted compiled with 0.11 with no problem. It doesn't do anything...

... but it compiles and runs.

The following seems to work correctly:
Code:
type hiscorestruct
   names as string
   punkte as integer
end type

dim hiscore(10) as hiscorestruct

for counter = 0 to 10
  hiscore(counter).names = str$(counter)
next counter

tempnum = 5
temp$ = hiscore(tempnum).names

print temp$

sleep

Anonymous

i thought strings defined in a TYPE had to be fixed length i.e

Code:
DIM things as string * n


n being the length of the string of course
FB allows dynamic strings on UDT's, but they won't be automatically deallocated when a local UDT (inside a sub-routine) goes off scope, thus leaking if you don't do myudt.mydynstr = "" at end of the sub.
Quote:FB allows dynamic strings on UDT's, but they won't be automatically deallocated when a local UDT (inside a sub-routine) goes off scope, thus leaking if you don't do myudt.mydynstr = "" at end of the sub.

ARGHHH!!!!!
Thanks for that, i gona hit my head on the wall....
Quess what i forgot to put in the DIM foobar AS UDT... the inevitable shared.

I would fancy it if you would implement a metakeyword.
Code:
$GLOBAL ON
DIM a AS INTEGER
DIM b AS STRING
DIM c AS FLOAT
$GLOBAL OFF
All three above would be globals/shared

So Long, The Werelion!

Please close this >.<