How to remove a carriage return from a field?

Lynch, Jonathan bnz2 at
Thu Jan 19 16:11:31 CST 2006

Hi Claire, 

If you are building a file name, you might need to watch out for more
than just linefeeds.

Filenames generally should be limited to letters, numbers, and
underscore (hyphen is usually ok too)

You can be strict about this using the keydown and rawkeydown handlers.
It would look like this:

On RawKeyDown pKey
  Put "abcdefghijklmnopqrstuvwxyz1234567890_-" into tCharList
  If ((the commandkey is down) and (numtochar(pkey)="v")) or (pKey =
65379) then
    Put the clipboarddata["text"] into tPastedText
    Repeat for each char tChar in tPastedText
      If tChar is in tCharList then put tChar after tNewPastedText
    End repeat
    Put tNewPastedText into the selection
    Pass rawkeydown
  End if
End RawKeyDown

On Keydown pKey
  Put "abcdefghijklmnopqrstuvwxyz1234567890_-" into tCharList
  If pKey is in tCharList then pass keydown
End keydown

A couple notes
1) it is untested, let me know if it does not work and I will fix it for
2) 65379 is the raw key number for the insert key on a typical windows
keyboard. This might be different on your keyboard.

Good luck,


-----Original Message-----
From: use-revolution-bounces at
[mailto:use-revolution-bounces at] On Behalf Of Martin
Sent: Thursday, January 19, 2006 4:38 PM
To: How to use Revolution
Subject: Re: How to remove a carriage return from a field?

Claire Bradin Siskin wrote:
> In my stack, the user enters identifying information into a field, and

> this text is used to build a filename for ftp upload. This works fine
> long as the user does not enter a carriage return at the end of the 
> field. If the user does press "enter," this messes up the upload. How 
> can I script it so that any carriage returns are removed from the
> Suggestions for actual scripts would be very much appreciated since I
> a newbie. :-)
> Thanks very much,

or this field script:

on closefield
   put line 1 of me into me
end closefield

use-revolution mailing list
use-revolution at
Please visit this url to subscribe, unsubscribe and manage your
subscription preferences:

More information about the use-livecode mailing list