Repository navigation
Len
Home › String Functions › Len
Returns the length of a string, or the size of a type.
Declare Function Len ( ByRef expression As String ) As Integer
Declare Function Len ( ByRef expression As ZString ) As Integer
Declare Function Len ( ByRef expression As WString ) As Integer
Declare Operator Len ( ByRef expression As datatype ) As datatype
Declare Function Len ( datatype ) As Integerexpressiondatatype
Len returns the length of an expression or the size of a DataType, in bytes.
In the first form, if expression is of type String, WString or ZString, the length of the string in characters will be returned. If the expression is of a user defined type, an Operator Len compatible with that data type is called. Otherwise, the size of the expression's data type in bytes is returned.
In the second form, if expression is ZString or WString, the size in bytes of an ASCII or Unicode character is returned, respectively. If datatype is String, the size of the string descriptor type is returned.
If there is both a user defined type and a variable visible with the same name in the current scope, the user defined type takes precedence over the variable. To ensure that the Len takes the variable instead of the user defined type, wrap the argument to Len with parentheses to force it to be seen as an expression. For example Len((variable)).
Note: When used with array names, Len returns the length of the array datatype, but not the total number of its elements.
For clarity, it is recommended that you avoid this potential confusion, and use Len on the array datatype doing Len(Typeof(array)), rather than the array name only doing Len(array).
The Len unary Operator can be overloaded with user defined types.
Returns the size of an expression or DataType (including the data fields of a UDT) in bytes.
result = Len( expression )orresult = Len( DataType )
-
Lenonly allows expressions in the -lang qb dialect. Can be used with built-in types and user-defined types in the -lang fb and -lang fblite dialects.
- Can be used with built-in types and user-defined types in the -lang fb and -lang fblite dialects. None in the -lang qb dialect.
Print Len("hello world") 'returns "11"
Print Len(Integer) ' returns 4
Type xyz
a As Integer
b As Integer
End Type
Print Len(xyz) ' returns 8Category: String Functions
Kind: function
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.
- Home
- What Is tiko-lang
- Quick Start
- Installing on macOS
- Debugging
- Feature Index
- Compatibility
- FAQ
- AI Cheatsheet
- 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)
- Time Zones
- 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