As posted in this thread: http://www.opto22.com/community/showthread.php?t=304&p=945#post945 , i thought it would be a nice candidate for the competition.
//loop around and check for an invalid character in a string
//valid ASCII characters are 0-9, A-Z and a-z
//decimal character codes are: 48-57, 65-90 and 97-122 respectively
//get the string length to check
nInvalidCharFound=0; //set true if we find an invalid char so we can bail asap
nIndex=0; //counter so we can loop through
nChar=0; //character at nIndex position
nChar=GetNthCharacter(sStringToCheck,nIndex); //get the character at index number
IncrementVariable(nIndex); //increment the index
//check to see if all 3 statements are valid. if the char is not within the limits specified then its invalid.
//add more as you see fit, even make the statics variables!!
nInvalidCharFound=nIndex-1; //set the invalidchar variable to the position it was found
until ((nInvalidCharFound<>0) or (nIndex==nStringLength)); //bail if we get an invalid char found or we have reached the end of the string
does as the code says, parses a string until an invalid character is found. can be hacked to suit accordingly...
Come on iPad!!!