[Coco] DEF USR and strings?
Allen Huffman
alsplace at pobox.com
Wed Oct 29 21:07:15 EDT 2025
> On Oct 29, 2025, at 6:15 PM, Bruce Borer via Coco <coco at maltedmedia.com> wrote:
>
> I do not know what can and cannot be done (yet) but can you pass the
> address (number) of the string and use the pointer in USRn to do what you
> want?
Yes, the way we’ve always done it is to use VARPTR. I have an article series on my site where I dove into how that worked.
But, earlier this year I saw someone post saying you didn’t need to use VARPTR. That stuck in the back of my mind until I had time to revisit the subject (now). That would make things much easier.
For example, suppose you had some routines that help move something around the screen (software “sprites”) and it handles all of that, returning status (collision, etc.) from a simple:
X=USR0(x)
Easy. But, what if it also handed keyboard commands. You could hard-code it for UP, DOWN, LEFT and RIGHT, but some users prefer WASD or whatever. So I was thinking along the lines of doing:
X=USR0(“WASD”)
Super simple. You can do it now, but it would look like:
X=USR0(VARPTR(“WASD”))
Or similar.
But apparently there IS a way to obtain the string address, so the game Is afoot!
— A
More information about the Coco
mailing list