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?