Re: Check if Key is down?
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