1
QB64 Discussion / Re: Problem with OPEN in SUB
« on: February 26, 2022, 01:07:15 pm »Would have been nice if somebody would have pointed out what you did wrong, though you might of garnered it from the example replies.
This was your original issue;
SUB text (g, ttt, testing, t1, t2, t3)
If you wanted to pass a UDT you needed to use the AS statement just like in a DIM line
SUB text (g, ttt AS testing)
called with
text 1, ttt
in your original line, each of those variables being passed were passed as the SINGLE data type, by default since you did not specify.
That is why you were not seeing the results you expected.
Now you didn't receive any kind of error because you didn't write one bit of code wrong! Every thing you typed was valid code. Just not the code that would produce the results you wanted. ttt.t1 is a valid variable even without UDT.
and GET #1, g, ttt
worked correctly too it loaded 4bytes (length of a SINGLE) into ttt, but instead of as a STRING it loaded it as a SINGLE(numeric) value. so no error
and of course PRINT ttt.t1 would have printed 0 as ttt.t1 was a SINGLE value that had nothing assigned to it.(same with the other 2 print lines) so still no error
max = LOF(1) / LEN(ttt)
here LEN(ttt) would have been 4, again because ttt is a SINGLE value which is 4 bytes long. again no error on the compiler side.
Hopefully that explains what occurred, and you can avoid (or make) some problems in the future with this knowledge.
Understood.