Substring: Difference between revisions

→‎{{header|ASIC}}: Added a solution.
(Dialects of BASIC moved to the BASIC section.)
(→‎{{header|ASIC}}: Added a solution.)
Line 1,153:
6 FOR I = 1 TO L : IF MID$(S$,I,LEN(F$)) = F$ THEN PRINT MID$(S$,I,M) : RETURN
7 NEXT : RETURN</syntaxhighlight>
 
==={{header|ASIC}}===
<syntaxhighlight lang="basic">REM Substring
Base$ = "abcdefghijklmnopqrstuvwxyz"
N = 12
M = 5
 
REM Starting from N characters in and of M length.
Sub$ = MID$(Base$, N, M)
PRINT Sub$
 
REM Starting from N characters in, up to the end of the string.
L = LEN(Base$)
L = L - N
L = L + 1
Sub$ = MID$(Base$, N, L)
PRINT Sub$
 
REM Whole string minus last character.
L = LEN(Base$)
L = L - 1
Sub$ = LEFT$(Base$, L)
PRINT Sub$
 
REM Starting from a known character within the string and of M length.
B = INSTR(Base$, "b")
Sub$ = MID$(Base$, B, M)
PRINT Sub$
 
REM Starting from a known substring within the string and of M length.
Find$ = "pq"
B = INSTR(Base$, Find$)
Sub$ = MID$(Base$, B, M)
PRINT Sub$
END
</syntaxhighlight>
{{out}}
<pre>
lmnop
lmnopqrstuvwxyz
abcdefghijklmnopqrstuvwxy
bcdef
pqrst
</pre>
 
==={{header|BASIC256}}===
511

edits