Part of the Samples Website. 8/16/97.

samples.basicStuff.customDialog

«Shows you how to implement a custom dialog in Frontier
«This script allows you to change the type and creator of any file
«It's also a sample for doing custom dialogs in Frontier
«
«The dialog it's running is in the Dialogs folder
«In the same folder as the Frontier application
«If you write your own custom dialog you should...
«Design the dialog using a resource editor.
«Make sure that the DLOG resource id is 25000.
«Same for the DITL resource.
«Take note of the item numbers, they're used in the script.
«In dialog.getValue and dialog.setValue calls.
«How the script works:
«It prompts for a file of any type (that's what the 0 is for).
«...in the file.getFileDialog call
«Then it calls dialog.runFromFile, which repeatedly calls itemHit.
«itemHit is prepared for 3 kinds of "hits":
«a signal from Frontier to initialize the dialog
«this will come just as the dialog is opening
«it allows you to set the initial values of the fields
«a click on the OK button
«we save off the values entered in the dialog
«and send a signal back to Frontier to close the dialog
«a click on the Cancel button
«we send a signal back to Frontier to close the dialog
«
«Hope this helps!
«
«11/9/93 DW
local (f)
if not file.getFileDialog ("Select a file...", @f, 0)
return
on itemHit (itemNum) «return false to close the dialog, true to keep it open
case itemNum
-1 «signal from Frontier to initialize the fields
dialog.setValue (3, "File "" + file.fileFromPath (f) + "":")
dialog.setValue (4, file.type (f))
dialog.setValue (5, file.creator (f))
return (true)
1 «user clicked on OK
try
on getField (fieldNum)
local (s)
s = dialog.getValue (fieldNum)
if sizeOf (s) [not equal] 4
scriptError ("Types and creators must be exactly four characters long.")
return (s)
file.setType (f, getField (4))
file.setCreator (f, getField (5))
return (false) «everything worked, close the dialog
else
dialog.alert (tryError) «display the error message
return (true) «keep the dialog open
2 «user clicked on Cancel
return (false) «close the dialog
else
return (true) «keep going if item isn't OK or Cancel
dialog.runFromFile ("Creator & Type Dialog.DW", 1, @itemHit)


This page was last built on Sat, Aug 16, 1997 at 6:34:44 PM. You can download the current set of sample scripts from our FTP site. Dave