Repository navigation
Enumcount
Home › Miscellaneous Keywords › EnumCount
Returns the number of constants an enum declares, as a compile-time constant.
result = enumcount( enumtype )-
enumtype: the name of anEnumtype, qualified if it is in a namespace (Ns.Inner).
The number of constants in the declaration, as an integer constant. Constants that share a value each count.
enumcount folds to a constant, so it can go wherever a constant can: a const, an array bound, a fixed-size array field of a type.
Together with enumvalue it walks every constant of an enum in declaration order: for i = 0 to enumcount( E ) - 1, then enumvalue( E, i ).
The argument must be an enum type, not a value or a constant of one: enumcount( Monday ) is an error (TKO1272).
enum Weekday
Monday, Tuesday, Wednesday, Thursday, Friday
end enum
const DAYS = enumcount( Weekday ) '' a constant
dim as int32 hours( 0 to DAYS - 1 ) '' so it can size an array
type Week
as int32 worked( 0 to enumcount( Weekday ) - 1 )
end type
print DAYS, ubound( hours ), sizeof( Week ) 5 4 20
-
Not a reserved word. A procedure, variable or other symbol of your own named
enumcountwins, and the built-in is then out of reach in that scope. -
enumcountis a tiko addition.
Category: Miscellaneous Keywords Kind: function
tiko-lang · Home · Feature Index · Keyword Index · License
FreeBASIC manual pages reproduced under the GNU FDL 1.3.
- Home
- What Is tiko-lang
- Quick Start
- Installing on macOS
- Android (experimental)
- Debugging
- Feature Index
- Compatibility
- FAQ
- AI Cheatsheet
- Generics
- Interfaces
- For Each
- Iterators
- Tuples
- Array Results
- Defer
- Move Semantics
- Match
- Lambdas
- Block Strings
- String Interpolation
- Partial Types
- String Slices
- Array 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)
- Time Zones
- Filesystem
- File Streams
- Config (INI and TOML)
- Codec
- Hash
- UUID
- OS
- Hardware
- Process
- Net
- HTTP and TLS
- Math Library
- Finance
- Logging
- Terminal TUI Library
- tkControls
- sys/win
- Goroutines and Channels
- LLVM Backend
- tiko build
- tiko test
- tiko doc
- 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