[Coco] DEF USR and strings?
Allen Huffman
alsplace at pobox.com
Wed Oct 29 16:48:43 EDT 2025
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$))
I went to try it today and it gives me a ?TM ERROR
I checked the Unravelled listing and it looks like it wants to handle strings:
* PROCESS A USR CALL
L892C BSR L891C GET STORAGE LOC OF EXEC ADDRESS FOR USR N
LDX ,X * GET EXEC ADDRESS AND
PSHS X * PUSH IT ONTO STACK
JSR >LB262 SYNTAX CHECK FOR ‘(‘ & EVALUATE EXPR
LDX #FP0EXP POINT X TO FPA0
LDA VALTYP GET VARIABLE TYPE
BEQ L8943 BRANCH IF NUMERIC, STRING IF <> 0
JSR >LB657 GET LENGTH & ADDRESS OF STRING VARIABLE
LDX FPA0+2 GET POINTER TO STRING DESCRIPTOR
LDA VALTYP GET VARIABLE TYPE
L8943 RTS JUMP TO USR ROUTINE (PSHS X ABOVE)
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?
— A
More information about the Coco
mailing list