Re: Field Properties

Scott Raney (raney@metacard.com)
Tue, 25 Feb 1997 11:39:00 -0700 (MST)

On Tue, 25 Feb 1997, Simon Lord wrote:

> Is there a way I can edit the script of the "Import" button on the Field
> Properties dialog? I want to add a script that will set the name of the
> field to the name of the imported text automatically. Unix names are so
> picky that I'm bound to mess up and want to pass on the responsibilities
> of naming these fields to the import btn.

You can edit the script of that button (in fact, you can edit the
scripts of *any* of the tools in development environment). Generally
the easiest way to do this is by editing the script directly rather
than trying to open up the window as a toplevel stack and then
selecting the object manually. You can get to a script directly by
running something like the following in the Message Box:

edit script of button "Import..." of stack "Properties"

But I'd recommend instead making a new button someplace that does what
you need. The Utilities stack would be one good place to put such a
button. This way, you won't lose your changes when you upgrade the
tools stack, and you'll continue to have access to standard
functionality if you ever need it again.

The script of that importer button is pretty simple:
on mouseUp
answer file "Choose a file to import..."
if it is not empty then
set the cursor to watch
local fname
put it into fname
open file fname for read
if the result is not empty then
answer "Can't open file" && fname
exit to MetaCard
end if
read from file fname until eof
put it into field "text"
close file fname
set the text of the selectedObject to field "text"
end if
end mouseUp

> --
> [---------------------------] Simon Lord
> [Important letters that.....] Database Engineer, CAE Electronics
> [contain no errors will.....] tel: (514) 341-2000 x3861
> [develop errors in the mail.] fax: (514) 340-5496
> [---------------------------] email: simonl@cae.ca
>

***************************************************************
Scott Raney raney@metacard.com http://www.metacard.com
Any sufficiently advanced technology
is virtually indistinguishable from magic -- Clark's law