Revision [14452]
This is an old revision of KeyPgTypeAlias made by CountingPine on 2009-08-29 21:57:18.
Type (Alias)
Declares an alternative name for a type
Syntax:
Type typename KeyPgAs as symbol
Parameters:
typename
new alternative name.
symbol
symbol or data type declaration to associate with typename.
Description:
symbol may refer to any declared data type including a built-in data type, KeyPgSub Sub or KeyPgFunction Function pointer, KeyPgType Type declaration, KeyPgUnion Union declaration, or KeyPgEnum Enum declaration.
A type alias can be used to allow forward declarations of CatPgUserDefTypes User Defined Types.
Examples:
Type ParentFwd As Parent
Type Child
Name As ZString * 32
ParentRef As ParentFwd Ptr
''...
End Type
Type Parent
Name As ZString * 32
ChildList(0 To 9) As Child
''...
End Type
Dim p As Parent
p.Name = "Foo"
With p.ChildList(0)
.Name = "Jr."
.ParentRef = @p
'' ...
End With
With p.ChildList(0)
Print .Name; " is child of "; .parentRef->Name
End With
Type Child
Name As ZString * 32
ParentRef As ParentFwd Ptr
''...
End Type
Type Parent
Name As ZString * 32
ChildList(0 To 9) As Child
''...
End Type
Dim p As Parent
p.Name = "Foo"
With p.ChildList(0)
.Name = "Jr."
.ParentRef = @p
'' ...
End With
With p.ChildList(0)
Print .Name; " is child of "; .parentRef->Name
End With
Differences from QB:
- New to FreeBASIC
See also:
Back to User Defined Types