Contents   Index   Previous   Next



Generic Macros

The following table shows the macros that are defined by the system and can be included in any other macro. Some of them also take parameters.

A special kind of macros are listed under ‚Navigation‘. These do not paste text, but move the caret. This comes in very handy if you want to move the cursor to the start of the line before the actual text is pasted or you can move the cursor after you have pasted the text to a point inside the text that still needs some editing!

The examples that deal with code refer to the following script of the object w_Frame:

int of_SendEventToSheets(string as_event, boolean ab_noIcons)

Name

Descripton

Example

User Info

 

 

§username§

Programmer’s name

John BigMouth

§shortuser§

Short name

JBM

§company§

Name of the company

BM Unlimited

Script Info

 

 

§object§

Class or object for which the script is implemented

w_FrameAncestor

§routinekind§

Kind of routine: either Function or Event. Which text gets pasted can be defined in the options window.

Function

§returnvalue§

The class of the  return value of the script.

It gets changed into the case you defined in the sp_type.ini file.

Int

§retvar§

The return variable of the script.

§retvar§ translates to a variable that can be used in return statements. It consists of a prefix (here ‘l’ for local), a type id (here ‘i’ for Integer), and a name (here ‘_ret’).

For Boolean variables it would be 'lb_ret', for Long variables it would be 'll_ret'.

Which prefix is used can be defined in the file sp_type.ini, you find it in your SmartPaste directory. It should be pretty self-explanatory (well, hopefully!). There you can also define a string that comes before and after the type prefix.

li_ret

§retdef§

Return variable definition

This translates to something like
   Boolean b_ret
or
   DataStore ds_ret

If there is no return type, it translates to the empty string.

Int li_ret

§retstat§

Return statement

This translates to something like
   RETURN b_ret

or

   RETURN s_ret

If there is no return type, it translates to the empty string.

RETURN li_ret

§routinename§

Name of the routine

of_Sendeventtosheets

§parms§

Horizontal parameter list

Type case is changed according to sp_type.ini

String as_event, Boolean ab_noicons

§parms 20§

Vertical parameter list. Replace 20 with the number of the column to align the parameters.

Type case is changed according to sp_type.ini

           String as_event
           Boolean ab_noicons

§parms n§

Horizontal list of parameters without parameter types

as_event, ab_noicons

§parms n20§

Vertical parameter list without parameter types, with alignment column.

           as_event
           ab_noicons

§parms t§

Horizontal list of parameter types.

Type case is changed according to sp_type.ini

String, Boolean

§parms t20§

Vertical list of parameter types, with alignment column.

Type case is changed according to sp_type.ini

           String
           Boolean

§parms p§

Horizontal list of parameters with 'pass by' – information

Type case is changed according to sp_type.ini

Works only for PB  >= 7

reference String as_event, value Boolean ab_noicons

§parms p20§

Vertical list of parameters with 'pass by' – information, with alignment column.

Type case is changed according to sp_type.ini

Works only for PB >= 7

           reference String as_event
           value Boolean ab_noicons

§parms pn§

Horizontal list of parameters with 'pass by' – information without parameter types.

Works only for PB >= 7

reference as_event, value ab_noicons

§parms pn20§

Vertical list of parameters with 'pass by' – information, with alignment column without parameter types.

Works only for PB  >= 7

           reference as_event
           value ab_noicons

§parms pt§

Horizontal list of parameter types with 'pass by' – information.

Works only for PB  >= 7

reference string, value boolean

§parms pt20§

Vertical list of parameter types with 'pass by' – information and alignment column.

Type case is changed according to sp_type.ini

Works only for PB  >= 7

           reference String
           value Boolean

§parms -20§

If you include a – before the alignment column, SmartPaste will include the double dash comment style '//' starting from the 2nd parameter in the list

This works for all above versions with alignment column.

Type case is changed according to sp_type.ini

           String as_event
//        Boolean ab_noicons

§selectinstvar§

Selection of an instance variable. See also ‚Get and Set functions‘

Works only for PB  <= 6

 

§instvar§

The selected instance variable

Works only for PB  <= 6

 

§instvartype§

The type of the selected instance variable

Type case is changed according to sp_type.ini

Works only for PB  <= 6

 

§access§

Access to routine. Possible values are 'public', 'private' or 'protected'.

Works only for PB >= 7.

public

§eventid§

Id of event if it is mapped to a predefined PB event.

Works only for PB >= 7.

pbm_activateapp

§throws§

List of thrown exceptions as defined in the ‘Throws’-edit box

Works only for PB >= 8.

x_InputError

Date and Time

 

 

§date§

The current date in [shortdate] format

31.12.1998

§date format§

Current Date with a PB format. You can use the usual PB format identifiers for date and time to format the date.

Example: §date yy-mm-dd hh:mm§

98-12-31 12:23

Params

These macros include any parameter that has been added to the macro name into the script.

 

§p x§

x can be replaced by any number and defines the number of the parameter, starting from 1

 

Navigation

These macros do not insert any text, they just move the cursor

 

§sos§

Move cursor to start of script

-

§eos§

Move cursor to end of script

-

§sol§

Move cursor to start of line

-

§eol§

Move cursor to end of line

-

§lup§

Move cursor up

-

§ldn§

Move cursor down

-

§lft§

Move cursor left

-

§rgt§

Move cursor right

-

§del§

Delete character right of cursor

-

§bck§

Delete character left of cursor

-

§nl§

Newline + Powerbuilder indentation.
Now you can use macros within loops and nested ifs that have a higher indentation level and the macro still gets formatted nicely!

Example:

FOR i=1 TO 9§nl§Beep(1)§nl§§bck§NEXT§nl§



     // current indentation
     FOR i=1 TO 9
        Beep(1)
     NEXT         

Conditional Text

 

 

§cond2 'text'§

 Text within quotes is only inserted if the following macro does resolve to the empty string. Can be used for empty param lists.

Example:
§cond2 'none'§§parms§

If there are not params,
'none'
gets pasted instead (without the quotes)

§cond 'text'§

Text within quotes is only inserted if the following macro does not resolve to the empty string. See Conditional Text.

-

§if cond;then;else§

Here you define a condition (cond), it gets evaluated, if it yields TRUE, the first macro gets pasted (then), otherwise the other macro (else) gets pasted. There’s a special syntax for macro names within the if-condition (use % as delimiter rather then §)

Example:

§if ‘%routinekind%’=’Function’; funcHeader;eventHeader§

For a detailed explanation see Conditional Text.

[full function header]

Others

 

 

§nopaste§

The text does not get pasted, but is copied into the clipboard. To activate this feature, simply put the §nopaste§ macro somewhere in the macro text.

 

-§macro§

If you use a dash in front of any macro name in the SmartPaste main window, then this macro does not get pasted into PB. Compared to the §nopaste§-macro the dash version does not need any PowerBuilder instance running (therefore there is no information on the current PB script available). This is for all those that use SmartPaste with other tools than PowerBuilder.