Repeat a string: Difference between revisions

(Add 8080 Assembly)
 
(3 intermediate revisions by 3 users not shown)
Line 417:
print StringRepeat$("*", 5)
end</syntaxhighlight>
 
==={{header|Chipmunk Basic}}===
{{works with|Chipmunk Basic|3.6.4}}
<syntaxhighlight lang="qbasic">100 cls
110 print stringrepeat$("rosetta",1)
120 print stringrepeat$("ha",5)
130 print stringrepeat$("*",5)
140 end
150 function stringrepeat$(s$,n)
160 cad$ = ""
170 for i = 1 to n
180 cad$ = cad$+s$
190 next i
200 stringrepeat$ = cad$
210 end function</syntaxhighlight>
 
==={{header|GW-BASIC}}===
{{works with|Applesoft BASIC}}
{{works with|PC-BASIC|any}}
{{works with|BASICA}}
{{works with|Chipmunk Basic}}
{{works with|QBasic}}
{{works with|MSX BASIC}}
<syntaxhighlight lang="qbasic">100 CLS : rem 100 HOME for Applesoft BASIC
110 S$ = "rosetta" : N = 1
120 GOSUB 210
130 PRINT CAD$
140 S$ = "ha" : N = 5
150 GOSUB 210
160 PRINT CAD$
170 S$ = "*" : N = 5
180 GOSUB 210
190 PRINT CAD$
200 END
210 REM FUNCTION STRINGREPEAT$(S$,N)
220 CAD$ = ""
230 FOR I = 1 TO N
240 CAD$ = CAD$+S$
250 NEXT I
260 RETURN</syntaxhighlight>
 
==={{header|Minimal BASIC}}===
{{works with|Quite BASIC}}
<syntaxhighlight lang="qbasic">100 REM Repeat a string
110 LET S$ = "rosetta"
120 LET N = 1
130 GOSUB 210
140 LET S$ = "ha"
150 LET N = 5
160 GOSUB 210
170 LET S$ = "*"
180 LET N = 5
190 GOSUB 210
200 STOP
210 REM FUNCTION StringRepeat$(S$,N)
220 FOR I = 1 TO N
230 PRINT S$;
240 NEXT I
250 PRINT
260 RETURN
270 END</syntaxhighlight>
 
==={{header|MSX Basic}}===
{{works with|MSX BASIC|any}}
The [[#GW-BASIC|GW-BASIC]] solution works without any changes.
 
==={{header|QBasic}}===
Line 431 ⟶ 496:
PRINT StringRepeat$("*", 5)
END</syntaxhighlight>
 
==={{header|Quite BASIC}}===
{{works with|BASICA}}
{{works with|Chipmunk Basic}}
{{works with|GW-BASIC}}
{{works with|MSX BASIC}}
{{works with|PC-BASIC|any}}
{{works with|QBasic}}
<syntaxhighlight lang="qbasic">100 CLS
110 LET S$ = "rosetta"
115 LET N = 1
120 GOSUB 210
130 PRINT C$
140 LET S$ = "ha"
145 LET N = 5
150 GOSUB 210
160 PRINT C$
170 LET S$ = "*"
175 LET N = 5
180 GOSUB 210
190 PRINT C$
200 END
210 REM FUNCTION STRINGREPEAT$(S$,N)
220 LET C$ = ""
230 FOR I = 1 TO N
240 LET C$ = C$ + S$
250 NEXT I
260 RETURN</syntaxhighlight>
 
==={{header|True BASIC}}===
Line 445 ⟶ 538:
PRINT StringRepeat$("*", 5)
END</syntaxhighlight>
 
==={{header|XBasic}}===
{{works with|Windows XBasic}}
<syntaxhighlight lang="qbasic">PROGRAM "Repeat a string"
VERSION "0.0000"
 
DECLARE FUNCTION Entry ()
DECLARE FUNCTION StringRepeat$ (s$, n)
 
FUNCTION Entry ()
 
PRINT StringRepeat$ ("rosetta", 1)
PRINT StringRepeat$ ("ha", 5)
PRINT StringRepeat$ ("*", 5)
 
END FUNCTION
FUNCTION StringRepeat$ (s$, n)
cad$ = ""
FOR i = 1 TO n
cad$ = cad$ + s$
NEXT i
RETURN cad$
END FUNCTION
END PROGRAM</syntaxhighlight>
 
==={{header|Yabasic}}===
Line 918 ⟶ 1,035:
 
=={{header|Elena}}==
ELENA 46.x :
<syntaxhighlight lang="elena">import system'routines;
import extensions;
Line 925 ⟶ 1,042:
public program()
{
var s := new Range(0, 5).selectBy::(x => "ha").summarize(new StringWriter())
}</syntaxhighlight>
 
Line 1,499 ⟶ 1,616:
 
=={{header|langur}}==
<syntaxhighlight lang="langur">"ha" * 5</syntaxhighlight>
This example looks like Perl, but the x operator doesn't just multiply strings in langur.
<syntaxhighlight lang="langur">"ha" x 5</syntaxhighlight>
 
=={{header|Lasso}}==
Line 2,964 ⟶ 3,080:
 
=={{header|Wren}}==
<syntaxhighlight lang="ecmascriptwren">System.print("ha" * 5)</syntaxhighlight>
 
{{out}}
885

edits