RosettaCodeData/Task/Strip-comments-from-a-string/ANSI-BASIC/strip-comments-from-a-string.basic

15 lines
530 B
Text
Raw Permalink Normal View History

2023-07-01 11:58:00 -04:00
100 DECLARE EXTERNAL FUNCTION FNstripcomment$
110 LET marker$="#;"
120 PRINT """";FNstripcomment$("apples, pears # and bananas", marker$);""""
130 PRINT """";FNstripcomment$("apples, pears ; and bananas", marker$);""""
140 PRINT """";FNstripcomment$(" apples, pears ", marker$);""""
150 END
160 !
170 EXTERNAL FUNCTION FNstripcomment$(text$, delim$)
180 FOR I=1 TO LEN(delim$)
190 LET D = POS(text$, delim$(I:I))
200 IF D>0 THEN LET text$ = text$(1:D-1)
210 NEXT I
220 LET FNstripcomment$=RTRIM$(text$)
230 END FUNCTION