04-11-2023, 06:11 AM
STRING$() function has weird behavior in QBJS. Is this on purpose?
Because I tried to test with the following code:
For the first line, I got "42" replicated 40 times. In QuickBASIC and "clones" it gives me 80 asterisks.
Even weirder, I do:
and the result is "4324324324". Not sure but it's supposed to flag an error that the second parameter must be type byte.
Otherwise this is pretty neat and I could finally shelf my REPEAT$(). LOL.
Because I tried to test with the following code:
Code: (Select All)
print string$(80, 42)
print string2$(80, 42)
print string$(40, "*+-")
print string2$(40, "*+-")
print string2$(40, "*+-", 2)
print string2$(20, "*+-", 3)
end
function string2$(quant as integer, astr as string, numchar as integer)
dim i as integer, sret$
if astr = undefined then astr = chr$(32)
if numchar = undefined then numchar = 1
for i = 1 to quant
sret$ = sret$ + left$(astr, numchar)
next
string2$ = sret$
end function
For the first line, I got "42" replicated 40 times. In QuickBASIC and "clones" it gives me 80 asterisks.
Even weirder, I do:
Code: (Select All)
print string$(10, 432)
and the result is "4324324324". Not sure but it's supposed to flag an error that the second parameter must be type byte.
Otherwise this is pretty neat and I could finally shelf my REPEAT$(). LOL.