QB64 Phoenix Edition
undocumented Len function - Printable Version

+- QB64 Phoenix Edition (https://qb64phoenix.com/forum)
+-- Forum: Chatting and Socializing (https://qb64phoenix.com/forum/forumdisplay.php?fid=11)
+--- Forum: General Discussion (https://qb64phoenix.com/forum/forumdisplay.php?fid=2)
+--- Thread: undocumented Len function (/showthread.php?tid=2955)



undocumented Len function - Jack - 08-16-2024

in the Wiki the Len function is described for strings only but QBasic uses the Len function also to get the size in bytes of data types including udts
but QB64pe also gives the size in bytes of an array, but this seems to be a feature and it behaves strangely
the following works and prints 50, 100 and 200
Code: (Select All)

Dim As Integer i(4, 4)
Dim As Long l(4, 4)
Dim As _Integer64 ll(4, 4)

Print Len(i())
Print Len(l())
Print Len(ll())
but if you add the following
Code: (Select All)

Print Len(l()) / Len(i())
it prints 100 instead of 2, the division never takes place
I think that getting the SizeOf an array would be nice to have and it almost works, perhaps the developers could fix it so that the last statement would be evaluated correctly


RE: undocumented Len function - SMcNeill - 08-16-2024

Looks like a bug in the processing to me:

Code: (Select All)
Dim As Integer i(4, 4)
Print Len(i())
Print Len(i()) / 2



RE: undocumented Len function - RhoSigma - 08-16-2024

Definitly a very old bug then, QB64 v0.954 (last SDL based version) behaves the same way.


RE: undocumented Len function - Jack - 08-16-2024

actually, I think that the Len of an array is an unintentional feature, it not supported by QBasic but it's so close to working in QB64pe that it would be a shame not to fix it