Writing Scripts
\The Sandbox \PB History & Future \New In PB7 \Nonmodal Development \Common Views \Writing Scripts
Variables &
External Fns
Defining
Functions
Defining 
User Events
Using
AutoScript

Description

The Script painter has been replaced by the Script view. In the Script view, you write and edit function and event scripts and define your own functions and events. This screen shows the Script view with the Prototype window for a user-defined function open:

The Script view has three new dropdown listboxes: in the first you select the object, control, or menu item for which you want to write the script or you select the special entries [Functions] and [Declare]; in the second you select the event or function you want to edit or, when Declare is selected in the first list box, the kind of declaration you want to make; in the third you select the current object or an ancestor object for easy display of object or function scripts.

Selection in first dropdown listbox

Contents of second dropdown listbox

Contents of third dropdown listbox

Object, control, or menu item for which you want to write the script

Events to edit for the selected object, control, or menu item or [New Event]

Current object and all ancestor objects

[Functions] to edit function scripts

Function to edit or [New Function]

All ancestor objects with functions having the same signature as the selected function

[Declare] to declare variables and external functions

Kind of declaration you want to make: global, local, and instance variables, and global and local external functions

Empty

The Paste listboxes that were in the Script painter have been removed; you use Paste Special from the Edit or popup menu or the Paste buttons on the PainterBar to paste control names, arguments, and variables into scripts.

The Prototype window at the top of the view displays automatically when you define a new function or event. An Error window displays at the bottom of the view when there are compilation errors. You can toggle the display of these windows with the two toggle buttons to the right of the listboxes.

When you're entering code in the Script view, a popup window displays when you pause listing possible completions for the statement you are typing. For more information, see Using AutoScript.

Usage

Whether you're coding a script for an application, a window, a user object, or a menu, a Script view is usually part of your default layout. To compare scripts and cut and paste between scripts, you can open multiple Script views.

To do this

Do this

See more than one script at a time

Select View>Script to open new Script views. When you double-click a function or event from a list, its script opens in the last-touched Script view (if there are errors in the previous script, an error window displays instead)

See the ancestor version of a script you're editing

Select the ancestor's name from the third dropdown listbox or select GoTo>Ancestor Script from the Edit or popup menu

Extend an ancestor script (the default is override)

Select Extend Ancestor Script from the Edit or Design menu. A checkmark displays next to the menu item. To override an ancestor script, make sure that Extend Ancestor Script is not checked

Comment out a line of code

Select Comment Selection from the Edit or Popup menu or from the PainterBar

Compile a script

Select Compile from the Edit or popup menu. Scripts are also compiled when you select a new script in the same view, close the view, or close the painter

Edit a script for a different event

Select the event name from the second listbox or double-click it in the Event List view

Edit a script for a different object

Select the object name from the first listbox or double-click it in the Layout view

Edit a script for a user-defined function

Select [Functions] from the first listbox and the function name from the second, or double-click the function in the Function List view

Declare or edit variables

Select [Declare] from the first listbox and the variable type from the second, then type the declaration in the Script view

Declare external functions

Select [Declare] from the first listbox and the function type from the second, then type the declaration in the Script view

Define object-level functions

Select Insert>Function from the menu bar or, in the Script view, select [New Function] from the second dropdown list, or in the Function List view, select Add from the popup menu

Define object-level structures

Select Insert>Structure or Add from the popup menu in the Structure List view

Define user events

Select Insert>Event or Add from the popup menu in the Event List view

Modify the prototype of the function or event you're editing

Click the Prototype toggle button to the right of the listboxes

Show or hide the Error window

Click the Error toggle button to the right of the listboxes

Paste objects, controls, arguments, and variables into a script

Select Paste Special from the Edit or popup menu or use the Paste buttons on the PainterBar

Paste functions, statements, or SQL statements into a script

Select Paste Special from the Edit or popup menu or use the Paste buttons on the PainterBar

Paste from a text file into a script

Select Paste Special from the Edit or popup menu or use the Paste buttons on the PainterBar

See also

Declaring variables and external functions
Defining functions
Defining user events
Using AutoScript

PBL Peeper PB Help PB History
& Future About Us Feedback Site Map

Google
 
Web www.techno-kitten.com
www.sybase.com