TL;DR:
Classic approach (will work on most BASICs):
10 INPUT NU : REM MS-BASIC recognizes only two letters for names
20 A$="" : REM Initialize a String to collect the hyphens
30 FOR I = 1 TO NU : REM 'I' is traditionally used for counting in BASIC
40 A$=A$+"-" : REM Add one hyphen per iteration
50 PRINT A$;"TEXT" : REM Spare the expensive sting concatenation, just print them in sequence
60 NEXT I : REM It's good style to close with variable names
There are of course, many other ways, like using string operations and so on, but they may run in issues (*1), so above is a safe bet.
Details
20 FOR X=1 TO NUM%: PRINT NUM%*"-" + "TEXT" : NEXT
The code above got me an error: ?TYPE MISMATCH EROR IN 20
In BASIC multiplication is only defined for numbers. It does not operate on strings or mixtures of strings and numbers.
However, I didn't yet figure out how to manipulate the string's beginning to multiply the '-' marks on each loop run
BASIC isn't as rich, especially not MS-BASIC. It's ... well ... basic :))
In fact, doing BASIC requires a procedural mentality describing machine operation, not laying out high level concepts. You're telling the interpreter step by step what to do and how to do it. More of a better Assembler than more abstract languages.
So the straight forward (but but kinda clumsy) way would to 'explain' that string 'multiplication' to the interpreter as an inner loop:
Minimalist BASIC
10 INPUT NU
20 FOR I = 1 TO NU : REM loop around all output lines
30 FOR J = 1 TO I : REM Multiplication-Loop creating the hyphens
40 PRINT "-"; : REM Print one hyphen, let the next PRINT continue right after
50 NEXT J : REM End of multiplication
60 PRINT "TEXT" : REM PRINT the text, advance output to the next line
70 NEXT I
This should even work with the tiniest TINY-BASIC. It needs the least amount of RAM, as there is no dynamic string creation and manipulation. Only straight string output from constants. Depending on the BASIC it might as well be faster than seemingly more compact solutions due not doing string operations.
BBB - Better BASIC(s) Bureau
Having said that, there are of course BASIC Dialects that offer functions to build strings by 'multiplying' characters or even strings. BBC BASIC is one of these, offering a STRING$(repeat,string)
function that returns a string made of the input string repeated given times. In this case the program will look much like your first approach:
10 INPUT NU
20 FOR I = 1 TO NU
30 PRINT STRING$(I,"-");"TEXT"
40 NEXT I
Simon does it on the C64
To do the same on a C64, you may want to use Simons' BASIC, an extension to V2 BASIC, offering a DUP functions (*2) doing the same:
10 INPUT NU
20 FOR I = 1 TO NU
30 PRINT DUP("-",I);"TEXT"
40 NEXT I
*1 - Like being only valid within certain limits of NU, or eating up lots of RAM.
*2 - Simons BASIC is kind of an outgrown hack, as if not simply named STRING$
like in many other dialects, it should at least have a $ sign attached (DUP$
), as it's result is a string.