|
Post by B+ on Sept 9, 2018 12:54:25 GMT
'Handy LeftOf and RightOf Functions.txt, by B+ 2018-09-09
calc$ = "1 - 2 + 3 - 4 + 5 - 6 + 7 - 8 + 9 - 10 + 11 - 12 + 13" copyCalc$ = calc$
while len(calc$) nORo$ = LeftOf$(calc$, " ") calc$ = RightOf$(calc$, " ") if instr("+-", nORo$) then op$ = nORo$ else select case op$ case "" : sum = val(nORo$) case "+": sum = sum + val(nORo$) case "-": sum = sum - val(nORo$) case else : print "Error: maybe you forgot to include the LeftOf$() or RightOf$ functions?" : end end select end if wend print "And the sum of ";copyCalc$;" = ";sum
FUNCTION LeftOf$ (source$, of$) posOf = INSTR(source$, of$) IF posOf > 0 THEN LeftOf$ = MID$(source$, 1, posOf - 1) END FUNCTION
FUNCTION RightOf$ (source$, of$) posOf = INSTR(source$, of$) IF posOf > 0 THEN RightOf$ = MID$(source$, posOf + LEN(of$)) END FUNCTION
|
|