"Fossies" - the Fresh Open Source Software Archive

Member "FreeBASIC-1.09.0-win64/examples/manual/operator/address-var.bas" (1 Jan 2022, 1041 Bytes) of package /windows/misc/FreeBASIC-1.09.0-win64.zip:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Visual Basic source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file.

    1 '' examples/manual/operator/address-var.bas
    2 ''
    3 '' NOTICE: This file is part of the FreeBASIC Compiler package and can't
    4 ''         be included in other distributions without authorization.
    5 ''
    6 '' See Also: https://www.freebasic.net/wiki/wikka.php?wakka=KeyPgOpAt
    7 '' --------
    8 
    9 'This program demonstrates the use of the @ operator.
   10 
   11 Dim a As Integer
   12 Dim b As Integer
   13 
   14 Dim addr As Integer Ptr
   15 
   16 a = 5   'Here we place the values 5 and 10 into a and b, respectively.
   17 b = 10
   18 
   19 'Here, we print the value of the variables, then where in memory they are stored.
   20 Print "The value in A is ";a;" but the pointer to a is ";@a
   21 Print "The value in B is ";b;" but the pointer to b is ";@b
   22 
   23 'Now, we will take the integer ptr above, and use @ to place a value into it.
   24 'Note that the * will check the value in the ptr, just as @ checked the ptr 
   25 'for a normal variable.
   26 
   27 addr = @a
   28 
   29 Print "The pointer addr is now pointing at the memory address to a, value: ";*addr
   30 
   31 addr = @b
   32 
   33 Print "The pointer addr is now pointing at the memory address to b, value: ";*addr