Os scripts necessitam de posiconamento dos elementos através coordenadas absolutas. Como é difícil desenhar estes diálogos, o engenheiro da Adobe que desenvolveu o PM Scripter, Dr. Vladimir Samarskiy, escreveu uma série de scripts que ajudam a se montar caixas de diálogo através de um documento do próprio PageMaker.
O engenheiro russo tem uma página com estas ferramentas há mais de 12 anos, mas coloco-as aqui para o caso de, algum dia, sua página ser desativada.
Use special kit of scripts and PageMaker to create a script which will display a dialog.
Table of Contents
- Scripts: Open Dialog Template | Align Controls | Adjust Dialog Box | Test Dialog | Save Dialog
- Sample Workflow
- Cross Platform Development
- How to download…
- Adobe Scripter
Dialog Builder is a family of several miscellaneous scripts. When used all together this scripts can significantly simplify development of dialog segment in your script.
This script creates a PageMaker document. The only page of the document is empty, but above the page on the pasteboard there are colored PageMaker text frames in piles. Each color corresponds to a certain type of a control. Initial text in the frame also hints on the control type.
Consider the page as a dialog box and text frames dragged onto the page from the pasteboard piles as a controls. One can move and reshape controls with the pointer tool and also edit text within the frames with a text tool thus modifying a caption or content of the control. Script Align Controls helps to refine position and size of the controls.
To change size of the dialog box use either File > Document Setup dialog or the script Adjust Dialog Box , to specify its position alternate zero point of the document.
Apply the script when several controls are selected. To align controls horizontally and/or vertically check corresponding checkbox and a radiobutton below the checkbox. Align left (top, right, bottom) means alignment to a leftmost (topmost, rightmost, botommost) position among all selected controls. For central alignment script will calculate average coordinate of all centers. The ‘Cascade’ options arranges centers of all selected objects into an arithmetical progression (outcome depends on the drawing order of the selected controls). The ‘Tile’ options tiles controls by X or Y coordinate. Tile option is usually combined with left (top,right,bottom) alignment of the other coordinate.
Script ‘Align Controls’ expects several objects selected. If just one group (use Element > Group or ^G) is selected, script modifies controls within the group. It is not recommended to apply the script when a group(s) and an individual controls are simultaneously selected.
Click here to see why would you use groups for dialog building.
This script will change page size of the document so that all objects on the page fit within margin box. Margins are not shown in the outcome dialog, hence margins can be used to secure an inset in a positions of a controls.
When you are done with positioning controls on the page, run the script to see the dialog preview. Exit from a dialog by any pushbutton or GoAway button. After inspecting the preview, dialog can be either alternate further on or save the outcome using script ‘Save Test Dialog’.
Script ‘Test Dialog’ can be used as a training tool when mastering in Dialog Builder.
Saves the newly created script in the same directory under the name specified
1. Run the script ‘Open Dialog Template’
2. Using a pointer tool, drag from the pasteboard piles onto the page as many controls as you need. Put them in the positions you would like to see them in a dialog. Only move and resize controls, do not rotate, reflect or skew them. Controls should not overlap each other.
If you have radiobuttons in your dialog, join radiobuttons into a group ( Element > Group or ^G ), thus ensuring their adjacent position in the display order. This is necessary or the Dialog Builder to understand these that the radiobuttons form a group and only one of them can be checked at a time.
If one of the pushbuttons should be the default pushbutton, put it first in the display order (Element > Arrange > Send to Back)
3. Use script ‘Align Controls’ to refine mutual positions of the controls.
4. Use script ‘Test Dialog’. Inspect dialog. Dismiss the dialog by pushing any pushbutton. To change number, size and position of controls return to step 2 or step 3.
5. After you satisfied with the preview, use the script ‘Save dialog‘. Type in a name of the script when prompted. Do not specify path in the filename edit window. Outcome script will be saved into the same directory where Dialog Builder scripts are located. 6. (Optionally) Now open the script in the script palette, copy it to clipboard (^C ) and paste into the script you are working on. I hope that amount of adjusting changes in the script will be minimal. Thus, for example, the PageMaker document below
yields the following dialog script:
Dialogbegin 0,0,187,98,"Dialog caption" Checkbox 72,23,127,39,"Option 2" Checkbox 72,3,128,18,"Option 1" Pushbutton 24,80,86,95,"OK" Static 3,55,65,70,"Enter some text :" Edit 71,55,122,70,"Text entered." Listbox 3,3,65,50,"Item 1","Item 2","Item 3","Item 4","Item 5","" Pushbutton 100,80,163,95,"Cancel" Radiobutton 134,3,184,18,"Choice 1" Radiobutton 134,21,184,37,"Choice 2" Radiobutton 134,40,184,56,"Choice 3" Dialogend return
To refine this script:
Radiobutton 134,3,184,18,"Choice 1"
Radiobutton 134,3,184,18,"Choice 1" , 1
to make sure that this radiobutton is checked at the initialization of the dialog.
b) Remove “” at the end of the listbox definition statement. Most often extra “” in the listbox definition is due to extra carriage returns typed into the text frame used for a listbox representation. Dialog Builder considers every paragraph as a list item and does not check if list item is empty.
c) Move pushbutton “OK” statement immediately after the Dialogbegin statement to have “OK” button outlined or hilited as a default button.
Now dialog script may look like that
Dialogbegin 0,0,187,98,"Dialog caption" Pushbutton 24,80,86,95,"OK" Pushbutton 100,80,163,95,"Cancel" Checkbox 72,23,127,39,"Option 2" Checkbox 72,3,128,18,"Option 1" Static 3,55,65,70,"Enter some text :" Edit 71,55,122,70,"Text entered." Listbox 3,3,65,50,"Item 1","Item 2","Item 3","Item 4","Item 5" Radiobutton 134,3,184,18,"Choice 1",1 Radiobutton 134,21,184,37,"Choice 2" Radiobutton 134,40,184,56,"Choice 3" Dialogend return
Dialog Builder builds a dialog script valid for the platform on which Dialog Builder is installed. For example, if you are working in Windows the resulting script will look fine on Windows but not on Macintosh. To obtain dialog script for another platform, script Save Dialog should be edited as follows:
When working on Windows and trying to get Macintosh dialog script, insert (temporary ) script line
platform = MACINTOSH
just after the line
getplatform >> platform
When working on Macintosh and trying to get Windows dialog script, insert ( temporary ) script line
platform = WINDOWS
just after the line
getplatform >> platform
Save Macintosh and Window scripts under different names and after that merge them into one if … endif statement:
getplatform >> platform if platform = WINDOWS -- paste Windows dialog script here else -- paste Macintosh dialog script here endif
See, for example, cross platform dialog in the script Save Dialog
Store all the scripts from Dialog Building kit in one folder. Keep it within the folder ‘… PlugIns:Scripts’ to make all scripts visible in the Script Palette.
Shift-click (WIN) or click-hold (Mac) on a name below. When Save As common dialog appears navigate into the destination folder and drop script there. Do the same with other scripts.
[N. do Editor: Baixe todos estes scripts, este manual e o executável Adobe Scripter. Coloque a pasta zipada na pasta de scripts do PageMaker, geralmente "c:\Arquivos de programas\Adobe\PageMaker 7.0\RSRC\BRASIL\PLUGINS\Roteiros\".]
Adobe Scripter is a stand alone application which helps to write, edit, run and debug scripts. Run this application simultaneously with PageMaker.
This is a sketch of Scripter’s functionality following a menu commands.
- File > New : Opens new script. Default name of the script is ‘untitled.spt’. Application creates a file ‘untitled.spt’ in its home directory. On Macintosh platform File > New creates a new window so this menu command is available only after File > Close
- File > Open : Opens existing script. Supports only short / 8.3 / names of files and directories.
- File > Save; File > Save As : Saves the script in the text editor.In case of File > Save saves previous version of the script with extension *.bak. Supports only short / 8.3 / names of files and directories.
- File > Close (Macintosh only) Closes edit window.
- File > Revert : Restores last saved script. (No ‘Watch your changes’ warning.)
- File > Print script; File > Print Selection : PageMaker should be running to execute this menu command.
- File > Quit – exit the application.
- Edit > Undo : Undo/Redo last Edit > xxx action. (available only on Windows platform)
- Edit > Cut ; Edit > Copy ; Edit > Paste ; Edit > Select All- as expected. Editing of the script is disabled while script is stopped in the debugger.
- Run > Run : Starts running script or continues running if the script has been stopped in the debugger. Before the executing of the very first line of the script Scripter saves the script from the script editor to a disk. Previous version of the script gets extention *.bak.
- Run > Step : Executes just one line of the script and stops. See log of executed commands in the right side of the application widow. If a subroutine
occurs, Run > Step goes into it. One can use Run > Step shortcut ( F 8) to throw currently running script into the debugger .
- Run > Step Out. Completes the loop or subroutine, whichever is immediate, and stops in the debugger again.
- Run > Reset : Stops the script; closes all scripts and subroutine files, however spares variables so that variables still can be inspected later on using Vars > Inspect.
- Run > Verify : Verifies script for errors. Before verification starts, script is saved to a disk ( no *.bak version for this action ). Click here to learn more about the Verifier
- Vars > Inspect : Shows in the edit window list of all current variables ( including local ones of a subroutines ) and their current values. Use File > Revert to reload script into the edit window. Note that Vars > Inspect command does not save the content of the edit window to disk. It means that after Vars > Inspect all unsaved modification of the script are lost. It is possible to continue tracing with variables in the edit window instead of the script.
- Vars > Evaluate : To change current value of the variable edit the value to the left of the ‘ = ‘ and use Vars > Evaluate command to update variables accordingly to the content of the edit window.
- Vars > Erase : Erases all variables.
Warning : On Windows platform it is not possible to use the Script Palette for executing or tracing a script if Adobe Scripter is running. To avoid this conflict when Adobe Scripter is opened run all scripts using Adobe Scripter ( e.g. copy / paste the script into the Adobe Scripter edit window ) or upgrade PMScript/PMTrace engine to a new version to avoid a software conflict.
Verifier ( Run > Verify ) reads all lines of the script one by one and checks lines for possible errors.
- Checks matching pairs of the script commands like if – endif, repeat – until etc. and how these constructs are nested.
- Checks syntax of the expressions that PMScript will have to calculate in the run time. Note that type of a variable ( number, string ) is defined at the run time, hence verifier gives no warranty that operations and functions will be applied to right type of variables. Instead Verifier only checks brackets and signs of operations without going any deep.
There are cases when Verifier is more strict then actual PMScript – see test report. If Verifier did not find errors, it indents script lines accordingly to how programming constructs are nested.
Verifier can find and report only one error at a time. When Verifier encounters an error it places error information as a comments at the erroneous line at stops verification.
Verifier is the most recent feature of the script engine, please let me know if / where it fails. (email@example.com)
Last update: 02/10/98
Verifier has been tested against scripts shipped with PageMaker 6.5. It failed to certify the following scripts:
1) Ligatures … spt, New Object Layers.spt – because dialogbegin – dialogend construct should be properly nested within if – endif construct. To meet this requirement, edit > cut dialogend line outside of the if – endif construct and edit > paste it twice into WINDOWS and MACINTOSH section of the dialog
2) Hanging character.spt – ‘;’ is not allowed in the comments because ‘;’ may mark end of the line. Replace
// check if para is empty; if yes - bail out
// check if para is empty, if yes - bail out
3) Styles info, Resize group, Number paragraphs – Memory overflow. Too long scripts for this version of Verifier.