Re: DEF USR and strings?

Allen Huffman via Coco <coco-uNHYcr1XS/wmlAP/[email protected]>
Newsgroups gmane.comp.hardware.tandy.coco
Message-ID <[email protected]>
> On Oct 29, 2025, at 4:03 PM, William Astle via Coco <[email protected]> wrote:
> 
> First, you leave out VARPTR completely. It's not needed if you rely on USR to pass through a string parameter. (Under plain Color Basic, you can't pass a string in but Extended Basic lets you).
> 
> The biggest problem is that if you pass a string to USRn(), VALTYP will still be flagged as string when your USR routine returns and that will trigger a TM error on the assignment (to X in your example). Your handler routine will have to actually return a value instead of doing nothing with a simple RTS. Note that if you do things right, your USRn() handler can actually return a string but the how of that is beyond the scope of this email.
> 
> If you get a TM error *with* the VARPTR in there, then you have something else wrong.

It looks like I tried this back in 2017 and couldn’t get it to work:

https://subethasoftware.com/2017/02/07/interfacing-assembly-with-basic-via-defusr-part-3/

There, I wrote:

"Unfortunately, the USRx() command only allows you to pass in a numeric value, and not a string, so we can’t simply do something like:

A$=USR0("Convert this to all uppercase.") 'THIS WILL NOT WORK!


I suspect my handling of USRx may be incorrect? I am pretty sure I did not know this was even possible until I saw someone post about it working, somewhere.

		— Allen


-- 
Coco mailing list
[email protected]
https://pairlist5.pair.net/mailman/listinfo/coco
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.