Strip comments from a string: Difference between revisions

Line 354:
}</lang>
 
=={{header|BBCANSI BASIC}}==
<lang ansibasic>100 DECLARE EXTERNAL FUNCTION FNstripcomment$
<lang bbcbasic> marker$ = "#;"
110 LET marker$="#;"
PRINT FNstripcomment("apples, pears # and bananas", marker$)
120 PRINT """";FNstripcomment$("apples, pears ;# and bananas", marker$);""""
130 PRINT """";FNstripcomment$(" apples, pears ; and bananas", marker$);""""
140 PRINT """";FNstripcomment$(" apples, pears # and bananas", marker$);""""
150 END
160 !
170 EXTERNAL DEFFUNCTION FNstripcomment$(text$, delim$)
LOCAL I%, D%
180 FOR I% = 1 TO LEN(delim$)
190 LET D% = INSTRPOS(text$, MIDdelim$(delim$, I%, 1:I))
200 IF D>0 THEN IF D%LET text$ = LEFTtext$(text$, 1:D%-1)
210 NEXT I%
220 LET FNstripcomment$=RTRIM$(text$)
WHILE ASC(text$) = 32 text$ = MID$(text$,2) : ENDWHILE
230 END FUNCTION</lang>
WHILE LEFT$(text$) = " " text$ = RIGHT$(text$) : ENDWHILE
= text$</lang>
 
=={{header|Bracmat}}==