Re: DEF USR and strings?

William Astle via Coco <coco-uNHYcr1XS/wmlAP/[email protected]>
Newsgroups gmane.comp.hardware.tandy.coco
Message-ID <[email protected]>
On 2025-10-29 14:48, Allen Huffman via Coco wrote:
> I could have swore I saw someone post (maybe on Facebook) that they realized the DEF USR could accept a string parameter. I had only known to use it like this:
> 
> A$=“STRING”
> X=USR0(VARPTR(A$))
> 
<snip>
> It looks like BEQ L8943 is where it goes if numeric, else it continues and gets the length and address of the string variable and continues.
> 
> What is the syntax to make this work?

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.

-- 
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.