« Syntax for 'address of string'? »

Welcome Guest. Please Login or Register.
Feb 18th, 2018, 12:00am

Cross-platform BBC BASIC (Win32, Linux x86, Android, Mac OS-X, Raspberry Pi)

« Previous Topic | Next Topic »
Pages: 1  Notify Send Topic Print
 thread  Author  Topic: Syntax for 'address of string'?  (Read 41 times)
Richard Russell

member is offline


Homepage PM

Posts: 727
xx 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?

User IP Logged

Pages: 1  Notify Send Topic Print
« Previous Topic | Next Topic »

Donate $6.99 for 50,000 Ad-Free Pageviews!

This forum powered for FREE by Conforums ©
Sign up for your own Free Message Board today!
Terms of Service | Privacy Policy | Conforums Support | Parental Controls