QBJS - Fun Facts!
#4
STRING$() function has weird behavior in QBJS. Is this on purpose?

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.
Reply


Messages In This Thread
QBJS - Fun Facts! - by dbox - 04-10-2023, 08:46 PM
RE: QBJS - Fun Facts! - by mnrvovrfc - 04-10-2023, 09:48 PM
RE: QBJS - Fun Facts! - by Sprezzo - 04-10-2023, 10:23 PM
RE: QBJS - Fun Facts! - by mnrvovrfc - 04-11-2023, 06:11 AM
RE: QBJS - Fun Facts! - by dbox - 04-11-2023, 08:55 PM
RE: QBJS - Fun Facts! - by dbox - 04-11-2023, 09:20 PM
RE: QBJS - Fun Facts! - by vince - 04-11-2023, 10:03 PM
RE: QBJS - Fun Facts! - by dbox - 04-13-2023, 11:48 AM
RE: QBJS - Fun Facts! - by mnrvovrfc - 04-14-2023, 03:04 AM
RE: QBJS - Fun Facts! - by CharlieJV - 04-14-2023, 04:00 AM
RE: QBJS - Fun Facts! - by bplus - 04-13-2023, 01:45 PM
RE: QBJS - Fun Facts! - by SMcNeill - 04-14-2023, 11:38 AM
RE: QBJS - Fun Facts! - by dbox - 04-14-2023, 01:31 PM
RE: QBJS - Fun Facts! - by vince - 04-14-2023, 11:55 AM
RE: QBJS - Fun Facts! - by mnrvovrfc - 04-14-2023, 02:53 PM
RE: QBJS - Fun Facts! - by dbox - 04-14-2023, 03:55 PM
RE: QBJS - Fun Facts! - by dbox - 04-21-2023, 02:04 PM



Users browsing this thread: 5 Guest(s)