I had to write a function that returns only true ASCII printable characters 
because when I performed a drag/drop operation from a searchable PDF, I 
discovered that Acrobat puts all kinds of hidden characters in the text that 
really messes with LC. It’s a simple function:

FUNCTION cleanASCII pString, pModeList, pCustomList
   /*
   pModeList is a comma delimited list that may contain the following values:
   "lowercase,uppercase,numbers,tabs,newlines,returns,spaces,symbols,custom"
   If custom is used, then a third paramaeter containing allowed characters 
must be supplied.
   */
   IF pModeList is empty THEN
      put " 0-9a-zA-Z" into tAllowedChars
   END IF

   IF pModeList contains dash THEN replace dash with "/" & dash in pModeList

   REPEAT for each item pMode in pModeList
      put word 1 of pMode into pMode

      SWITCH
            break
         CASE "tabs" is in pMode
            put "\t" AFTER tAllowedChars
            break
         CASE "newlines" is in pMode
            put "\n" BEFORE tAllowedChars
            break
         CASE "returns" is in pMode
            put "\r" BEFORE tAllowedChars -- currently not working
            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 pCustomList 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


On May 19, 2020, at 5:37 AM, Graham Samuel via use-livecode 
<use-livecode@lists.runrev.com<mailto:use-livecode@lists.runrev.com>> wrote:

Yep, that was it! I had pasted some text from elsewhere. The text **looks** 
perfectly normal (and the count of characters is the same as in the visual 
representation of them, so none apparently hidden), but in some way it must 
mess up the functioning of the Property Inspector. As Ralph confirms, the 
initial text (in a Label Field, it’s just “Label:”) can be changed via the 
Property Inspector without being specifically selected - in fact you can’t 
select the ‘contents’ text in the Property Inspector display. So IMHO it’s a 
bug, if a minor one. Will report it, but I don’t expect a quick solution. Odd, 
though.

Thanks to Ralph and Richard

Graham

_______________________________________________
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

Reply via email to