Pasting information into scripts

You can paste the names of variables, functions, objects, controls, and other items directly into your scripts. (You can also use AutoScript. See “Using AutoScript”.) If what you paste includes commented text that you need to replace, such as function arguments or clauses in a statement, you can use Edit>Go To>Next Marker to move your cursor to the next commented item in the template.

Table 6-2: Pasting information into scripts

To paste

Use

PocketBuilder objects and their properties, functions, and events

System Tree

Properties, datatypes, functions, structures, variables, and objects

Browser

Contents of clipboard

Edit>Paste

Contents of Clipboard window

Drag and drop

Objects, controls, arguments, and global and instance variables

Paste buttons on PainterBar or Edit>Paste Special

PowerScript statements

Paste Statement button or Edit>Paste Special>Statement

SQL statements

Paste SQL button or Edit>Paste Special>SQL

Built-in, user-defined, and external functions

Paste Function button or Edit>Paste Special>Function

Contents of text files

Edit>Paste Special>From File

NoteUndoing a paste If you paste information into your script by mistake, click the Undo button or select Edit>Undo from the menu bar.

Some of these techniques are explained in the sections that follow.

Using the System Tree

To paste the name of a PocketBuilder object, or of any of its properties, functions, or events, select the item you want to paste in the System Tree and drag it into your script.

Using the Browser

You can use the Browser to paste the name of any property, datatype, function, structure, variable, or object in the application.

Most tab pages in the Browser have two panes. The left pane displays one type of object, such as a window or menu. The right pane displays the properties, events, functions, external functions, instance variables, shared variables, and structures associated with the object.

NoteGetting context-sensitive Help in the Browser To get context-sensitive Help for an object, control, or function, select Help from its pop-up menu.

StepsTo use the Browser to paste information into the Script view:

  1. Click the Browser button in the PowerBar, or select Tools>Browser.

  2. Select the PowerScript target you want to browse.

  3. Select the appropriate tab and then select the object in the left pane.

  4. Select the category of information you want to display by expanding the appropriate folder in the right pane.

  5. Select the information and click Copy.

  6. In the Script view, move the cursor where you want to paste the information and select any text you want to replace.

  7. Select Paste from the pop-up menu.

    PocketBuilder displays the information at the insertion point in the script, replacing any selected text.

Pasting statements

You can paste a template for all basic forms of the following PowerScript statements:

When you paste these statements into a script, prototype values display in the syntax to indicate conditions or actions.

StepsTo paste a PowerScript statement into the script:

  1. Place the insertion point where you want to paste the statement in the script.

  2. Select the Paste Statement button from the PainterBar, or select Edit>Paste Special>Statement from the menu bar.

  3. From the cascading menu, select the statement you want to paste.

    The statement prototype displays at the insertion point in the script.

  4. Replace the prototype values with the conditions you want to test and the actions you want to take based on the test results.

For more about PowerScript statements, see the PowerScript Reference in the online Help.

Pasting SQL

You can paste a SQL statement into your script instead of typing the statement.

StepsTo paste a SQL statement:

  1. Place the insertion point where you want to paste the SQL statement in the script.

  2. Click the Paste SQL button in the PainterBar, or select Edit>Paste Special>SQL from the menu bar.

  3. From the cascading menu, select the type of statement you want to insert.

    The appropriate dialog box displays so that you can create the SQL statement.

  4. Create the statement, then return to the Script view.

    The statement displays at the insertion point in the workspace.

For more about embedding SQL in scripts, see the PowerScript Reference in the online Help.

Pasting functions

You can paste any function into a script.

StepsTo paste a function into a script:

  1. Place the insertion point where you want to paste the function in the script.

  2. Click the Paste Function button in the PainterBar, or select Edit>Paste Special>Function from the menu bar.

  3. Choose the type of function you want to paste: built-in, user-defined, or external.

  4. Double-click the function you want from the list that displays.

    PocketBuilder pastes the function into the script and places the cursor within the parentheses so that you can define any needed arguments.

For more about pasting user-defined functions, see “Pasting user-defined functions”. For more about external and built-in functions, see the Resource Guide.

Pasting contents of files

If you have code that is common across different scripts, you can keep that code in a text file, then paste it into new scripts you write. For shorter snippets of code, you can also use the Clip window. See “The Clip window”.

StepsTo import the contents of a file into the Script view:

  1. Place the insertion point where you want the file contents pasted.

  2. Select Edit>Paste Special>From File from the menu bar.

    The Paste From File dialog box displays, listing all files with the extension SCR. If necessary, navigate to the directory that contains the script you want to paste.

  3. Choose the file containing the code you want. You can change the type of files displayed by changing the file specification in the File Name box.

    PocketBuilder copies the file into the Script view at the insertion point.

NoteSaving a script to a file To save all or part of a script to an external text file, select the code you want to save and copy and paste it to the File editor. Use the extension SCR to identify it as PowerScript code. You might want to use this technique to save a backup copy before you make major changes or so that you can use the code in other scripts.