ATTENTION MEMBERS: Conforums will be closing it doors and discontinuing its service on April 15, 2018. We apologize Conforums does not have any export functions to migrate data. Ad-Free has been deactivated. Outstanding Ad-Free credits will be reimbursed to respective payment methods.
Thank you Conforums members.
Cross-platform BBC BASIC (Windows, Linux x86, Mac OS-X, Android, iOS, Raspberry Pi)
Syntax for 'address of string'?
« Thread started on: Jan 25th, 2018, 10:50pm »
It's messy to find the memory address of a string in BBC BASIC. In BB4W and BBCSDL you can use !^string$ but that can't work in a 64-bit environment because it returns a 32-bit value. What's more, you can't write a user-defined function (FN) to do the job because when you pass a string as a parameter what you get inside the function is a copy of the string, not the original (so although you can find the address of the copy that's not what you want).
These factors suggest that there could be some value in providing a built-in function to do it. An 'obvious' candidate is the PTR function which is normally used to return a file pointer (PTR#channel) but which could be re-purposed to accept the syntax PTR(string$) to return the memory address of, i.e. a pointer to, the string.
What do you think? Does this seem sensible? I don't think there are any significant compatibility implications because currently if PTR is followed by anything other than a hash it reports the 'Missing #' error. But are there any pitfalls?