In the following example a fixed-length string s with size 19, a pointer p and an unsigned integer n are declared. With the built-in function aof() (address of) the descriptor address of string s is assigned to p. In SharpBASIC a string descriptor has the format [addr:size], a double dword in 32 bits. So p+4 points to the size of the string and is assigned to n with the built-in function bya() (by address).
Code: Select all
' SharpBASIC ptr6 ' ----------------- incl "lib/sys.sbi"; dim s: str * 19; dim p: ptr; dim n: uint; main do ' address of descriptor p = aof(s); ' size by address in second dword field n = bya(p + 4); ' output: 19 print(n); end;