Re: New Iteration of cleanASCII
I had a condition there I didn't need (there) so I moved it but forgot to delete the break. Bob S > On Mar 23, 2017, at 07:23 , Tiemo Hollmann TB via use-livecode >wrote: > > Hi Bob, nice function. > Just for my interest, what is the function of the leading "break" in the > switch control structure? It doesn't seem to bother, but any advantage? > Tiemo ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: New Iteration of cleanASCII
Probably a typo. Bob S > On Mar 23, 2017, at 07:23 , Tiemo Hollmann TB via use-livecode >wrote: > > Hi Bob, nice function. > Just for my interest, what is the function of the leading "break" in the > switch control structure? It doesn't seem to bother, but any advantage? > Tiemo ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
AW: New Iteration of cleanASCII
Hi Bob, nice function. Just for my interest, what is the function of the leading "break" in the switch control structure? It doesn't seem to bother, but any advantage? Tiemo -Ursprüngliche Nachricht- Von: use-livecode [mailto:use-livecode-boun...@lists.runrev.com] Im Auftrag von Bob Sneidar via use-livecode Gesendet: Mittwoch, 22. März 2017 23:21 An: How to use LiveCode <use-livecode@lists.runrev.com> Cc: Bob Sneidar <bobsnei...@iotecdigital.com> Betreff: Re: New Iteration of cleanASCII cleanASCII(pString, pModeList, pCustomChars) Belay my last. I refactored the whole thing to be much more robust. Pass a string, a modelist and a custom list. This will act as a simple regex character filter for any string you pass it. (Great for filtering out hidden/non-printing characters!) If you only pass it a string and no arguements, it will return uppercase, lowercase, numbers and spaces. The modelist can be any items in "tabs,newlines,returns,spaces,numbers,lowercase,uppercase,symbols,custom". If the modelist contains "custom" then pass any other characters you want to include in pCustomList. Modifications welcome, but remember this is just a character by character filter and NOT a full blown regex replacement. That would put me in the funny farm for sure. Bob S function cleanASCII pString, pModeList, pCustomChars if pModeList is empty then put " 0-9a-zA-Z" into tAllowedChars end if repeat for each item pMode in pModeList switch break case "tabs" is in pMode put "\t" after tAllowedChars break case "newlines" is in pMode put "\n" after tAllowedChars break case "returns" is in pMode put "\r" after tAllowedChars break case "spaces" is in pMode put " " after tAllowedChars break case "numbers" is in pMode put "0-9" after tAllowedChars break case "lowercase" is in pMode put "a-z" after tAllowedChars break case "uppercase" is in pMode put "A-Z" after tAllowedChars break case "symbols" is in pMode put "!#$%&'()*+,./:;<=>?@[\\_`{|}~^-" after tAllowedChars break case pMode is "custom" put pCustomChars after tAllowedChars break end switch end repeat put "[" & tAllowedChars & "]" into tMatchText repeat for each character theChar in pString if matchtext(theChar, tMatchText) is true then put theChar after cleanString end if end repeat return cleanString end cleanASCII Bob S ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: New Iteration of cleanASCII
cleanASCII(pString, pModeList, pCustomChars) Belay my last. I refactored the whole thing to be much more robust. Pass a string, a modelist and a custom list. This will act as a simple regex character filter for any string you pass it. (Great for filtering out hidden/non-printing characters!) If you only pass it a string and no arguements, it will return uppercase, lowercase, numbers and spaces. The modelist can be any items in "tabs,newlines,returns,spaces,numbers,lowercase,uppercase,symbols,custom". If the modelist contains "custom" then pass any other characters you want to include in pCustomList. Modifications welcome, but remember this is just a character by character filter and NOT a full blown regex replacement. That would put me in the funny farm for sure. Bob S function cleanASCII pString, pModeList, pCustomChars if pModeList is empty then put " 0-9a-zA-Z" into tAllowedChars end if repeat for each item pMode in pModeList switch break case "tabs" is in pMode put "\t" after tAllowedChars break case "newlines" is in pMode put "\n" after tAllowedChars break case "returns" is in pMode put "\r" after tAllowedChars break case "spaces" is in pMode put " " after tAllowedChars break case "numbers" is in pMode put "0-9" after tAllowedChars break case "lowercase" is in pMode put "a-z" after tAllowedChars break case "uppercase" is in pMode put "A-Z" after tAllowedChars break case "symbols" is in pMode put "!#$%&'()*+,./:;<=>?@[\\_`{|}~^-" after tAllowedChars break case pMode is "custom" put pCustomChars after tAllowedChars break end switch end repeat put "[" & tAllowedChars & "]" into tMatchText repeat for each character theChar in pString if matchtext(theChar, tMatchText) is true then put theChar after cleanString end if end repeat return cleanString end cleanASCII Bob S ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: New Iteration of cleanASCII
Be sure to use an appropriate video card: Markham, ON - In a joint announcement today the Nethack Devteam announced a new version of the popular text based game, version 3.4.1, but the big announcement came from ATI which announced a new video card, the ATI Radeon 9500 ASC, optimized for ASCII gaming. . . . http://www.bbspot.com/News/2003/02/ati_ascii.html :) -- Dr. Richard E. Hawkins, Esq. (702) 508-8462 ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
New Iteration of cleanASCII
Hi all. A while back I wrote a function that would remove all characters from a string except for 0-9, a-z, and A-Z. I have updated it to also include an arguement for other allowed characters, and true or false for line breaks and or carriage returns. Note the code below. What I need is a list of reserved regex characters, like backslash (\) and whatnot. Once tuned up it can be added to the Master Library (I think an older version may be there already). function cleanASCII pString, pAllowedChars, pAllowBreaks put "*|\" into lReservedChars put pAllowedChars into tCharList repeat for each char tChar in pAllowedChars if tChar is in lReservedChars then replace tChar with "\" & tChar in tCharList end repeat if pAllowBreaks is empty then put false into pAllowBreaks put "[ 0-9A-Za-z]" into tMatchText put tCharList after char 2 of tMatchText if pAllowBreaks then put "\r\n" after char 1 of tMatchText end if repeat for each character theChar in pString /* if theChar is "|" then put theChar after cleanString -- special case for regex reserved char next repeat end if */ if matchtext(theChar, tMatchText) is true then put theChar after cleanString end if end repeat return cleanString end cleanASCII Bob S ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode