Headers
stringlengths 3
162
| Content
stringlengths 12
32.8k
|
---|---|
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 You can only have one of each type of control Attribute on any form except for APPLY which may Be used on several buttons |
A Simple Form | Example ( simpleForm.pmlfrm ): Setup form!! simpleForm Title 'My Form ' Icontitle 'Myform'Paragraph .message text 'Hello world! ' Button .bye 'Goodbye 'ok Exit |
The Form Definition File | Should be held one per file.
The file should be stored in a directory pointed to by the PMLLIB environment variable.
Filename must have suffix .pmlfrm.
!!MYFORM or!!MyForm or!!myform all correspond to myform.pmlfrm.
Begins with setup form and ends with exit.
Any method definitions should follow the exit command.
Each method begins with define method and ends with end method.
In particular, it will contain the form's default constructor method.
This method has the same name as the form and no arguments.
The only method called automatically when the form is loaded.
Used to set default values for the gadgets of the form.
The form may be given an initialization method.
Which is run whenever the form is shown.
No executable statements should appear in the file outside the form
definition or form methods.
But comments can be put anywhere in the file. |
Loading and Displaying | Forms PML will automatically load an object or form from file When first used To display a form (can either be free -standing or as a member of A form family): Show!! Formname $* default is a child form Show!! Formnamefree Removing or hiding from the screen:Hide!! Formname Redefining a form once loaded: Pmlreload form!! Formname 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 Removing a form definition: Kill!! Formname |
Some Built -in Methods | For Forms A variety of useful method calls have been Provided: To show a form: !! MyForm.Show() !! MyForm.Show( 'FREE ') !! MyForm.Show( 'At ',0.3,0.5) $* automatically FREE To hide a form: !! MyForm.Hide() To query whether a form is currently shown: If (!! MyForm.Shown()) then ......... Endif |
Form Member Variables | Used to store additional information on a form which will Not be displayed to the user These are variables which can be any of the PMLdata types, Including ARRAYS and OBJECTSSetup form!! MyForm ............ Member . MyNumberis REAL Member . MyStringis STRING Member . MyArrayis ARRAY ............ Exit 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 gadget 'sCALLBACK |
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 a gadget callback is defined by the callback command followed by a Command or PML functions enclosed in text delimiters for defining complicated callback, it is recommended to use a form Method |
Callback Example | For a callback to call a function Setup form!! MyForm ............ Button . Query 'Query 'callback'!! queryCatalogueDetails () ' ............ Exit For a callback to call a method Setup form!! MyForm ............ Button . Query 'Query 'callback'! this.queryDetails () ' ............ Exit |
Callback Example | Showing another form from a form gadget Setup form!! MyForm ............ Button . Gadz 'Show Gadz Form 'callback 'show!! gdzMainForm ' ............ Exit Gold Setup form!! MyForm ............ Button . Gadz 'Show Gadz Form 'form!! gdzMainForm ............ Exit |
Callbacks: Form Methods | Most callbacks require more than a singThe command, so invoking a method Or function or macro is an essential requirement Example: Setup form!! MyForm Title 'Display Your Message ' Paragraph . Message width 15 height 1 Text. Capture 'Enter message: 'width 15 is STRING Button . Bye 'Goodbye 'OK ExitDefine method. MyForm() $* default constructor –set gadget default values ! this.Message.Val = 'Hello world! ' ! this.Capture.Callback = '! this.Message.Val = ! this.Capture.Val ' ! this.OKcall= '! this.Success() ' Endmethod Define method. Success() ! this.Message.Val = 'Hello again! ' ! this.Capture.Val = '' Endmethod |
Callbacks: Form Methods | The greAt advantage of methods is that you can pass Variables as arguments to the method and it can also Return a result just like a PML function Example: Define method. Success(! Output is GADGET, ! Input is GADGET) ! output.Val= 'Hello again! ' ! input.SetFocus()Endmethod Define method . setGadget(! Output is GADGET) is BOOLEAN ! output.Val= 'Gadget initialized! ' Handle any Return FALSE Endhandle Return TRUE Endmethod |
PML Open Callbacks | When the operator interacts with a GUI, an event occurs Example: Types something into a field on a form Moves the cursor into a window Presses down a mouse button Etc. Application sOftware defines a set of meta-eventsfor Forms and gadgets When a meta -event occurs, the application software Checks for user -defined callbacks and execute them |
PML Open Callbacks | Simple assigned callback is insufficient to fully exploit the Gadget's possible behaviors To overcome this shortcoming, we can use OPEN CALLBACKS to Allow the AppWare to be informed whenever a meta event isEncountered Open Callback: Define method. Control(! Object is GADGET, ! Action is STRING) Object is aForms and Menus object (i.e. a form, gadget, or Menu)! Action is the meta -event that occurred on the object and Represents the action to be carried out by the method |
PML Open Callbacks | The open callback is a string of the form: '! this.MethodName(' Note the open bracket '('(no arguments andNo closing bracket). The callback is to an openmethod or function |
PML Open Callbacks Example | An open callback to a multi -choice list gadget: Setup form!! Open Title 'Test Open Callbacks ' List . Choose callback '! this.Control('multi width 15 height 8 Exit Define method. Open() Do! I from 1 to 10 ! Fields[! I] = 'list field $! I ' Enddo ! This.Choose.Dtext = ! Fields Endmethod Define method. Control(! Object is GADGET, ! Action is STRING) If (! Actioneq 'SELECT ') then --Find out all about our gadget object ! Form = ! object.Owner() ! Type = ! object.Type() ! Name = ! object.Name() ! Field = ! object.PickedField! Fieldtext= ! object.Dtext[! Field ] $P Selected $! Form$n. $! Name$! Type Field $! Field Dtext{$! Fieldtext } Elseif(! Actioneq 'UNSELECT ') then ! Field = ! object.PickedField $P Unselect field $! Field Endif Endmethod |
PML Open Callbacks | It is also be essential if we use PML functions as Open callbacks Define function!! Control(! Object is GADGET, ! Action is STRING)............... Endfunction List of objects that can have open callbacks is Found Vantage Plant Design Software Customisation Guide Section, |
Gadget Definition Commands | Types of Gadgets:
FRAME
PARAGRAPH
BUTTON
TOGGLE
RGROUP
OPTION
LIST
DATABASE SELECTOR
TEXT
TEXTPANE
VIEW
SLIDER
RTOGGLE |
Gadget Size Management | User Specifiable Tagwidth for TEXT, TOGGLE, OPTION And RGROUP Gadgets TEXT, TOGGLE, OPTION andRGROUP gadgets support theTagwidth syntax Tagwidth specifies the size of the gadget 's tag field in grid Width units Option. ELLISTtagwid7 |Element Id| width 4 The actual tag may have more characters than the Declared Tagwidth and still fit in the tag field |
Gadget Size Management | Specifying Gadget Size Relative to Other Gadgets Example: Frame .fr1 'Frame 1 'at x0 y0 width 10 height 10............... Exit Frame .fr2 'Frame 2 'atxminyminwidth.fr1 height 15 ............... Exit |
Gadget that Support Pixmaps | some gadgets support pixmaps as content as an alternative to text e.g.Buttons,Toggles, andParagraphs Pixmaps arepixelated pictures held in files of type .png Default size for pixmaps is assumed to be 32x32 pixels Whenpixmaps are required, you will need to specify pathnames to the pixmap file Maximum required size of the image Button . But1pixmap/C:\pic.pngwidth 26 height 26 UsingAddPixmap ()Method: Button . But1pixmapwidth 26 height 26 In the constructor method: ! This.but1. AddPixmap( 'C:\pic.png ') |
Gadget Members | Members Contained by All Gadgets Visible Active Callback Tag Making gadgets visible and invisible !! MyForm.List1. Visible = FALSE $* Invisible !! MyForm.List1. Visible = TRUE $* Visible Activating and de -activating gadgets !! MyForm.List1. Active = FALSE $* From -activate !! MyForm.List1. Active = TRUE $* Activate |
Gadget Members | Setting Keyboard Focus Thekeyboard focus defines which gadget will receive keystrokes !! MyForm.KeyboardFocus = !! MyForm.Gadget This can be moved at any time to another gadget using the SetFocus ()method !! MyForm.Textfield.SetFocus () |
Frame Gadgets | Frame gadgets provide visual grouping of gadgets on a Form Frame Definition: Frame . MyFrameat x0 y3 'My Frame' ..................... Exit Frame Size: Automatically expands downwards and to the right when gadget is Added but you can specify default sizeFrame . MyFrameat x0 y3 'My Frame 'width 25 height 5 ..................... Exit |
TabsetFrames | A frame with tab pages TabsetFrame Definition:Frame . MyFrametabsetwidth 25 height 5 Frame . Tab1 'Tab 1 ' ............... Exit Frame . Tab2 'Tab 2 ' ............... Exit Exit |
Paragraph Gadgets | Paragraph gadgets are simple named gadgets which Allow piece of text or a pixmap to be displayed on the Form Textual Paragraph Gadgets: Paragraph . Message text 'Text String ' Paragraph . Message at ......text 'Text String 'width 16 lines 7 Paragraph .Message at ......background 2 width 20 lines 2 Pixmap Paragraph Gadgets: Paragraph . Picture at ......pixmap/C:\pic.png Paragraph . Picture at ......pixmap/C:\pic.pngwidth 30 height 30 Pixmap may be changed any time by assigning a new value to the . Valmember: !! MyForm.Picture.Val = /C:\newpic.png |
Button Gadgets | Also called control button , usually displays a child form or invoke aCallback (typically a PML Form method) Tag,pixmap, callback, and child form are all optional Button . SubForm 'More ...'form!! ChildForm Button . SubFormpixmap/C:\pic.pngform!! ChildForm Button . Calculate 'Calculate 'callback '! this.Calculate() ' Button . But1 'More ...'At......width 10 height 1 Toggle Mode Buttons: Button . But1 toggle pixmap/C:\unselectpic.png /C:\selectpic.png/C:\inactivepic.png width 16 height 16 Tooltip 'This is a toggle button ' |
Toggle Gadgets | Are used for independent on/offsettings Opposed to a radio group Example: Toggle . Bold 'Bold ' Toggle . Italic 'Italic' Toggle . Underline 'Underline ' UsingPixmap: Toggle .GridOnpixmap/C:\gridon.pngcallback '! this.enableGrid() ' |
RGroup Gadgets | Used to allow selection of oneOf a small fixed number of choice s 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 TheSELECTkeyword inThe addcommand defines its replacement Text string (RTEXT) When querying current selection using Selection() method, it will Return the RTEXTstring of the selected button If (!! MyForm.MyRGroup.Selection ()eq 'RED ') then ......... Endif |
RToggle Gadgets | Very similar to TOGGLE gadget, but is allowed only in FRAMES, where they operate together to form a set of RaDio buttons similar to RGROUP gadget Example: Frame . MyFrame 'Frame 'atxminymin 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 Display values (DTEXT) 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 HEIGHTorASPECT DTEXTmember will be the pixmap'sfilename Example: Option. Circle 'Circles 'at......callback '!! MyFunc() 'pixmapWidth 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 ','ColorBlack ')!! MyForm.Colour.Select( 'Rtext ','Black ') !! MyForm.Circle.Select( 'Dtext ','C:\circle1.png ') Reading the selection using Selection() Method: ! Selected = ! this.Colour.Selection () ! Selected = ! this.Colour.Selection( 'Dtext ') ! Selected = ! this.Colour.Selection( 'Rtext ') |
Slider Gadgets | Allows you to interactively to Generate values in a specified Range, at specified steps Supports vertical andhorizontalFrame .fr1 'Slider 'atxminymaxwidth 10 Text .txt width 3 is REAL Slider .sldhorizontal callback '! this.ControlSlide (' Range-50 +50 step 5val0 width 5 Exit Responds to left -mouseSLIDER START, MOVE, andSTOP Events |
List Gadgets | Allows you to interactively to
generate values in a specified
range, at specified steps
Supports vertical andhorizontal
frame .fr1 ‘Slider ’atxminymaxwidth 10
text .txt width 3 is REAL
slider .sldhorizontal callback ‘!this.ControlSlide (’
range-50 +50 step 5val0 width 5
exit
Responds to left -mouseSLIDER START, MOVE, andSTOPevents |
List Gadgets | Multiple Choice List Gadgets List . Components 'List 'multiple width 25 lines 15 ! ComponentDtext[1] = 'ELBO1 '! ComponentDtext[2] = 'FLAN1 ' ! ComponentRtext[1] = '=1565/1543 ' ! ComponentRtext[2] = '=1565/1544 ' ! this.Components.Dtext = ! ComponentDtext ! this.Components.Rtext = ! ComponentRtext Querying selected values Single choice list gadget returns a STRING MulTiple choice list gadget returns an ARRAY of STRINGS |
Form Exercise 1 | Create the following form. Upon the form is initialized;Default value in textbox: 0 Default frame tag: 'Sequence Frame ' Upon choosing 'Fibonacci ' Button; Frame tag: 'Fibonacci Sequence ' The sequence is shown inside the Frame. Upon choosing 'Hailstone ' Button; Frame tag: 'Hailstone Sequence' The sequence is shown inside theFrame. |
Form Exercise 1 | Use the functions you created in the previous exercises 3 & 4 Found in Part 1.Handle invalid input ( 0 and string ). Input should be a REAL Object. Define a constructor method. |
Multi-Column List Gadgets | A list gadget with a COLUMNS keyword Column Oriented -SETCOLUMNS() List . Components columns single zeroselectionwidth 25 lines 15 ! Head[1] = 'Name ' ! Head[2] = 'Type ' ! 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 Can be apply to Multiple Choice List gadget also |
Multi-Column List Gadgets | Row Oriented -SETROWS() List . Components columns single zeroselectionwidth 25 lines 15! Head[1] = 'Name ' ! Head[2] = 'Type ' ! Row[1][1] = 'Flange_B1 ' ! Row[1][2] = 'Type is Flange ' ! Row[2][1] = 'Elbow_B2 ' ! Row[2][2] = 'Type is Elbow ' ! Rtext[1] = '=156/256 ' ! Rtext[2] = '=157/257 ' ! this.Components.SetHeadings(! Head ) ! this.Components.SetRows(!Row ) ! this.Components.Rtext = ! Rtext DTEXTstring is held as a 'horizontal tab 'character separated String of column data |
Database Selector Gadgets | A special kind of list gadget Provides a mechanism for Displaying the current database Element along with its owner And members User can interact with a selector To change the current element Selector. Salt 'Selector: 'single width 12 height 5 DATABASE Selector. Selmultiple width 12 height 5 DATABASE OWNERS Selector. Selmultiple width 12 height 5 DATABASE MEMBERS Selector. Selsingle width 12 height 5 DATABASE AUTO Selector. Selcallback '! this.Mylist('single width 12Height 5 DATABASE |
Database Selector Gadgets | DATABASE keyword is mandatory OWNERS andMEMBERS are optional AUTOandMULTIPLE cannot be used together To get and set values for a selector: Selection() –get value Select() –set value ! Element = ! this.Sel.Selection () RTEXTandDTEXTare always the same as one Another AUTOmeans the selector gadget is updated when YOu do action to the design explorer form |
Text Gadgets | A box that can display a Value and into which the User may type a value,Or edit an existing value Text. Number at ........width 10 is REAL Text. Str 'Username: 'callback '!! MyFunction 'width 10 Scroll 100 is STRING Text. Bore 'Bore: 'width 10 is BORE format!! FormatBore Text. Passwd 'Password: 'at......width 10 NOECHO is STRING Specify data type using ISSupply a FORMAT object Password type using NOECHO keyword |
Text Gadgets | Validating Input to Text Fields HAs an optional validation callback member which The user can specify ! textField.ValidateCall = <callback string> Example: !! MyForm.Txt1. ValidateCall = '! this.Validate() ' VALIDATECALL is used to apply any checks if an error is encountered then the callback raises the errorAnd returns |
Textpane Gadgets | Provides a box on a form into which a user may type And edit multiple lines of texttextpane.Txt 'Text: 'at......width 10 height 20 textpane.Txt 'Text: 'at......height 20 aspect 0.5 Its contents is an array of strings Each element of the array corresponds to a line of text in the Gadget Setting contents: ! Lines[1] = 'Hello World ' ! Lines[2] = ''! Lines[3] = '' ! Lines[4] = 'Goodbye World' ! this.Txt.Val=! Lines |
Fast Access to Lists and Selectors | Textpanes using Do Loops To aLISTgadget: Do! Field list!! FormA.ListA ............ Enddo To aSELECTOR gadget: Do! Field selector!! FormA.SelectorA ............ Enddo To aTEXTPANE gadget: Do! Line pane!! FormA.TextpaneA ............ Enddo |
View Gadgets | Used to display and interact with alphanumeric or graphical view s Types of View Gadgets: ALPHA PLOT 2D Graphical Views3D Graphical Views Example (using multiple lines): View . MyViewat......PLOT Height 10 width 20 Cursortypepick Border on Setcolour15 Exit Example (using one line): View . MyViewat......PLOT height 10 width 20 bordonsetc15 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 COMMANDSExit View . InputOutputat......ALPHA Height 10 width 20 Channel REQUESTS Channel COMMANDS Exit channel COMMANDS –causes alpha view to have a command input Field and displays command lines and error messages in the messa ges In the scrollable output region chaNnel REQUESTS –displays the output resulting from commands, in Particular, queries in the scrollable output region |
View Gadgets | Defining PLOT Views Views for displaying non -interactive 2Dplotfiles 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 thePlot view, specify the PLOTFILE pat h with theAdd()method |
View Gadgets | Defining DRAFT'sArea (2D) Views CoNtents of the view may be any valid 2D graphical element, such as Drat sheet, VIEW, LIBRARY, etc. To define the content of the view, use the PUTcommand put CE -draws the current element put /SITE/SHEET -draws the named Sheet element Example: View . Drawing at ......AREA Height 10 width 20 Put /MDS-ABA-3-VIEWS(METRIC)-PS00001-AREA Limits 200 100 to 600 500 Exit ! this.Drawing.Background = 'beige' For DRAFT Module only |
View Gadgets | Defining DESIGN'sComparator (2D) Views Contents of the view may be any valid Process and Instrument Diagram sheet reference Example: View . Pidat......COMPARE Height 20 width 40 Put /SHEET CursortypepointerExit ! this.Pid.Background = 'darkslate ' |
View Gadgets | Defining DESIGN'sVolume (3D) Views Example: Setup form!! MyForm ...... View . Model at ......VOLUME Height 10 width 30 Auto limits Iso3 Exit ...... Exit Define method. MyForm() ...... ! this.Model.Borders = false ! this.Model.Shaded = true ...... Endmethod Full list of members and methods is found in VANTAGE Plant Desig n Software Customisation Reference Manual |
Form Layout | Defining DESIGN’sVolume (3D) Views
Example:
setup form !!MyForm
……
view .Model at ……VOLUME
height 10 width 30
limits auto
iso3
exit
……
exit
define method .MyForm()
……
!this.Model.Borders = false
!this.Model.Shaded = true
……
endmethod
Full list of members and methods is found in VANTAGE Plant Desig n Software
Customisation Reference Manual |
Gadget Positioning | Form Coordinate System Gadgets are positioned on a form from top Left 0 0123456789 X 1 2 3 4 5 6 7 8 9 Y1 character width per unit 1 line height per unit |
Auto Gadget - Placement | ThePATHcommand 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 andHDISTfor vertical and horizontal spacing If desperation calls!!! There are settings of HALIGN and VALIGN which can set the alignment LEFT,RIGHT,TOP, CENTRE, andBOTTOM |
Auto Gadget - Placement | Example: Button . But1 $* default placement PATH DOWN HALIGN CENTRE VDIST 4.0 para.Par2 width 4 height 2 $* auto-placed Toggle . Tog3 $* auto-placed PATH RIGHT HDIST 6.0 VALIGN BOTTOM List . Lis4 width 5 height 4 $* auto-placedPATH UP HALIGN RIGHT para.Par5 width 6 height 5 $* auto-placed.But1 . Par2 . Tog3. Lis4. Par6 |
Relative Gadget Placement | Each gadget has four label points XMIN XMAX YMIN YMAX These can be used for positioning using theATkeyword Paragraph .message at xminymaxtext 'Hello world! 'gadgetYMIN YMAX XMAXXMIN |
Relative Gadget Placement | Relative to the last gadget 0 0123456789 X 1 2 3 4 5 6 7 8 9 Y XMINYMAX YMAX + 2 Paragraph . Msg 'Hello! 'Atxminymax+2previously created gadget used asReference New paragraph gadget.Msg |
Relative Gadget Placement | Relative to the last gadget0 0123456789 X 1 2 3 4 5 6 7 8 9 Y XMIN.Para -5YMAX.Para YMAX.Para+5 Paragraph . Msg 'Hello! 'At xmin.Para-5 ymax.Para+5existing paragraph gadget New paragraph gadget.Para . Frm existing frame gadget . Msg |
Mixing Auto and Relative | Investment Example: Toggle .t1 atxminymin Toggle .t2 atxmaxymax.t1+0.25 PATH DOWN VDIST 2.0 Toggle .t3 at xmin.t1 places.t3with respect to XMINof gadget .T2, whilstYcoordinate For.t3is auto-placed at current VDISTvalue (which is 2.0) below the Last placed gadget (which is .t2) |
Absolute Gadget Positioning | Example: Toggle . OnOffat 4 3.5 Toggle . OnOffat x 4 y 3.5 0 0123456789X 1 2 3 4 5 6 7 8 9 Y Note: Absolute positioning is not recommended way to define your ga dget positions, Use relative positioning |
Intelligent Positioning and Resizing | So far, we have considered the static layout ofThe form Defining intelligent positioning and resizing Behavior of gadgets is considered as Complex Form Layout These describes gadgets with DOCKandANCHOR Attributes |
Complex Form Layout | Defines form with intelligent positioning and Resizingbehaviour of gadgets using the DOCK andANCHOR attributes DOCKAttribute: Allows you to dock a gadget to the left, right, top, orBottom 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: Allows you to control the position of an edge of the Gadget relative to the corresponding edge of its Container |
Complex Form Layout | DOCKAttribute Examples: For forms: Setup form!! MyFormdialog dock bottom For gadgets: Frame . MyFrameat......width 50heigth10 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 Frame . MyFrame 'My Frame 'at......anchor all textpane.Txt anchor all width 5 height 5 Button . Apply 'Apply 'anchor bottom + right at Xmax-size ymax+0.5 Path left Button . Cancel 'Cancel 'anchor bottom + right Exit |
Menus | Menus are always members of forms but can Be employedIn various ways by the form and Its gadgets Two types of menus: Main menu Popup menu |
Defining a Bar Menu Gadget | Defined within a form definition Created with barsubcommand Use the bar 'sAdd()method to Add options Example: Setup form!! MyFormdialog size 25 1 Bar ! this.bar.Add( 'Choose ','Menu1 ') ! this.bar.Add( 'Window ','Window ') ! this.bar.Add( 'Help ','Help ')Exit |
Defining a Menu Object | A Menu is a set of menu fields, each Representing an action that is invokedWhen 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 ','QueryElbows ','!! queryElbows() ') ! Menu1. Add( 'SEPARATOR ') ! Menu1. Add( 'MENU ','Pull-right ','PULLR ')--PULLR menu definition ! Pullr=! this.newMenu( 'PULLR ','Main ') ! pullr.Add( 'CALLBACK ','Menu1','show!! MyForm ') ! pullr.Add( 'FORM ','GadzMenu ','gdzMainForm ') |
Defining a Menu Object | General Syntax: ! menu.Add ('<Fieldtype >','<Dtext>','<Rtext>',{'<Fieldname >'}) <Fieldtype > CALLBACK ,TOGGLE ,MENU,FORM <Dtext> Display text <Rtext> CALLBACK –callback string TOGGLE –callback string MENU -menuname string (cannot be blank) FORM –formname 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-clickA popup is added to a gadget or form using its SetPopup () Method Example (Using MENUkeyword): Button . But1 'A Button 'at...... Menu .pop1 popup ! This.pop1. Add( 'TOGGLE ','Active/Inactive ','') ! This.pop1. Add( 'CALLBACK ','Clear ','ALPHA REQUEST Clear ') ! This.But1. SetPopup(! This.pop1) |
Popup Menus | Another Way: Button . But1 'A Button 'at...... ! 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: Setup form!! MyformDialog size 30 5 ...... ! Menu = ! this.newMenu( 'Test ','popup ') ! Menu.add( 'TOGGLE ','Active/Inactive ','!This.toggle( ','OnOff ') ...... Exit Define method .toggle(! Menuis MENU, ! Action is STRING ) ! Name = ! menu.Fullname() ! Field = ! menu.PickedFieldName $P menu $! Name $! Action field: $! Field Endmethod |
ALERT Objects | 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:
setup form !!MyformDialog size 30 5
……
!menu = !this.newMenu( ‘Test ’,‘popup ’)
!menu.add( ‘TOGGLE ',’Active/Inactive ’,'!this.toggle( ‘,'OnOff ')
……
exit
define method .toggle(!menuis MENU, !action is STRING )
!name = !menu.Fullname()
!field = !menu.PickedFieldName
$P menu $!name $!action field: $!field
endmethod |
ALERT Objects | INPUT Alerts allows the useR to obtain textual input from the operator via a Blocking alert which overrides all other interactive activities. The alert can be summoned by the alert methods: !! Alert.Input (! Prompt is STRING, ! Default is STRING) is STRING Examples: !! Alert.Error( 'Youcannot do this!') !! Alert.Message( 'Savingyour data now ') !! Alert.Warning( 'Donot press this button again! ') ! Answer = !! Alert.Confirm( 'Areyou sure? ') ! Answer = !! Alert.Question( 'OKto delete component? ') Confirm Alert returns: 'YES'or'NO'Strings Question Alert returns:'YES'or'NO'or'CANCEL 'Strings |
Form Exercise 2 | Create the following form. When stretched; |
Form Exercise 2 | The'Choose Template 'list gadget: It's contents is based in an option file; FirstRow means the Nameof the template Next row is for the description Third row is the plot files Forth row is the macro file of the template Last row means how many arguments are needed of the template The list only shows the name and the description of the templateUpon choosing each item on the list; The plot file will change based on the plot file defined in the option file The tag of the frame in the parameters frame will also change ba se on the name Disabling and enabling of the parameter fields are also handled Example (If the selected template 's required arguments are only 2, then parameter field 3 will be Disabled and parameter 1 and 2 will be enabled. Same concepts ap ply to all.) |
Form Exercise 2 | The'Create'button: Upon clicking this button; Check validity of the name supplied (If already exists, etc.) Check validity of the hierarchy Check if all required fiElds of the chosen template are supplied by the user If successful to all checking, create the equipment and revert t he form's Mode to initialization mode. Form as initialized: The first item is the default selection of the form This means, the plot fiLe, parameter frame tag and enabled/disab led 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 |
That's All Folks! | DISCLAIMER: This guide is for information purpose only. It is Recommended that users following this guide haveUndergone training first. You may use this manual at your own risk. In no Event shall the writer be liable for any direct, Indirect, incidental, exemplary or consequential Damages. |
Customizing a Graphical User Interface | The main features of PML2 are: • Available Variable Types - STRING, REAL, BOOLEAN, ARRAY • Built in Methods for commonly used actions • Global Functions supersede old style macros • User Defined Object Types • PML Search Path (PMLLIB)• Dynamic Loading of Forms, Functions and Objects • Aid objects for geometric modeling PML is now more consistent with other programming languages and more structured in Form. The new data types are now OBJECTS which can be operated by running METHODS .The old $ based variables are still valid, but are always treated as strings. Global functions Are macros which can be called more like subroutine s than traditional macros. e.g. a function Can be called between the brackets of an IF stateme nt and return a BOOLEAN result User-Defined object types enable a group of mixed variab les to be combined into packages. The Resulting object can then be used as a simple varia ble and the separate parts set or used as Attributes of the variable. Search paths and dynami c loading mean that it is no longerNecessary to pre load forms or have synonyms for ca lling macros. A large number of new Aid objects have been created so that users can do more graphical construction. Most AVEVA products make use of a Graphical User Interface (GUI) to drive the Software.PML 2 has been specifically designed for writing and customizing the Forms and Menus for AVEVA products. Almost all the facilities avail able in PML 1 and the older Forms And Menus facilities continue to function as before even if they are not documented here.Before you begin customizing a GUI, you must have a good working knowledge of the Command syntax for the AVEVA product you are working g with. PML2 is almost an object-oriented language. Its ma in deficiency is that it lacks Inheritance. However, itDoes provide for classes o f built-in, system-defined and user-defined Object types. Objects have members (their own variables) and methods (their own Functions ). All PML Variables are an instance of a built-in, system-defined or user-defined Object type.Operators and methods are polymorphic - what they do (their behavior) Depends on the type of the variable. Overloading of functions and operators is supported for All variable types. There is no concept of private members or methods, everything is public .There are only two levels of scope for variables: Global and Local . Arguments to PML Functions are passed-by-reference with Read/Write a ccess so any argument can potentially Be used as an output argument. Note: From PDMS12.1, all textual informatiOn in PDMS is represented as Unicode. Unicode Is a computing industry standard for the consistent encoding, representation and handling of Text expressed in most of the world's writing system ms. Developed in conjunction with the Universal Character SetStandard and published in b ook form as The Unicode Standard, the Latest version of Unicode consists of a repertoire of more than 109,000 characters covering All PML string variables support Unicode values. Yo u can use Unicode characters in PML VariabLe names, PML object form and gadget names, P ML method and function names. All PML language files should either be UTF8 format wit h a BOM present or else strictly ASCII |
PML2 variables | AVEVA PDMS Programmable Macro Language manual
• Available Variable Types - STRING, REAL, BOOLEAN, ARRAY
• Built in Methods for commonly used actions
• Global Functions supersede old style macros
• User Defined Object Types
• PML Search Path (PMLLIB)
• Dynamic Loading of Forms, Functions and Objects
• Aid objects for geometric modeling
PML is now more consistent with other programming languages and more structured in form. The new data types are now OBJECTS which can be operated by running METHODS .
The old $ based variables are still valid, but are always treated as strings. Global functions are macros which can be called more like subroutine s than traditional macros. e.g. a function can be called between the brackets of an IF stateme nt and return a BOOLEAN result User-defined object types enable a group of mixed variab les to be combined into packages. The resulting object can then be used as a simple varia ble and the separate parts set or used as attributes of the variable. Search paths and dynami c loading mean that it is no longer necessary to pre load forms or have synonyms for ca lling macros. A large number of new aid objects have been created so that users can do more graphical construction.
Most AVEVA products make use of a Graphical User Interface (GUI) to drive the software. PML 2 has been specifically designed for writing and customizing the Forms and Menus for AVEVA products. Almost all the facilities avail able in PML 1 and the older Forms
and Menus facilities continue to function as before even if they are not documented here.
Before you begin customizing a GUI, you must have a good working knowledge of the command syntax for the AVEVA product you are workin g with.
PML2 is almost an object-oriented language. Its ma in deficiency is that it lacks inheritance. However, it does provide for classes o f built-in, system-defined and user-defined object types. Objects have members (their own variables) and methods (their own
functions ). All PML Variables are an instance of a built-in, system-defined or user-defined object type. Operators and methods are polymorphic - what they do (their behavior) depends on the type of the variable. Overloading of functions and operators is supported for
all variable types. There is no concept of private members or methods, everything is public .
There are only two levels of scope for variables: Global and Local . Arguments to PML Functions are passed-by-reference with Read/Write a ccess so any argument can potentially be used as an output argument.
Note: From PDMS12.1, all textual information in PDMS is represented as Unicode. Unicode is a computing industry standard for the consistent encoding, representation and handling of text expressed in most of the world's writing syste ms. Developed in conjunction with the
Universal Character Set standard and published in b ook form as The Unicode Standard, the latest version of Unicode consists of a repertoire of more than 109,000 characters covering all PML string variables support Unicode values. Yo u can use Unicode characters in PML
variable names, PML object form and gadget names, P ML method and function names. All PML language files should either be UTF8 format wit h a BOM present or else strictly ASCII
|
Kupdf.net_pdms-pml-manual | • ARRAY holds many values of any type. An ARRAY variable c an contain many values, Each of which is called an array element. An Array is created automatically by Creating one of its array elements.The system-defined object types 2.1.2. • Position, Orientation, DirE, P0, P1... • Bore, Hbore, Href ... • Dbref, Dbname, Dbfile... Examples: BLOCK blocks are used to store commands for a special fo rm of working on arrays. The Block contains a listOf commands and "block Evalua tion" is used to perform the actions on An array FILE file is in principle a file name, but the file obj ect contains built in methods for working on The file. DATETIME returns current Date and Time information DB a DB object is an object representing a database. Can be used to interrogate information About type, team, access, claim type DBREF a dbref object a ref to a database it has members (access, file, name, number, Foreign, type, description, claim (string) and team (team))DIRECTION a Direction object has members (direction, origin (dbref), up, east, north (real)) MDB MDB object has members (name and description, both strings) ORIENTATION an orientation object has members (alpha (real), o rigin (dbref), Gamma and Beta(reals))POSITION a position object has members (origin (dbref) up, east, north (reals) PROJECT a project object has one member (evar (string)) TEAM a team object has members (name and description (r eals)) USER a user object has members (access, name, descripti on (strings))FORMAT is a way of formatting data for example metric or imperial] The user-defined object types 2.1.3. You may find that the object types supplied with P ML 2 are enough. However, you can Define new object types if you need to. In any case, the following example may help youUnderstand objects, their members and how they are used. It is a good idea to use upper Case for object-type names, and mixed upper and low er case for variable names, the objects Themselves. For example, a type might be Employee, and a variable name might beNumberOfEmployees. Define object COMPANY Member . Name is STRING Member . Address is STRING Member . Employees is REAL Member . NumberOfEmpliyees is REAL Endobject The user-defined object type should by normally st ored in a file with a lowercase nameMatching the name of the object type and a .pmlobj suffix in PMLLIB directory. PML will Load a definition automatically when it is needed. Example above should have name Company.pmlobj . |
PML1 variables creation | Creation of variables For creating variable is used VAR command. As value in variable could be used text orSome attribute. As you may see there are used text delimiters to define any text as value. These delimiters could be used '' or vertical bars || as well. The most important fact is that Using the VAR command always create variable as str ing() object. Even if you use numbersOr Booleans. Of course that you can create an array by VAR command but array itself Contain array members. Through command VAR you just fill an array by string elements. REMEMBER THAT VAR COMMAND ALWAYS CREATES STRING OBJ ECT TYPE!!! Text - as string in PML2:VAR! PML1text 'THISisTEXT' VAR! PML1attribute1 NAME VAR! PML1attribute2 POS WRT /* Numbers - as real in PML2: VAR! X (32) VAR! Y (52) VAR! Z1 (! X + ! Y) VAR! Z2 ('! X' + '! Y') VAR! Z3 ('$! X' + '$! Y') VAR! Z4 (23 * 1.8 + 32) Boolean - as Boolean in PML2:VAR! T1 TRUE VAR! F1 FALSE VAR! T2 T VAR! F2 F VAR! T3 YES VAR! F3 NO VAR! T4 Y VAR! F4 N There are no BOOLEAN () object variables in PML1. V AR command always creates the STRING () object type. Array - as array in PML2: VAR! ARRAY[1] 'AVEVA'VAR! ARRAY[10] NAME VAR! ARRAY[20] (12) Using the PML2 syntax you will create not only the value for variable but you Automatically assign the object type according to d efined data. If it is simply text, then results As string object but some dataAs position are alre ady defined as some other object type. In This case the position is system defined object typ e therefore results as POSITION. This is The most important difference between PML1 and PML2 because PML2 is object oriented Language. |
Members and Attributes | ! PML2string = 'THISisTEXT'! PML2attribute1 = NAME ! PML2attribute2 = POS WRT /* (in PML1 will be stri ng in PML2 position object type) Real: ! X = 32 ! Y = 52 ! Z1 = (! X + ! Y) ! Z2 = ('! X' + '! Y') ! Z3 = ('$! X' + '$! Y') ! Z4 = (23 * 1.8 + 32) Boolean: ! T1 = TRUE! F1 = FALSE ! T2 = T ! F2 = F ! T3 = YES ! F3 = NO ! T4 = Y ! F4 = N Array: ! ARRAY = ARRAY() ! ARRAY[1] = 'AVEVA' ! ARRAY[2] = NAME ! ARRAY[3] = 12 ! ARRAY[4] = N ! ARRAY[5] = TRUE An object can contain one or more items of data re ferRed to as its members or attributes. Each member has a name. • STRING, REAL and BOOLEAN variables just have a val ue - no members. • ARRAY variables have numbered elements, not member s. User Defined Objects can contain any variable or o bject type as attributes or members.Information is grouped with an object for ease of reference and standard reference. User- Defined objects can also contain user-defined metho ds that will use the information stored Within the object. These methods may represent a ca lculation, or information retrieval.After An object has been declared as a variable, the meth ods can be applied to the variable. For Example: Define object ELEMENT Member . Type is STRING Member . Material is STRING Endobject Define method. FullDesc() is STRING Return! This.Type & ' ' &! this.Material Endmethod |
Naming conventions | String:
!PML2string = 'THISisTEXT'
!PML2attribute1 = NAME
!PML2attribute2 = POS WRT /* (in PML1 will be stri ng in PML2 position object type)
Real:
!x = 32
!y = 52
!z1 = (!x + !y)
!z2 = ('!x' + '!y')
!z3 = ('$!x' + '$!y')
!z4 = (23 * 1.8 + 32)
Boolean:
!T1 = TRUE
!F1 = FALSE
!T2 = T
!F2 = F
!T3 = YES
!F3 = NO
!T4 = Y
!F4 = N
Array:
!ARRAY = ARRAY()
!ARRAY[1] = 'AVEVA'
!ARRAY[2] = NAME
!ARRAY[3] = 12
!ARRAY[4] = N
!ARRAY[5] = TRUE
An object can contain one or more items of data re ferred to as its members or attributes.
Each member has a name.
• STRING, REAL and BOOLEAN variables just have a val ue - no members.
• ARRAY variables have numbered elements, not member s.
User Defined Objects can contain any variable or o bject type as attributes or members.
Information is grouped with an object for ease of r eference and standard reference. User-defined objects can also contain user-defined metho ds that will use the information stored within the object. These methods may represent a ca lculation, or information retrieval. After
an object has been declared as a variable, the meth ods can be applied to the variable. For example:
define object ELEMENT
member .Type is STRING
member .Material is STRING
endobject
define method .FullDesc() is STRING
return !this.Type & ‘ ‘ & !this.Material
endmethod |
Naming conventions | Application Prefix Comments Area BasedADP!! ABA Add-in application Administration!! ADM Plus!! CDA Application Switching !! App Batch Handling!! BAT CADCentre!! CADC Draft!! CDR Draft Icon Location!! CD2D Icon pathnames Defaults!! DFLTS General!! CDC Plus!! CDD, E, F, G, H, I, L, M, N, P, S, U, V, W Specialized!! CE Plus!! ERROR, !! FMSYS The majority of the existing PML2 code has been giv en a 3or4 letter prefix to the full name. Application Prefix Comments Accommodation ACC ADM Administration Access, Stairs & Ladders ASL Area Based ADP ABA Add-in application Assembly ASSYAssociations ASSOC None apparent Common COMM Mixed Design DES Mixed Draft DRA Plus ADP, DGN, DXF Global GLB Hull Design HULL Hull Drafting HDRA None Integrator INT Application Prefix Comments Isometric ADP ISO Add-in application Marine DiagramsDIAG No appware except main form Monitor MON Paragon CAT Review Interface REVI None - Single file Spooler SPL Vantage Marine VMAR No appware except start-up Icons are named without regard to any rules, except on odd occasions. Application Prefix CommentsDesign DES Various Profile PRFL Various Schematic Model Viewer SMV Various Styles STY Plus FSTY |
PML 1 expressions | • Text values VAR! CEname NAME takes the current element's (ce) name attribute as string VAR! BRhbore HBORE takes bran bore on hbore, even if its number varia ble is stringVAR! X 'NAME' or VAR! X |NAME| sets the variable to the text string 'NAME' Note: Quotes ' ' or vertical bars | | may be used as tex t delimiters. • Number values VAR! X (32) VAR! Y (52) Expression VAR! Z (! X + ! Y) results as STRING 84!!! Expression VAR!Z ('! X' + '! Y') results as STRING! X! Y!!! Expression VAR! Z ('$! X' + '$! Y' ) results as STRING 3252!!! VAR! Temp (23 * 1.8 + 32) calculate a value and result is STRING 73.4 !!! Note: VAR always obtain STRING (text) value even if expr ession calculate numbers!!! • Boolean values VAR! X TRUE Note: This expression set variable! X as true. But this i s string text. This is not as PML2 Boolean where condition is TRUE or FALSE or 0 or 1. Booleans could be used as parameter In IF statement but from VAR evaluate STRING!!! • ARRAY (array is variable with many values in rows) VAR! ARRAY[1] 'AVEVA' VAR! ARRAY[10] NAME Note: VAR always obtain STRING (text) value even if coll ecting DB elements. The result is String value. • STRING ! Name = 'Fred' create STRING variable• REAL !! Answer = 42 create REAL variable: Expression! Z = ! X + ! Y where! X=32! Y=52 results as REAL 84!!! • BOOLEAN !! Flag = TRUE create BOOLEAN variable. If false than is Boolean 0. • ARRAY ! Newarray = ARRAY() create an empty ARRAY ! Newarray[1] = |xxx| or!Newarray[1] = 'xxx ' add first value to the empty ARRAY |
Deleting PML Variables | Creating Unset and undefined variable Each new data type supports a String() method that returns a string representing the Value of the variable. For example: ! X = 2.5 $* defines a variable X of type REAL wit h 2.5 as its numeric value! S = ! X.String() $* will be a variable of type STR ING, with the value “2.5” ! X = REAL()! $* yields the string '(the empty stri ng) ! S = ! X.String() ! X = BOOLEAN() $* yields the string '' (the empty s tring) ! S = ! X.String() ! X = STRING() $* yields the string 'Unset'! S = ! X.String() ! X = ARRAY() $* yields the string 'ARRAY ! S = ! X.String() Other variable types are system-defined variables. Most of these have adopted the unset String 'Unset'. User-defined data types can also pr ovide a String() method. These alsoSupport an UNSET representation, and usually adopt the UNSET representation 'Unset'. For example: ! X = DIRECTION() $* yields the string 'Unset' ! S = ! X.String() All data types can have the value UNSET which indi cates that a variable does not have aValue. A variable created without giving it an init ial value in fact has the value UNSET: !! Answer = REAL()! Name = STRING() ! Grid = BOOLEAN()! Lengths = ARRAY() Variables with an UNSET value can be passed around and assigned, but use of anUNSET value where a valid item of data is required will always result in a PML error. The Presence of an UNSET value may be tested either wit h functions or methods: If ( Unset(! X) ) then if ( ! X.Unset() ) then If ( Set(! X) ) then if ( ! X.Set() ) thenAn UNDEFINED variable is one that does not exist. T he existence of a variable may be Tested with these functions: If ( Undefined(!! Y) ) then If ( Defined(!! Y) ) then There is no equivalent method call. If the variable does not exist, attempting to call a methodWould result in an error. A variable that exists can be explicitly made UNDE FINED with the Delete() method: !! Y.Delete() Warning: You must not attempt to delete members of objects or forms. Mixing PML1 and PML2 expressions could cause mixin g the variables types.Mixing the Variables types give error for example: „Cannot ass ign variable to result - incompatible types (REAL=STRING)". With VAR you will always obtain a S TRING. You could have defined Variable type before you assign any value to the variable: |
Expression operators | Creating Unset and undefined variable
Each new data type supports a String() method that returns a string representing the value of the variable. For example:
!X = 2.5 $* defines a variable X of type REAL wit h 2.5 as its numeric value
!S = !X.String() $* will be a variable of type STR ING, with the value “2.5”
!X = REAL()! $* yields the string ’(the empty stri ng)
!S = !X.String()
!X = BOOLEAN() $* yields the string ‘’ (the empty s tring)
!S = !X.String()
!X = STRING() $* yields the string ‘Unset’
!S = !X.String()
!X = ARRAY() $* yields the string ‘ARRAY
!S = !X.String()
Other variable types are system-defined variables. Most of these have adopted the unset string ‘Unset’. User-defined data types can also pr ovide a String() method. These also support an UNSET representation, and usually adopt the UNSET representation ‘Unset’.
For example:
!X = DIRECTION() $* yields the string ‘Unset’
!S = !X.String()
All data types can have the value UNSET which indi cates that a variable does not have a value. A variable created without giving it an init ial value in fact has the value UNSET:
!!Answer = REAL() !Name = STRING()
!Grid = BOOLEAN() !Lengths = ARRAY()
Variables with an UNSET value can be passed around and assigned, but use of an UNSET value where a valid item of data is required will always result in a PML error. The presence of an UNSET value may be tested either wit h functions or methods:
if ( Unset(!X) ) then if ( !X.Unset() ) then
if ( Set(!X) ) then if ( !X.Set() ) then
An UNDEFINED variable is one that does not exist. T he existence of a variable may be tested with these functions:
if ( Undefined(!!Y) ) then
if ( Defined(!!Y) ) then
There is no equivalent method call. If the variable does not exist, attempting to call a method would result in an error.
A variable that exists can be explicitly made UNDE FINED with the Delete() method :
!!Y.Delete() Warning: You must not attempt to delete members of objects or forms.
Mixing PML1 and PML2 expressions could cause mixin g the variables types. Mixing the
variables types give error for example: „Cannot ass ign variable to result - incompatible types
(REAL=STRING)”. With VAR you will always obtain a S TRING. You could have defined
variable type before you assign any value to the va riable: |
Boolean Operators | ! S = 30 * sin(45) ! T = pow(20,2) (raise 20 to the power 2 (=400)) ! F = (match (name of owner, |LPX|) GT 0) The Boolean, sometimes called Logical, operators h ave the following meanings: • EQ TRUE if two expressions have the same value.• NE TRUE if two expressions have different values. • LT TRUE if the first expression is less than the s econd. • GT TRUE if the first expression is greater than th e second. • LE OR LEQ TRUE if the first expression is less than n or equal to the second.• GE OR GEQ TRUE if the first expression is greater than or equal to the second. • NOT TRUE if the expression is FALSE. • AND TRUE if both expressions are TRUE • OR TRUE if either or both expressions are TRUE. Note: The operators EQ, NE, LT, GT, LE and GE are someti mes referred to as comparator Or relational operators; NOT, AND, and OR are somet imes referred to as Boolean operators. Refer to Precisions of Comparisons for tolerances i n comparing numbers. Several different types of expressions examples:Logical expressions - PDMS attributes Logical constants TRUE, ON, YES for true / FALSE, OFF, NO for false Logical Operators Comparator operators (EQ, NEQ, LT, GT, LEQ, GEQ) Boolean operators (NOT, AND, OR) Logical functions BADREF, DEFINED, UNDEFINED, CREATE, DELETED, EMPTY, MATCHWILD, MODIFIED, UNSET, VLOGICAL.... Logical array expressions PDMS attributes e.g. XLEN YLEN POHE POSITION ORIENT ATION Numeric operator -- + Add, - Subtract, * Multiply, / Divide Numeric function ABS, ACOS, ASIN, ATAN, SIN, COS, TAN, MATCH, MAX, S QRT.. Real expressions - See numeric functions Text expressions - A text string, PDMS attributes, Text operators, Text functions Values to be concatenated are automatically conver ted to STRING by the '&' operator.Type the following onto the command line: ! A = 64! B = 32! M = 'mm' ! C = ! A & ! B & ! M Q var! C Compare this against the results of typing ! D = ! A +! B Q var! D |
Parameterized Macros | Communicating with AVEVA Products in PML All commands need to be supplied to the command pr ocessor as STRINGS. This is ImportantT when working with element creation (using the NEW syntax) to expand the Contents of a PML variable into a string - put a $ in front of it! ! CompType = |ELBO| ! Dist = 5600 NEW $! CompType DIST $! Dist Macros can be parameterized. This means insteadOf hard coding the values through the Macro, the values can be referenced, allowing them to be varied. Simplemac.mac can be Parameterized as follows: NEW EQUIP /$1 NEW BOX XLEN $2 YLEN $3 ZLEN $4 NEW CYL DIA $3 HEI $4 CONN P1 TO P2 OF PREV IF no parameters are specified, the macro will fai l. To avoid this, default values can be put Inside the macro. This is done by specified $d1= at the top of the macro. For example: $d1=ABCDEF $d2=300 $d3=400 $d4=600 Synonyms are abbreviations of longer commands.The y are created by assigning the Command to a synonym variable: E.g. $SNewBox=NEW BOX XLEN 100 YLEN 200 ZLEN 300 E.g. $SNewBox=NEW BOX XLEN $S1 YLEN $S2 ZLEN $S3 (A parameterized synonym) To call the first version, type NewBox. For the secondVersion, type NewBox 100 200 300 If all synonyms are killed, the synonyms needed to run PDMS will be removed. This Means PDMS will no longer work properly and will re quire restarting. If synonyms are turned Off, some PDMS functionality will also be removed.The return this functionality, the Synonyms should be turned back on. To kill a synonym, type $SXXX= & all synonyms $sk To switch synonyms off and on $S- and $S+ Note: If all synonyms are killed, the synonyms needed to run PDMS will be removed.This Means PDMS will no longer work properly and will re quire restarting. If synonyms are turned Off, some PDMS functionality will also be removed. The return this functionality, the Synonyms should be turned back on. $S - defines a local synonym$G - defines a global synonym $U - prevents the deletion of a global synonym whic h has already been defined Global synonym ($G) works inside pml functions/meth ods while local ($S) does not. |
Using the Member Values of an Object | Communicating with AVEVA Products in PML
All commands need to be supplied to the command pr ocessor as STRINGS. This is important when working with element creation (using the NEW syntax) to expand the contents of a PML variable into a string - put a $ in front of it!
!CompType = |ELBO| !dist = 5600
NEW $!CompType
DIST $!dist
Macros can be parameterized. This means instead of hard coding the values through the macro, the values can be referenced, allowing them to be varied. Simplemac.mac can be parameterized as follows:
NEW EQUIP /$1
NEW BOX
XLEN $2 YLEN $3 ZLEN $4
NEW CYL DIA $3 HEI $4
CONN P1 TO P2 OF PREV
If no parameters are specified, the macro will fai l. To avoid this, default values can be put inside the macro. This is done by specified $d1= at the top of the macro. For example:
$d1=ABCDEF $d2=300 $d3=400 $d4=600
Synonyms are abbreviations of longer commands. The y are created by assigning the command to a synonym variable:
e.g. $SNewBox=NEW BOX XLEN 100 YLEN 200 ZLEN 300
e.g. $SNewBox=NEW BOX XLEN $S1 YLEN $S2 ZLEN $S3 (A parameterized synonym)
To call the first version, type NewBox. For the second version, type NewBox 100 200 300
If all synonyms are killed, the synonyms needed to run PDMS will be removed. This means PDMS will no longer work properly and will re quire restarting. If synonyms are turned off, some PDMS functionality will also be removed. The return this functionality, the
synonyms should be turned back on.
To kill a synonym, type $SXXX= & all synonyms $sk
To switch synonyms off and on $S- and $S+
Note: If all synonyms are killed, the synonyms needed to run PDMS will be removed. This means PDMS will no longer work properly and will re quire restarting. If synonyms are turned off, some PDMS functionality will also be removed. The return this functionality, the
synonyms should be turned back on.
$S - defines a local synonym
$G - defines a global synonym
$U - prevents the deletion of a global synonym whic h has already been defined
Global synonym ($G) works inside pml functions/meth ods while local ($S) does not.
|
Storing and Loading PML Functions | define function!! LengthAndTrim(! Name is STRING, ! L ength is REAL) ! Name = ! Name.Trim() ! Length = ! Name.Length() Endfunction Arguments used for output must exist prIor to the c all and one that is also used as an input Argument must also have a value: ! Name = 'FRED'! Length = REAL() The function is called to set the value of a variab le! Length as follows: !! LengthAndTrim(' FRED ', ! Length) When an argUment value is changed within a PML Func tion its value outside the function is Also changed. The following call is incorrect, as t he function cannot modify a constant: !! LengthAndTrim(' FRED ' ,4 ) $* WRONG A PML Function returning a value may beUsed wherev er an expression or PML Variable Can be used, for example, this call to the! Area fu nction defined above: ! PartLength = 7! PartWidth = 6 ! SurfaceArea = !! Area(! PartLength, ! PartWidth) When a PML Function is called it is loaded automat iCally from its source file in a directory Located via the environment variable PMLLIB. The na me of the external file must be Lowercase and must have the .pmlfnc suffix. The sou rce of a PML Function invoked as !! AREA or !! Area or!! Area all correspond to the fi le named area.Pmlfnc. Note: The!! Means that the function is user-defined and that it is global - but!! Does not Form part of the external filename. All user-define d functions are global and only one may be Defined per file. The define function must be theF first line in the file and that its name and the File name must correspond. You may specify ANY as the type of an argument (an d even as the type of the function Return value). Note: The use of ANY should be the exception rather than the rule as it switches offArgument type checking - an important feature of PM L Functions to help ensure correct Functioning of your PML. In the case an argument of type ANY, a value of any type may be passed as the argument to The function: Define function!! Print(! Argument is ANY)$P $! Argument Endfunction Where an argument of type ANY is used, you may need to find out its actual type before you Can do anything with it. The ObjectType() method ca n be used for this purpose: |
PML Procedures | define function!! AnyType(! Argument is ANY) Type = ! Argument.pmlobjectType() If (! Type EQ 'STRING' ) then- - do something with a STRING Elseif (! Type EQ 'REAL' ) then - - do something with a REAL Elseif (! Type EQ 'DBREF' ) then - - do something with a DB Reference Else - - do something with all other types or give a n error EndifEndfunction A PML Procedure is a PML Function that does not re turn a result. A function is defined as A procedure by omitting the data type at the end of the define function statement: Define function!! Area( ! Length is REAL, ! Width is REAL, ! Result is REAL)! Result = ! Length * ! Width Endfunction Here we are using an output argument, ! Result, to r eturn the result rather than using a Function return value. The arguments to the!! Area procedure can be set as follows, and then The procedure invoked with the call command.! SurfaceArea = REAL() ! Partlength = 7 ! PartWidth = 6 Call!! Area(! PartLength, ! PartWidth, ! SurfaceArea) There will be an error if you attempt to assign the result of a PML Procedure because there Is no return value to assign. So, for example you c an say:Call!! Area(! PartLength, ! PartWidth, ! SurfaceArea) ! Answer = ! SurfaceArea But you cannot say: ! Answer = !! Area(! PartLength, ! PartWidth, ! SurfaceA rea) $* WRONG The ( ) parentheses after the name of a procedure o r function must always be present evenFor procedures that do not need arguments: Define function!! Initialize() ! TotalWeight = 0 !! MaxWeight = 0 Endfunction Call!! Initialize() Although the call keyword is strictly speaking opti onal, its use is recommended with Procedures. NOte: As well as procedures, you can invoke a PML Functi on that has a return value using Call, in which case the function result value is di scarded. |
Methods on User-Defined Object Types | define function !!AnyType(!Argument is ANY)
Type = !Argument.pmlobjectType()
if ( !Type EQ 'STRING' ) then
- - do something with a STRING
elseif ( !Type EQ 'REAL' ) then
- - do something with a REAL
elseif ( !Type EQ 'DBREF' ) then
- - do something with a DB Reference
else
- - do something with all other types or give a n error
endif
endfunction
A PML Procedure is a PML Function that does not re turn a result. A function is defined as a procedure by omitting the data type at the end of the define function statement:
define function !!Area( !Length is REAL, !Width is REAL, !Result is REAL)
!Result = !Length * !Width
endfunction
Here we are using an output argument, !Result, to r eturn the result rather than using a function return value. The arguments to the !!Area procedure can be set as follows, and then the procedure invoked with the call command.
!SurfaceArea = REAL()
!Partlength = 7
!PartWidth = 6
call !!Area(!PartLength, !PartWidth, !SurfaceArea)
There will be an error if you attempt to assign the result of a PML Procedure because there is no return value to assign. So, for example you can say:
call !!Area(!PartLength, !PartWidth, !SurfaceArea)
!Answer = !SurfaceArea
But you cannot say:
!Answer = !!Area(!PartLength, !PartWidth, !SurfaceA rea)
$* WRONG
The ( ) parentheses after the name of a procedure o r function must always be present even for procedures that do not need arguments:
define function !!Initialize()
!TotalWeight = 0
!!MaxWeight = 0
endfunction
call !!Initialize()
Although the call keyword is strictly speaking opti onal, its use is recommended with procedures.
Note: As well as procedures, you can invoke a PML Functi on that has a return value using call, in which case the function result value is discarded. |
Method Overloading | define method . Life() ! This.Answer = 42 Endmethod A method may return a result in just the same way a s a PML Function using the returnCommand. Set a member of the object using! This.mem bername. Define method. Answer() IS REAL Return! This.Answer Endmethod Define method. Answer( ! Value Is REAL) ! This.Answer =! Value Endmethod These methods might be used in the following way:! Marvin = object LIFE() -- The method . Life() was called automatically ! Number = ! Marvin.Answer() --! Number is set to the value 42 ! Marvin.Answer(40) ! Number = ! Marvin.Answer() --! Number now has the value 40 Warning: When you create a new objeCt type, or chan ge an existing definition, you Must load the definition by giving the command: Pml reload object _name_ Two or more methods on an object may share the sam e name providing they have Different arguments. This is called method overload ing.PML will invoke the method with the Arguments which match the method call. It is common practice: • To use a method with the same name as a member and one argument of the same Type to set the member's value. For example: ! Marvin.Answer(65) •To use a method of the same name as a member retur ning a value of the same type But with no arguments to get the member's value. Fo r example: ! Number = ! Marvin.Answer() When an object is created, it is possible to suppl y arguments that are passed by PML to aConstructor method with matching arguments instead of the default constructor method: ! Marvin = object LIFE(40) This would invoke a method: Define method. Life(! Value IS REAL) |
Invoking a Method from Another Method | Overloading with ANY As with PML Functions, the type of a methOd argume nt may be specified as ANY. Yew Method overloading is being used, PML will invoke t he method with a matching set of Explicitly typed arguments in preference to calling a method with arguments of type ANY, Irrespective of the order the methodsAppeared in t he object definition file: Define method. SetValue(! Argument Is ANY) Define method. SetValue(! Argument Is REAL) Then: ! SomeObject.SetValue(100) will invoke the method with the REAL argument, but ! SomeObject.SetValue('Priceless' )Will invoke the method with the ANY argument. Within a method! This.Methodname() refers to anoth er method on the same object. So Our second LIFE constructor method, the one with an argument, could be defined as: Define method. Life(! Value IS REAL)! This.Answer(! Value) Endmethod Whenever you add a new method to an object, you ne ed to tell PML to re-read the object Definition, by giving the command: Pml reload object life It is not necessary to use this command if you are simply editing an existing method(Although you will have to use it if you edit a for m definition file, and change the default Constructor method, described in Form Definition Fi le.) In PML 2, forms are a type of global variable. Thi s means that a form cannot have the Same name as aNy other global variable or any other form. Note that a form definition is also The definition of an object, so a form cannot have the same name as any other object type. |