As promised here is my code, very simple, but useful for taking user input and parsing it down to just lowercase letters and numbers:
cls
input "What tool are you looking for?", tool_num_$
tool_num_$ = tool_num(tool_num_$)
print tool_num_$
wait key
end
function tool_num(tool_num_$)
remstart
This function will ask the user to input a tool number, which will then be parsed down to lowercase then have all
non-letter or number characters stripped. The result will then be returned.
Example:
user inputs T-8990-2
the function then turns it into lowercase, t-8990-2
the function then strips off all non number or letter characters leaving the result: t89902
remend
tool_num_$ = lower$(tool_num_$)
new_tool_num_$ = ""
length = len(tool_num_$)
letter_or_num = 0
rem check each character in the tool string and if a letter or number add it to the tool number return value
while length >= 0
char_$ = left$(tool_num_$, 1)
length = length - 1
select char_$
case "0"
letter_or_num = 1
endcase
case "1"
letter_or_num = 1
endcase
case "2"
letter_or_num = 1
endcase
case "3"
letter_or_num = 1
endcase
case "4"
letter_or_num = 1
endcase
case "5"
letter_or_num = 1
endcase
case "6"
letter_or_num = 1
endcase
case "7"
letter_or_num = 1
endcase
case "8"
letter_or_num = 1
endcase
case "9"
letter_or_num = 1
endcase
case "a"
letter_or_num = 1
endcase
case "b"
letter_or_num = 1
endcase
case "c"
letter_or_num = 1
endcase
case "d"
letter_or_num = 1
endcase
case "e"
letter_or_num = 1
endcase
case "f"
letter_or_num = 1
endcase
case "g"
letter_or_num = 1
endcase
case "h"
letter_or_num = 1
endcase
case "i"
letter_or_num = 1
endcase
case "j"
letter_or_num = 1
endcase
case "k"
letter_or_num = 1
endcase
case "l"
letter_or_num = 1
endcase
case "m"
letter_or_num = 1
endcase
case "n"
letter_or_num = 1
endcase
case "o"
letter_or_num = 1
endcase
case "p"
letter_or_num = 1
endcase
case "q"
letter_or_num = 1
endcase
case "r"
letter_or_num = 1
endcase
case "s"
letter_or_num = 1
endcase
case "t"
letter_or_num = 1
endcase
case "u"
letter_or_num = 1
endcase
case "v"
letter_or_num = 1
endcase
case "w"
letter_or_num = 1
endcase
case "x"
letter_or_num = 1
endcase
case "y"
letter_or_num = 1
endcase
case "z"
letter_or_num = 1
endcase
case default
letter_or_num = 0
endcase
endselect
rem now if the character is a letter or number we add it to the new tool number string
if letter_or_num
new_tool_num_$ = new_tool_num_$ + char_$
letter_or_num = 0
endif
tool_num_$ = Right$(tool_num_$, length)
endwhile
tool_num_$ = new_tool_num_$
endfunction tool_num_$
Oh yeah, forgot to say that it is DBP.