basiccommodore

How to 'manipulate' strings in BASIC V2?


I would like to reach the following: I ask for a number from the user, and then output a string like the following:

-STR$

--STR$

---STR$

----STR$

-----STR$

I tried to do this:

10 INPUT NUM%
20 FOR X=1 TO NUM%: PRINT NUM%*"-" + "TEXT" : NEXT

The code above got me an error: ?TYPE MISMATCH EROR IN 20

However, I didn't yet figure out how to manipulate the string's beginning to multiply the '-' marks on each loop run


Solution

  • Maybe this:

    10 INPUT NUM%
    20 FOR I = 1 TO NUM%
    30 FOR J = 1 TO I: PRINT "-"; : NEXT
    40 PRINT " TEXT"
    50 NEXT
    

    There is no multipy of strings/character, as far as I remember to old (good) times.