LoginLogin

Variable contains reading?

Root / Programming Questions / [.]

ErtasCreated:
Is there a way to read a variable and say it contains ... Example If my variable contains “72901003” then i want it to know if it contains number 3, is there a code for that?

The function STRSRCH in the following code yields TRUE if the first string argument includes the second string argument and FALSE if not.
DEF STRSRCH(A$,B$)
VAR LA=LEN(A$),LB=LEN(B$)
VAR I
IF LB>LA THEN RETURN FALSE
FOR I=0 TO LA-LB
 IF MID$(A$,I,LB)==B$ THEN RETURN TRUE
NEXT I
RETURN FALSE
END

READ A$,B$

IF STRSRCH(A$,B$) THEN
 ?A$;:?" INCLUDES ";:?B$;:?"."
ELSE
 ?A$;:?" DOESN'T INCLUDE ";:?B$;:?"."
ENDIF

DATA "7291003","03"

For very simple searches on strings, you might be able to use INSTR()
>INSTR: Searches for the target character string in another character string >>Variable = INSTR( [Start position,] "Character string to search in", "Character string to search" )
INSTR(S$, "...") > -1
or more hacklike with numbers
INSTR(STR$(72901003), "3") > -1

Thanks, i have figured it out now i can continue to my project