Page 1 of 1

LengthLimit in fld when pasting

Posted: Wed Jan 05, 2011 12:38 pm
by jmburnod
Hi All,
This script limit the num of chars in a fld when the user paste a text in the field
Meaby you have a more simple way

Code: Select all

on commandKeyDown pKey
   if pKey is "V" then
      put the clipboardData["text"] into MonCB
      put the length of MonCB into NbCCB
      put the selectedchunk into bufCC
      put the value of word 2 of bufCC into depC
      put the value of word 4 of bufCC into FinC
      put last word of bufCC into LeFld
      if depC > FinC then
         put the length of fld LeFld into NbCfld
      else
         put FinC-depC+1 into NbCfld
      end if
      put NbCCB+NbCfld into NbCharsTot
      put NbCharsTot
      if NbCharsTot > 10 then
         beep
      else
         pass commandKeyDown
      end if
   else
      pass commandKeyDown
   end if
end commandKeyDown
Best

Jean-Marc

Re: LengthLimit in fld when pasting

Posted: Mon Jan 10, 2011 1:26 am
by Mark
Hi Jean-=Marc,

The following approach seems easier to me.

Code: Select all

on commandKeyDown theKey
  put 1000 into myLimit
  if theKey is "V" then
    put char 1 to (myLimit - number of chars of the text of me) of \
      the clipboardData["text"] into the selection
  else pass commandKeyDown
end commandKeyDown
I didn't test this script.

Kind regards,

Mark

Re: LengthLimit in fld when pasting

Posted: Mon Jan 10, 2011 9:28 am
by jmburnod
Hi Mark,

Yes, it work if the script is in fld script

Thank

Jean-Marc