• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Check if Key is down?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Check if Key is down?


  • Subject: Re: Check if Key is down?
  • From: Matthew Smith <email@hidden>
  • Date: Tue, 25 Sep 2001 17:32:18 +1000

on 25/09/01 11:21, Ivan at email@hidden wrote:

> if (TempFolder as text = myFolder as text) then
> duplicate file Template
> set name of file ((Template as text) & " copy") to (genName & newName)
> else
> copy file Template to folder myFolder -- & genName & newName)
> set name of file (myFolder & (get name of Template) as text) to (genName &
> newName)
> end if

Couldn't you write this as:

Set newDocument to duplicate file template to folder myFolder
Set name of newDocument to genName & newName

You can use tell the duplicate command where you want the file. The result
of the duplicate command is an alias to the file. You can then use it to
refer to the new file, like changing its name.

You can also get the number as a string with leading zeros by doing:

set stringNum to characters 2 thru -1 of ((myNum + 1000) as text) as string

Where myNum is your number and stringNum is the resultant string. The idea
is you add 1 times 10 to the number of digits you want, and then take
characters from the second one to the end. (eg. 1 becomes 1001, which
becomes 001).

> property Template : "1-Winky:-Documents:ThorGazette:Thor 000"
> property TempFolder : "1-Winky:-Documents:ThorGazette:"
> property myFolder : "1-Winky:-Documents:ThorGazette:"

These would be better as:

property Template : ""
property myFolder : ""
...
If template = "" then
Set template to choose file "Select template file" of type {"abcd"}
End if
If myFolder = "" then
Set myFolder to choose folder "Select work folder"
End if

Note: replace abcd with the file type for Nisus documents (I don't know the
value).

This will prompt for the values the first time the script is run. It will
set them to aliases, so you don't have the paths hard coded. You probably
won't need a property for the template folder. It is part of the template
file. If you move the template or the folder where you place the resultant
file, the code should work without having to edit it, or even prompt for new
values.

--
Matthew


References: 
 >Check if Key is down? (From: Ivan <email@hidden>)

  • Prev by Date: Re: Command execution ala Director's message window
  • Next by Date: Re: Does anyone have experience with scripting Adobe Illustrator 9.0 and 9.02
  • Previous by thread: Re: Check if Key is down?
  • Next by thread: Sounds
  • Index(es):
    • Date
    • Thread