08-22-2022, 09:04 PM
Is it possible to pass _MEM handles to Functions/Subs without having to make it global?
Is there a way to normalize the behavior of strings in UDT's? Uninitialized strings in UDT's are filled with CHR$(0), and initialized strings are padded with spaces at the end. Trying to determine the actual string length is difficult, because I can't tell if the spaces are intentional or not.
Are variable length strings in UDT allowed? I though that they weren't. But it seems if you use the right syntax they are allowed, but I found that I can get some strange behaviors if I use them. (Not demonstrated in code.)
I've demonstrated my questions in the following code.
Is there a way to normalize the behavior of strings in UDT's? Uninitialized strings in UDT's are filled with CHR$(0), and initialized strings are padded with spaces at the end. Trying to determine the actual string length is difficult, because I can't tell if the spaces are intentional or not.
Are variable length strings in UDT allowed? I though that they weren't. But it seems if you use the right syntax they are allowed, but I found that I can get some strange behaviors if I use them. (Not demonstrated in code.)
I've demonstrated my questions in the following code.
Code: (Select All)
TYPE tTEST
st AS STRING * 12
END TYPE
TYPE tTESTBUG
AS STRING st
END TYPE
DIM AS tTEST test
DIM AS tTESTBUG testbug
PRINT "Uninitialized String."
prntSTR test
PRINT "Initialized String."
test.st = "Hello"
prntSTR test
PRINT "Variable length String in UDT? "
PRINT "Uninitiated String."
prntSTRBug testbug
PRINT "Initialized String."
testbug.st = "Hello"
prntSTRBug testbug
SUB prntSTR (test AS tTEST)
DIM i AS LONG
FOR i = 1 TO LEN(test.st)
PRINT ASC(MID$(test.st, i, 1)); " ";
NEXT
PRINT
END SUB
SUB prntSTRBug (test AS tTESTBUG)
DIM i AS LONG
FOR i = 1 TO LEN(test.st)
PRINT ASC(MID$(test.st, i, 1)); " ";
NEXT
PRINT
END SUB