Qbasicnews.com
Bug with UDTs? - Printable Version

+- Qbasicnews.com (http://qbasicnews.com/newforum)
+-- Forum: Qbasic "like" compilers/interpreters (http://qbasicnews.com/newforum/forum-5.html)
+--- Forum: FB Discussion & Programming Help (http://qbasicnews.com/newforum/forum-15.html)
+--- Thread: Bug with UDTs? (/thread-6199.html)



Bug with UDTs? - BastetFurry - 02-23-2005

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!


Bug with UDTs? - steven_basic - 02-23-2005

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



Bug with UDTs? - Anonymous - 02-23-2005

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


Bug with UDTs? - v3cz0r - 02-24-2005

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.


Bug with UDTs? - BastetFurry - 02-24-2005

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 >.<