DAT test BYTE "This is a test", 0 '***************************************************************************** ' This routine searches the string "ptr" for the character "val". ' It returns the address of the first occurance of "val" if found. ' Otherwise, it will return the address of the NULL at the end of the string. '***************************************************************************** PUB FindChar (ptr, val) REPEAT WHILE (BYTE[ptr]) IF (BYTE[ptr] == val) QUIT ptr ++ return ptr '***************************************************************************** ' This routine searches a string for the letter "A". If "mode" is zero, the ' string pointed to by "str" will be searched. Otherwise, the global variable ' "test" will be searched. This routine uses FindChar to do the search. '***************************************************************************** PUB FindA1 (str, mode) | ptr IF (mode == 0) ptr := FindChar( str, "a") else ptr := FindChar(@test, "a") return ptr '***************************************************************************** ' This routine searches a string for the letter "A". If "mode" is zero, the ' string pointed to by "str" will be searched. Otherwise, the global variable ' "test" will be searched. This routine does not use FindChar to do the ' search. '***************************************************************************** PUB FindA2 (str, mode) | i, ptr, val i := 0 val := "a" IF (mode == 0) REPEAT WHILE (BYTE[str][i]) IF (BYTE[str][i] == val) QUIT i ++ ptr := @BYTE[str][i] else REPEAT WHILE (test[i]) IF (test[i] == val) QUIT i ++ ptr := @test[i] return ptr