Repository navigation
Function Member
Home › User Defined Types › Function (Member)
Declares or defines a member procedure returning a value
{ Type | Class | Union } typename
Declare [ Static | Const ] Function fieldname [calling convention specifier] [ Alias external_name ] ( [ parameters ] ) [ ByRef ] As datatype [ Static ]
End { Type | Class | Union }
Function typename.fieldname ( [ parameters ] ) [ ByRef ] As datatype [ Export ]
statements
End Functiontypenamefieldnameexternal_nameparameterscalling convention specifier
Function members are accessed with Operator . (Member Access) or Operator -> (Pointer To Member Access) to call a member procedure that returns a value (a reference can also be returned by specifying Byref As return_type). The procedure may optionally accept parameters either ByVal or ByRef. typename be overloaded without explicit use of the Overload keyword.
typename is the name of the type for which the Function method is declared and defined. Name resolution for typename follows the same rules as procedures when used in a Namespace.
A hidden This parameter having the same type as typename is passed to non-static member procedures. This is used to access the fields of the Type, Class, or Union.
To access duplicated symbols defined as global outside the Type, add one or preferably two dot(s) as prefix: .SomeSymbol or preferably ..SomeSymbol (or only ..SomeSymbol if inside a With..End With block).
A Static (Member) may be declared using the Static specifier. A Const (Member) may be declared using the Const specifier.
As for a normal Function, the return value of a Function member can be ignored in the calling code.
- Only available in the -lang fb dialect.
#include "vbcompat.bi"
Type Date
value As Double
Declare Static Function Today() As Date
Declare Function Year() As Integer
Declare Function Month() As Integer
Declare Function Day() As Integer
End Type
Function Date.Today() As Date
Return Type(Now())
End Function
Function Date.Year() As Integer
Return ..Year(value)
End Function
Function Date.Month() As Integer
Return ..Month(value)
End Function
Function Date.Day() As Integer
Return ..Day(value)
End Function
Dim d As Date = Date.Today
Print "Year = "; d.Year
Print "Month = "; d.Month
Print "Day = "; d.DayCategory: User Defined Types
Kind: member
Reproduced from the FreeBASIC Wiki Manual under the GNU Free Documentation License 1.3 — with no Invariant Sections, no Front-Cover Texts and no Back-Cover Texts. Copyright © the FreeBASIC project and wiki contributors. See License.
tiko-lang · Home · Feature Index · Keyword Index · License
FreeBASIC manual pages reproduced under the GNU FDL 1.3.
- Generics
- Interfaces
- For Each
- Iterators
- Tuples
- Array Results
- Defer
- Lambdas
- Block Strings
- Partial Types
- String Slices
- Embed
- Typed Variadics
- C Header Import
- Foreign Library Linking
- UString
- Fixed-Width Types
- Nullptr
- String Library
- Format
- Array
- Map
- Set
- LinkedList
- OrderedMap
- OrderedSet
- Sorting
- Optional
- Result
- Smart Pointers
- Date and Time (Chrono)
- Filesystem
- File Streams
- Config (INI and TOML)
- Codec
- Hash
- UUID
- OS
- Process
- Net
- HTTP and TLS
- Math Library
- Finance
- Logging
- Terminal TUI Library
- PsControls
- tkControls
- sys/win
- Goroutines and Channels
- LLVM Backend
- tiko build
- TIKO_COMPILER
- Variable Declarations
- Standard Data Types
- User Defined Types
- Procedures
- Operators
- Control Flow Statements
- Converting Data Types
- Array Functions
- String Functions
- Mathematical Functions
- Bit Manipulation
- Date and Time Functions
- File I/O Functions
- Console Functions
- User Input (Runtime Library)
- User Input Functions (Graphics Library)
- Screen Functions
- 2D Drawing Functions
- Graphics Library Reference
- Graphics Keyword List
- Memory Functions
- Threading Support Functions
- Error Handling Functions
- Operating System Functions
- Preprocessor
- Intrinsic Defines
- Miscellaneous Keywords
- Modularizing