A question about types

Blitz3D Forums/Blitz3D Beginners Area/A question about types

Yo! Wazzup?(Posted 2007) [#1]
Can you do this?
Type hi
Field hi=1
End Type



Yahfree(Posted 2007) [#2]
Yea?

but generaly thats not how types work.. more like this:


Graphics 300,500,16,2
setbuffer backbuffer()


type person
field Hello$
end type

Bob.person = new person
Bob\Hello="Hello"

Joe.person = new person
Joe\Hello="Yo Wazzup?"

Dumbguy.person = new person
Dumbguy\Hello="Duhh..."

Print "Dumbguy's Hello: "+Dumbguy\Hello
Print "Joe's Hello: "+Joe\Hello
Print "Bobs Hello: "+Bob\Hello

delay 5000



H&K(Posted 2007) [#3]
Although you could do it, I would very much recomend not nameing the type the field and the instance the same thing
Hi.Hi = New Hi
print Hi\hi
Is just anoying codeing


Unless you were just asking if you can allocate a field directly, in which case yep no probs


Yo! Wazzup?(Posted 2007) [#4]
Well, this is why I want to do it:
http://www.blitzbasic.com/Community/posts.php?topic=69694
I want to complete this in as very little code as possible.


GfK(Posted 2007) [#5]
Types can't have default values in Blitz3D, can they?


big10p(Posted 2007) [#6]
Types can't have default values in Blitz3D, can they?
No, they can't - although, I think the compiler allows you to put 'Field a=1' etc., it just doesn't have any effect.


Yahfree(Posted 2007) [#7]


;---------
type Scans
Field code
Field ID$
end type

for i=0 to 222 ; the amount of SC's i think
Codes.Scans = new Codes
Codes\ID="ScanCode#"+i
next



Somthing like that i suppose..?


(tu) sinu(Posted 2007) [#8]
The compiler lets you, but sometimes it bugs up and requests a file to open if you give a custom function eg

type box
field contents% = CreateList%()
end type