Q: How `opendialog' and `saveasdialog' work:
A:
`opendialog' and `saveasdialog' command display OpenFile or SaveAsFile common dialog box and wait while user navigates to a certain file. After user hits "Open", "Save" or "Cancel" button command returns name of the choosen file as a quoted string ("" if dialog was cancelled ). Syntax and limitations depend on the platform.
Windows:
opendialog sDir, sFiltDescriptor, sFiltPattern, sFiltDescriptor, sFiltPattern,...
saveasdialog sDir, sFiltDescriptor, sFiltPattern, sFiltDescriptor, sFiltPattern,...
Commands allow arbitrary number of (sFiltDescriptor,sFiltPattern) pairs.
All parameters are quoted strings:
sDir - directory listed in the common dialog from which user navigates
to the target file.
sFiltDescriptor - Description of the filter exactly as appears in the "Files
of type" /"List files of type" combobox at the bottom of
the dialog box.
sFiltPattern - File mask which defines filter.
Example:
opendialog "C:\PgMkr","PageMaker files","*.p65","Text
files","*.txt" >> fName
Current limitations and warnings: 16bit version of the Script Engine
handles only with short file names ( 8.3 format ). Script engine shipped
with PageMaker 6.5 may crash when user tries to enter long file name into
16bit common dialog box. This should be fixed in PageMaker 6.51 or PageMaker
6.52.
Wait for 32 bit Scripter for long file names in the 'opendialog' /'saveasdialog'
commands and many other upcoming atractions.
Macintosh:
opendialog sDir,sFileType1,sFileType2,sFileType3,sFileType4
saveasdialog sDir,sFileType1,sFileType2,sFileType3,sFileType4
All parameters are quoted strings.
First parameter hints where navigation to the file should start, however
it is just a recomendation and may be ignored.
sFileType1,...,sFileType4 - each string contains within quotes exactly
4 chars which specify type(s) of the files listed in the common dialog.
Last 3 parameters can be omitted.
Examples:
1)
saveasdialog "","AB65" >> whereTo
This line will display file save dialog with PageMaker files listed in
it.
2)
opendialog "","AB65","AT65" >> what
This will display file open dialog box with PageMaker documents and Pagemaker
templates listed.
Further hints:
- If in doubt, use { File > Get File/Folder info } menu command of the
ResEdit to see how the file type is specified
- Use getplatform query in your script to find out on which platform script
is running:
getplatform >> platform
if platform = WINDOWS
opendialog "C:\TxtDocs","Text files","*.txt"
>> loc
elseif platform = MACINTOSH
opendialog "","TEXT" >> loc
endif
Q: PMscript is intolerant of trailing backlashes in pathnames.
A:
Yes. It is a consequence of the \" way of putting a quote inside
already quoted string.
If you need to use backslash at the end of path, you may consider doing
something like this:
FileTitle = "MyDoc.p65"
Path = "C:\PgMkr"
FileName = Path + quote(ascii(92)) + FileTitle
Q: When to use quotes? ( in a nutshell )
A: I would suggest the following ( simplified
) rule(s) for the beginners in PMScript:
1. Names of variables do NOT require quotes
2. Numerical constants do NOT require quotes
3. Keywords in Pagemaker commands ( like column,left,on,off etc ... ) inherited
from PM6.0 scripting do NOT require quotes. (and can be replaced by their
numerical equivalents anyway.)
4. In all other cases use quotes.
If rules 1-4 do not work:
see descripting of PageMaker command in a Script Language Guide or
Help>Help topics>Script Language Guide > Quick Reference >
Index of Comands and Queries
and see description of the script programming construct in a book "Adobe
PageMaker Scripting", Hans Hansen
or at http://www.oz.net/~vsamarsk/KeyWords.html