Repository navigation
Operator Address of
Home › Operators › Operator @ (Address Of)
Returns the address of a string literal, variable, object or procedure
Declare Operator @ ( ByRef rhs As T ) As T PointerrhsT
Operator @ (Address of) returns the memory address of its operand.
When the operand is of type String, the address of the internal string descriptor is returned. Use Operator Strptr (String pointer) to retrieve the address of the string data.
The operand cannot be an array, but may be an array element. For example, "@myarray(0)" returns the address of "myarray(0)".
This operator can be overloaded for user-defined types as a member Operator using the appropriate syntax.
Returns the address of the right-hand side (rhs) operand.
result = @ rhs
- In the -lang qb dialect, this operator cannot be overloaded.
- New to FreeBASIC
'This program demonstrates the use of the @ operator.
Dim a As Integer
Dim b As Integer
Dim addr As Integer Ptr
a = 5 'Here we place the values 5 and 10 into a and b, respectively.
b = 10
'Here, we print the value of the variables, then where in memory they are stored.
Print "The value in A is ";a;" but the pointer to a is ";@a
Print "The value in B is ";b;" but the pointer to b is ";@b
'Now, we will take the integer ptr above, and use @ to place a value into it.
'Note that the * will check the value in the ptr, just as @ checked the ptr
'for a normal variable.
addr = @a
Print "The pointer addr is now pointing at the memory address to a, value: ";*addr
addr = @b
Print "The pointer addr is now pointing at the memory address to b, value: ";*addr'This program demonstrates how the @ symbol can be used
'to create pointers to subroutines.
Declare Sub mySubroutine ()
Dim say_Hello As Sub()
say_Hello = @mySubroutine 'We tell say_Hello to point to mySubroutine.
'The sub() datatype acts as a pointer here.
say_Hello() 'Now we can run say_Hello just like mySubroutine.
Sub mySubroutine
Print "hi"
End SubCategory: Operators
Kind: operator
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
- 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