Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Menus
The AVEVA Programmable Macro Language
Example:
setup form !!hello
paragraph .Message text Hello world
button .Bye Goodbye OK
exit
Or
setup form !!MyForm
!!Myform.InitCall = !this.init()
exit
Form Callbacks (OK)
The OKCALL callback allows the operator to
approve the current gadget settings
You can assign to the forms OKCALL member by:
setup form !!MyForm
OKCALL !this.approveData1()
exit
You can modify the OK callback at any time using,
!this.OKCall = !this.approveData2()
Form Callbacks (Cancel)
The CANCELCALL callback allows the operator
not to proceed with the function of the form
You can assign to the forms CANCELCALL
member by:
setup form !!MyForm
CANCELCALL !this.cancelForm1()
exit
You can modify the Cancel callback at any time using,
!this.CancelCall = !this.cancelForm2()
Form Callbacks (Quitcall)
The QUITCALL callback is executed whenever the user
presses the QUIT/CLOSE icon (X) on the title bar of forms
You can assign to the forms QUITCALL member by:
setup form !!MyForm
QUITCALL !this.quitForm1()
exit
You can modify the Quit callback at any time using,
!this.QuitCall = !this.quitForm2()
Form Control Attributes
A button may optionally have a form control
attribute which takes effect after the callback
command is invoked
Control Attributes:
OK
APPLY
CANCEL
RESET
HELP
Form Control Attributes
Examples:
button .Ok OK callback !!MyOKFunction OK
button .Apply Apply callback $
!!MyApplyFunction APPLY
button .Cancel Cancel callback $
!!MyCancelFunction CANCEL
button .Reset Reset RESET
button .Help Help HELP
Loading a form:
loadform !!formname
Loading and Displaying
Forms
Note: If you show the form again, it will appear on
the screen but its definition is already known so it
will not be loaded again
To hide a form:
!!MyForm.Hide()
The value of a form member can be set and used in just the
same way as an object member
!this.MyNumber = 42
!this.MyString = Gadz
!Num = !this.MyNumber
Form Gadgets
There are many kinds of form gadgets
Two common aims in defining gadgets on the
form
Define the area to be taken up on the form
Define the action to be taken if the gadget is
selected
Each gadget size and position determines the
area taken up
The action is defined by the gadgets CALLBACK
Callbacks
Any selectable gadget has a callback which
is defined at the time the gadget is created
The callback can do one of the three things:
Show a form
Execute a command directly
Run a function or method
Callbacks
Example:
setup form !!MyForm
paragraph .Message text Hello world
button .Change Change Message callback $
|!this.Message.Val = Modified|
button .Bye Goodbye OK
exit
!this.MethodName(
Common properties:
}
position - All gadgets have this
tag
tooltip
callback
Most but not all gadgets
anchor
have these
docking
Example:
!!MyForm.KeyboardFocus = !!MyForm.Gadget
!!MyForm.Textfield.SetFocus()
Frame Gadgets
Frame gadgets provide visual grouping of gadgets on a
form
Frame Definition:
frame .MyFrame at x0 y3 My Frame
exit
Frame Size:
Automatically expands downwards and to the right when gadget is
added but you can specify default size
Using Pixmap:
toggle .GridOn pixmap /C:\gridon.png callback
!this.enableGrid()
RGroup Gadgets
Used to allow selection of one of a small fixed number of choices
Example:
rgroup .MyRGroup Choices: horizontal callback !this.Select()
add tag Red select RED
add tag Blue select BLUE
add tag Green select GREEN callback !this.RadAction()
exit
Example:
frame .MyFrame Frame at xmin ymin
rtoggle .Rad1 Radio Button 1 callback !this.Control(
rtoggle .Rad2 Radio Button 2 callback !this.Control(
rtoggle .Rad3 Radio Button 3 callback !this.Control(
exit
Option Gadgets
Offers a single choice from a list of items
The items on the list can be either pixmaps or
text strings but not a mixture
Contains two parallel lists of the same length in
ARRAY format
values (DTEXT)
Display
Replacement values (RTEXT)
Textual Option Gadgets
Width of a textual option gadget must be
specified
Example:
option .Colour Colours at callback !!MyFunc() width 10
!ColourDtext[1] = Color Black
!ColourDtext[2] = Color White
!ColourDtext[3] = Color Red
!ColourRtext[1] = Black
!ColourRtext[2] = White
!ColourRtext[3] = Red
!this.Colour.Dtext = !ColourDtext
!this.Colour.Rtext = !ColourRtext
Pixmap Option Gadgets
Gadget shape must be specified using WIDTH
keyword and either HEIGHT or ASPECT
DTEXT member will be the pixmaps filename
Example:
option .Circle Circles at callback !!MyFunc() pixmap
width 256 height 128
!CircleDtext[1] = C:\circle1.png
!CircleDtext[2] = C:\circle2.png
!CircleRtext[1] = Circle 1
!CircleRtext[2] = Circle 2
!this.Circle.Dtext = !CircleDtext
!this.Circle.Rtext = !CircleRtext
Option Gadgets
Setting and Getting the Current Selection
Setting selection using Select() Method:
!!MyForm.Colour.Select(Dtext,Color Black)
!!MyForm.Colour.Select(Rtext,Black)
!!MyForm.Circle.Select(Dtext,C:\circle1.png)
!col[1][1] = Flange_B1
!col[1][2] = Elbow_B2
!col[2][1] = Type is Flange
!col[2][2] = Type is Elbow
!rtext[1] = =156/256
!rtext[2] = =157/257
!this.Components.SetHeadings(!head)
!this.Components.SetColumns(!col)
!this.Components.Rtext = !rtext
!element = !this.Sel.Selection()
Example:
!!MyForm.Txt1.ValidateCall = !this.Validate()
Setting contents:
!Lines[1] = Hello World
!Lines[2] =
!Lines[3] =
!Lines[4] = Goodbye World
!this.Txt.Val = !Lines
Fast Access to Lists, Selectors and
Textpanes using Do Loops
To a LIST gadget:
do !field list !!FormA.ListA
enddo
To a SELECTOR gadget:
do !field selector !!FormA.SelectorA
enddo
To a TEXTPANE gadget:
do !line pane !!FormA.TextpaneA
enddo
View Gadgets
Used to display and interact with alphanumeric or graphical views
Types of View Gadgets:
ALPHA
PLOT
2D Graphical Views
3D Graphical Views
Example (using multiple lines):
view .MyView at PLOT
height 10 width 20
cursortype pick
border on
setcolour 15
exit
Example (using one line):
view .MyView at PLOT height 10 width 20 bord on setc 15 exit
View Gadgets
Defining ALPHA Views
Views for displaying text output and/or allowing command input
view .Input at ALPHA
height 10 width 20
channel COMMANDS
exit
view .InputOutput at ALPHA
height 10 width 20
channel REQUESTS
channel COMMANDS
exit
setup !!MyForm
view .Diagram at PLOT height 10 width 20 exit
!this.Diagram.Borders = false
!this.Diagram.Add(C:\plot1.plt)
exit
To define the content of the plot view, specify the PLOTFILE path with
the Add() method
View Gadgets
Defining DRAFTs Area (2D) Views
Contents of the view may be any valid 2D graphical element, such as
DRAFT SHEET, VIEW, LIBRARY, etc.
To define the content of the view, use the PUT command
put CE - draws the current element
put /SITE/SHEET - draws the named Sheet element
Example:
Example:
Full list of members and methods is found in VANTAGE Plant Design Software
Customisation Reference Manual
Form Layout
Typically, gadgets are laid out onto the form
from top left to right and from top to bottom
Y
Gadget Auto-Placement
The PATH command can be used to define the logical
position of subsequent gadgets
PATH DOWN means that the next gadget will be below
the current one, PATH RIGHT means that the next gadget
will be to the right of the current one
The spacing between gadgets is controlled by VDIST
and HDIST for vertical and horizontal spacing
If desperation calls!!! There are settings of HALIGN and
VALIGN which can set the alignment LEFT, RIGHT, TOP,
CENTRE, and BOTTOM
Gadget Auto-Placement
Example:
button .But1 $* default placement
PATH DOWN
.But1
HALIGN CENTRE
VDIST 4.0
.Par5
para .Par2 width 4 height 2 $* auto-placed
toggle .Tog3 $* auto-placed
.Par2
PATH RIGHT
HDIST 6.0
VALIGN BOTTOM
XMAX gadget
YMAX
YMIN
XMIN
XMAX
YMAX
XMIN
Y
new paragraph gadget
XMIN.Para-5
PATH DOWN
VDIST 2.0
0 1 2 3 4 5 6 7 8 9 X
0
1
2
3
4
5
6
7
8
9
Note: Absolute positioning is not recommended way to define your gadget positions,
use relative positioning
Intelligent Positioning and Resizing
So far, we have considered the static layout of
the form
Defining intelligent positioning and resizing
behavior of gadgets is considered as Complex
Form Layout
These describes gadgets with DOCK and ANCHOR
attributes
Complex Form Layout
Defines form with intelligent positioning and
resizing behaviour of gadgets using the DOCK
and ANCHOR attributes
DOCK Attribute:
Allowsyou to dock a gadget to the left, right, top, or
bottom edge of its container, typically a form or a
frame: or you can cause the gadget to dock to all
edges, or to no edges
ANCHOR Attribute:
Allowsyou to control the position of an edge of the
gadget relative to the corresponding edge of its
container
Complex Form Layout
DOCK Attribute Examples:
For forms:
setup form !!MyForm dialog dock bottom
For gadgets:
frame .MyFrame at width 50 heigth 10
button .But1 This is a button dock fill
path down
frame .Fr1 A Frame width 5 height 10 dock right
exit
exit
Complex Form Layout
ANCHOR Attribute Examples:
Only applicable to gadgets
exit
Defining a Menu Object
A Menu is a set of menu fields, each
representing an action that is invoked
when the field is selected
A menu field can do one of three things:
Execute a callback
Display a form
Display a sub-menu
Defining a Menu Object
Example of a complete
menu definition:
-- Menu1 definition
!menu1 = !this.newMenu('MENU1,Main)
!menu1.Add('CALLBACK',Query Elbows',!!queryElbows())
!menu1.Add('SEPARATOR')
!menu1.Add('MENU','Pull-right','PULLR')
<Fieldtype>
CALLBACK, TOGGLE, MENU, FORM
<Dtext>
Display text
<Rtext>
CALLBACK callback string
TOGGLE callback string
MENU menu name string (cannot be blank)
FORM form name string without !! (cannot be blank)
<Fieldname>
Optional argument (unique field name)
Popup Menus
You can use any of your defined menus as popup menus
for most interactive gadgets and for the form background
as long as you have specified them as belonging to the
popup menu system
Triggered using Right-click
A popup is added to a gadget or form using its SetPopup()
method
Example (Using MENU keyword):
!popit = !this.newMenu(POPIT,Popup)
!popit.Add(TOGGLE,Active/Inactive,!this.Control()
!this.But1.SetPopup(!popit)
Toggle Menus
A menu field with a callback action and a tick-box to show that the
field has been selected or unselected
By default, the field is unselected
Example:
Examples:
Form as initialized:
The first item is the default selection of the form
This means, the plot file, parameter frame tag and enabled/disabled
parameter fields are also based on the default item selected
Supplied files:
The option file, plot files, and macro files will be supplied.
It is delivered together with this manual under Form Exercise 2 folder
Thats All Folks!
DISCLAIMER:
All examples in this guide are tested in PDMS 11.6 Author: Romel E. Daguplo
SP3 and SP5.
Email: romeldhagz@gmail.com