!------------------------------------------------------------------------------ !bnopunc.sqc is a procedure written in SQR to scrub punctuation. !Copyright (C) 2007 Mike Putnam ! !This program is free software; you can redistribute it and/or modify it under !the terms of the GNU General Public License as published by the Free Software !Foundation; either version 2 of the License, or (at your option) any later !version. ! !This program is distributed in the hope that it will be useful, but WITHOUT !ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS !FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. ! !You should have received a copy of the GNU General Public License along with !this program; if not, write to the Free Software Foundation, Inc., 675 Mass !Ave, Cambridge, MA 02139, USA. !----------------------------------------------------------------------------- ! Change log: ! - Version 1.0 released. !----------------------------------------------------------------------------- !This procedure scrubs everything that is not a uppercase/lowercase letter, !a space, or a number from a given string. It does so by checking the ASCII !value of every position in the string and discarding the unwanted positions. !It returns the results to the same variable it was provided for input. ! !ASCII codes this procedure cares about !Literal spaces: ' ' [032] !Alpha: A-Z [065-090] and a-z [097-122] !Numeric: 0-9 [048-057] ! !Usage example: do no-punctuation($somestring) begin-procedure no-punctuation(:$instring) let $outstring = '' let #len-instring = length($instring) let #character-counter = 1 while #character-counter <= #len-instring let $current-character = substr($instring,#character-counter, 1) let #ascii-code = ascii($current-character) if (#ascii-code >= 65 and #ascii-code <= 90) or (#ascii-code >= 97 and #ascii-code <= 122) or (#ascii-code = 32) or (#ascii-code >= 48 and #ascii-code <= 57) let $outstring = $outstring || $current-character end-if let #character-counter = #character-counter + 1 end-while let $instring = $outstring end-procedure