BBC BASIC
« Syntax for 'address of string'? »

Welcome Guest. Please Login or Register.
Mar 31st, 2018, 10:43pm



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)
BBC BASIC Resources
BBC BASIC Help Documentation
BBC BASIC for Windows Home Page
BBC BASIC Programmers' Reference
BBC BASIC Beginners' Tutorial
BBC BASIC for SDL 2.0 Home Page
BBC BASIC Discussion Group

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


member is offline

Avatar




Homepage PM


Posts: 803
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?

Richard.
User IP Logged

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

| |

This forum powered for FREE by Conforums ©
Terms of Service | Privacy Policy | Conforums Support | Parental Controls