|
Post by alexfish on Dec 29, 2020 15:31:05 GMT 1
and using the last occur
'strrchr' and first occur 'strchr' BR Alex
LOCAL B$ TYPE STRING B$ = B$ & "test" & CHR$(34) & " these " & CHR$(34) & " = " & CHR$(39) & " bits" PRINT B$
LOCAL C$ TYPE STRING
C$ = strchr(B$,39)
IF LEN(C$) THEN PRINT C$ ELSE PRINT "not found" END IF
C$ = strchr(B$,34)
IF LEN(C$) THEN PRINT C$ ELSE PRINT "not found" END IF
C$ = strrchr(B$,34)
IF LEN(C$) THEN PRINT C$ ELSE PRINT "not found" END IF
|
|
|
Post by vovchik on Dec 29, 2020 15:59:19 GMT 1
Dear Alex,
Thanks. Very useful string functions... Have to keep them in mind for future code.
With kind regards, vovchik
|
|
|
Post by alexfish on Dec 29, 2020 18:21:20 GMT 1
Dear Alex, Thanks. Very useful string functions... Have to keep them in mind for future code. With kind regards, vovchik Thank for looking. I am a bit behind the times with all the new features in BaCon', need to do some homework yet I find those 'strchr' and strrchr' also very usefull when used incombination with REVERSE$,REPLACE$ BR Alex
|
|
|
Post by alexfish on Jan 3, 2021 12:57:46 GMT 1
Hi All
whilst there is a while and for loop using argc count/amount
thought about this while loop without argc count/amount : test NULL :: edit now works with test NULL
LOCAL arg =0 TYPE int LOCAL arg$ TYPE STRING
WHILE (argv[arg] ) DO arg$ = argv[arg] PRINT arg$ INCR arg WEND
BR Alex
|
|
|
Post by alexfish on Jan 3, 2021 13:23:01 GMT 1
And then apply same NULL to a string
note bacon throws a warning but if do work, now FIXED
LOCAL str$ = "test these 'bits'" TYPE STRING LOCAL ch = 0 TYPE int LOCAL A$ TYPE STRING WHILE (str$[ch]) DO A$ = CHR$(str$[ch]) IF A$ = "'" THEN PRINT "Found :" & A$ END IF INCR ch WEND
ADDED: with postions Edited to get rid of warnings
LOCAL str$ = "'test these 'bits'" TYPE STRING LOCAL ch = 0 TYPE int LOCAL A$ TYPE STRING WHILE (str$[ch] ) DO A$ = CHR$(str$[ch]) IF A$ = "'" THEN PRINT "postion :" , ch+1 , " :Found :" & A$
END IF INCR ch WEND
BR Alex
|
|