0% found this document useful (0 votes)
40 views59 pages

Microsoft PowerPoint - AdminTraining-Level3

Uploaded by

manidme6699
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
40 views59 pages

Microsoft PowerPoint - AdminTraining-Level3

Uploaded by

manidme6699
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

PDMS ADMINISTRATOR TRAINING – LEVEL3

CONDUCTED BY
WORLEYPARSONS MALAYSIA

TRAINER: S. VASUDEVA SARMA (VASU)

PDMS ADMIN TRAINING – LEVEL3 (25/7/07 – 27/7/07)


1
INTRODUCTION

 INTRODUCE YOURSELF

 LIST YOUR PRIORITIES

PDMS ADMIN TRAINING – LEVEL3 (25/7/07 – 27/7/07)


2
Agenda for this Course

Day-1 Day-2 Day-3


 Introduction to  How to make PML talk?  Creating PML Forms
Programming ..contd..
 Alerts and Error
 Importance of Logic Messages  Creating PML
Functions/Methods
 Variables and  PML Control Statements
 Using Arguments
Expressions  If/Else/Endif
 Returning Values
 Do Loops
 1st Macro of the Course  GoLabel
-- Lunch Break –
--- Lunch Break ---
 Built-in Objects and -- Lunch Break –
 Importance of Methods
environment variables
PMLLIB and PDMSUI  Handling Files and
Folders  Creating New PML
 Error Handlers  Reading from Files Objects
 Collecting / Evaluating  Writing to Files
 Q&A
Arrays  Debugging PML Code
 Pseudo Atrributes  Creating PML Forms

PDMS ADMIN TRAINING – LEVEL3 (25/7/07 – 27/7/07)


3
Introduction to Programming

 Computers aren't very smart. Sure, they can do a


lot of math or help you search the Internet. But, if
you asked a computer to vacuum the house for
you, could it do it? If you asked a computer to draw
a picture of a bird for you, would it? A computer
would have no idea about what you're saying.

 Computers are bad at understanding things. If you


don't give them exact instructions, they become
confused and make mistakes. Telling a computer
what you want it to do is sometimes hard because
you have to explain things very carefully.

 Because computers don't understand English,


these instructions have to be written in special
computer languages that computers can
understand.

PDMS ADMIN TRAINING – LEVEL3 (25/7/07 – 27/7/07)


4
Importance of Programming Logic

 It's important for beginners and students to


understand "the big picture" - that is, how
software systems are created in the real world.

 If you have really analysed and designed the


system correctly based on proper LOGIC,
writing the code will be almost automatic and
the testing and implementation will take much
less time

 Actually writing the program code should take


less time and effort than any other phase of the
project.

Note: Everything is vague till you have tried to make it precise

PDMS ADMIN TRAINING – LEVEL3 (25/7/07 – 27/7/07)


5
Variables

 In mathematics, a variable often represents an unknown


quantity that has the potential to change
 In computer science, it represents a place where a quantity can
be stored.

PDMS ADMIN TRAINING – LEVEL3 (25/7/07 – 27/7/07)


6
Categories of Variables

PML allows for the following 3 categories of variables


 Numbered Variables
 You can define numbered variables, like below

 Local Variables (!a, !MyPhone, !CePos, !EleList, !Myarray)


 Local variables are retained within the macro / method / function. The
system will not remember the variable definition (or) its value when the
macro / method / function is completed.
 Global Variables (!!a, !!MyPhone, !!CePos, !!EleList, !!Myarray)
 Global variables are retained until the PDMS session is completed. The
system will remember the variable definition and its value until you exit
PDMS.

PDMS ADMIN TRAINING – LEVEL3 (25/7/07 – 27/7/07)


7
Types of Variables

 PML Variables can be any of the following built-in types:


ALL EXAMPLES
 Real (!Mynumber = 99 / !!ZipCode = 50400 / !SlopeRatio = 0.042
HERE ARE  String (!!EvarValue = ‘MAS000’ / !Equitype = ‘Compressor’)
PML/2 STYLE
 Boolean (!Result = True / !SlopeUp = False / !!Answer = False )
DEFINITIONS
 Array (!names[1] = ‘Paul’, !names[2] = ‘Mazlan’, !Names[3] = ‘Kumar’)

 All PML/1 style definitions of variables would be of string type.


See the snapshots below to appreciate the difference

PML/1 STYLE
DEFINITIONS

PML/2 STYLE
DEFINITIONS
PDMS ADMIN TRAINING – LEVEL3 (25/7/07 – 27/7/07)
8
OBJECTS – An extension of variables

 PML/2 has a collection of predefined objects which are an extension


of variables.
 PML/2 also allows you to create objects, where you can define your
own variable type.
 An object can be used to store more than one value. For example, if
you want to store the equipment name, position and its orientation
normally, you would create 3 variables say,
 !Equiname
 !EquiPos
 !EquiOri.

 With PML/2, you can create an Object called !MyEquiDet and create 3
variables under it called
 ![Link]
 ![Link]
 ![Link]

 These are very useful for advanced programmers when they pass
arguments to functions and subroutines.
PDMS ADMIN TRAINING – LEVEL3 (25/7/07 – 27/7/07)
9
PML Expressions

 Expressions are calculations using PML variables

Using PML1 Using PML2


Var !x (100)
Var !y (200) !x = 100
VAR !Z ( $!X + $!Y ) !y = 200
!Z = !X + !Y
NOTE: all PML1 variables are STRING data
types

 Expression operators are as below


+-/*
LT GT EQ NE LE GE
NOT AND OR
SIN COS TAN SQR POW NEGATE
ASIN ACOS ATAN LOG ALOG ABS
INT NINT

PDMS ADMIN TRAINING – LEVEL3 (25/7/07 – 27/7/07)


10
Expressions - Examples

!backdir = !DAY + !MONTH + ![Link]().STRING(). + 'PipingMTO‘

!outfile = |$!pcod-PIPINGMTO-| + !DAY + !MONTH + ![Link]()

!Easttotal = ( (($!Easttotal * $!Dryweight) + (![Link](East) * $!Weight)) / ($!Dryweight + $!Weight) )

!Northtotal = ( (($!Northtotal * $!Dryweight) + (![Link](North) * $!Weight)) / ($!Dryweight + $!Weight) )

!Uptotal = ( (($!Uptotal * $!Dryweight) + (![Link](Up) * $!Weight)) / ($!Dryweight + $!Weight) )

PDMS ADMIN TRAINING – LEVEL3 (25/7/07 – 27/7/07)


11
Order of Precedence

The order of precedence for evaluating expressions are as


below:
1. () [Anything within the brackets are evaluated first]

2. * / [Multiplication and division comes next]

3. + - [Addition and Subtraction comes next]

4. EQ NE GT LT GE LE [The comparisons come next]

5. NOT [Booleans come next, 1st is the NOT in booleans]

6. AND [2nd is the AND in booleans]

7. OR [OR is the last in booleans]

PDMS ADMIN TRAINING – LEVEL3 (25/7/07 – 27/7/07)


12
The 1st Macro of the Course

 Type the following in a NotePad / Crimson Editor and save it as


C:\Temp\[Link]

 Run the macro in PDMS Command Window by typing


$m /c:\temp\[Link]
 Is your equipment created? You may get some errors. Do not
Worry.
 We’ll try to make this macro to accept inputs from user in the
next slide.
PDMS ADMIN TRAINING – LEVEL3 (25/7/07 – 27/7/07)
13
1st Macro made to accept user inputs

 Change the macro [Link] as shown below and save it.

 |$1|, $2, $3 and $4 represents the arguments to the macro.


 You need to run the macro as
$m /c:\temp\[Link] /NEW-EQUIP 2500 3000 400

$1 : Argument one $2 : Argument two $3 : Argument three $4 : Argument four

PDMS ADMIN TRAINING – LEVEL3 (25/7/07 – 27/7/07)


14
Comments are very important
 Comment lines are very important in macros
 They are ignored by the system, but understood by
humans
 Be liberal about writing comments in macros
 These comments would help you debug the program
at a later date
Anything between
$(
and
$)
are comments

Anything which begins with – is


also a comment

PDMS ADMIN TRAINING – LEVEL3 (25/7/07 – 27/7/07)


15
LUNCH BREAK
(DAY1)

PDMS ADMIN TRAINING – LEVEL3 (25/7/07 – 27/7/07)


16
PMLLIB AND PDMSUI

Sample Settings done in a batch file

SET PMLLIB=%SDNFIMPEXP% X:\PD116\RHWLIB C:\AVEVA\MDS11.6\PMLLIB11.6


C:\AVEVA\MDS11.6\PMLLIB11.5 c:\aveva\mds11.6\pmllib C:\AVEVA\ABA11.6\PMLLIB
C:\AVEVA\PDMS11.6.SP1\pmllib

SET PDMSUI=X:\PD116\RHWCUS\PDMSUI C:\AVEVA\MDS11.6\PDMSUI11.6 C:\AVEVA\MDS11.6\PDMSUI11.5


C:\AVEVA\MDS11.6\pdmsui C:\AVEVA\ABA11.6\PDMSUI C:\AVEVA\Pdms11.6.SP1\pdmsui

 In macros/command window, whenever we refer to %PMLLIB%/<Something> (or)


%PDMSUI%/<Something>, the system would search for “Something” in all the
paths set in the batch file, and pick up the first one, that it hits upon.

 Please note that, if you have two different copies of the same “Something” in two
different folders, the first “Something” which the system finds would be used.

PDMS ADMIN TRAINING – LEVEL3 (25/7/07 – 27/7/07)


17
PMLLIB AND PDMSUI ..contd

 Some of you might have noticed the PMLLIB warning, as shown below. It is
because of this and causes no harm – but the sequence specified in batch file
determines which “Something” would be used.

A Word of Caution from Aveva:

PDMS ADMIN TRAINING – LEVEL3 (25/7/07 – 27/7/07)


18
Error Handlers
 We use Error Handlers to inform the user about what the system is
expecting from them.

 Which one would you prefer (as a user) between the two sets of error
messages above (Left or Right)?

PDMS ADMIN TRAINING – LEVEL3 (25/7/07 – 27/7/07)


19
Error Handlers ..contd

 Update your macro [Link] to look like this below. See, how Errors have
been handled

 A good program would always have a lot of Error Handlers. It should not
terminate abruptly creating a mess of the members of list.

 If a program is good and cannot proceed because of errors (whatever the


reason), it would clear the mess it has created.

 Please note, there is no exhaustive list of Error Handlers supplied by Aveva.


 The best way is for the programmer to simulate the error situations and note down the error numbers
shown on the command window and handle them within his macro.
PDMS ADMIN TRAINING – LEVEL3 (25/7/07 – 27/7/07)
20
Collecting / Evaluating Arrays

 Ever used the List functionality of PDMS?

 A List is nothing but an array.


Arrays/Lists are very powerful.

 But don’t mess around with them. If you


mess with them, they will make a mess of
the database.

 Try this Simple Collection:


Var !MyCollection collect all Site
Q var !MyCollection

 Try this now:


Var !Mycollection eval(name) for all Site
Q var !MyCollection

PDMS ADMIN TRAINING – LEVEL3 (25/7/07 – 27/7/07)


21
Conditional Statements / Expressions

Some Conditional Statements / Expressions:


!A eq !B If variable !A equals !B
Type eq ‘ELBO’ If Type is ELBO
P1BOR EQ 50 If P1Bore is 50
NAME EQ ‘/P100’ If name is /P100
P1BOR GT 50 If p1bore is greater than 50
MATCHW (Name,’/P*’) EQ TRUE If name starts with /P
MATCH (TYPE,’ELBO’) NE 0 If Type is ELBO
MATCH (NAME,’/P100’) EQ 1 If name is /P100
MATCHW (DTXR,’*B16.9*’) If the description contains the text B16.9
PARA[1] OF CATREF EQ 50 If parameter 1 of Catalogue reference is 50
SKEY OF DETREF EQ ‘FLOR’ If SKEY of the detail reference is FLOR
PDMS ADMIN TRAINING – LEVEL3 (25/7/07 – 27/7/07)
22
Conditional Collections / Evaluations

 When writing macros / programs, we have to do a lot of collections /


evaluations based on some conditions.
 See some examples of Conditional Collections / Evaluation
statements here below:
Do a Q var after each of these statements to see

1. Var !PipeLst eval(name) for all Pipe with Purp of PSPE eq ‘PIPE’
what is stored in the collection

2. Var !AttaLst collect all Atta with SKEY of DETREF eq ‘FLOR’ For /P100
Var !StexLst eval(Stext) for all from !AttaLst

Var !ZoneLst eval(name of zone) for all from !AttaLst

3. Var !FlanLst collect all Flan with matchw (dtxr,’*1500#*RTJ*’) eq true for ce
var !SizeLst eval(p1bor) for all from !FlanLst

4. Var !MdbLst eval(name) for all MDB


Did you notice that all these
PDMS ADMIN TRAINING – LEVEL3 (25/7/07 – 27/7/07)
variables are Array variables? 23
Pseudo Attributes

 When writing macros, we need to collect elements or evaluate


a lot of attributes.

 PDMS lists out only a few attributes on the screen. Starting


version-11.4, pseudo attributes have been introduced.

 You can also use the Pseudo attributes in your Collect /


Evaluate Statements

 Please refer to Appendix-D of “Plant Design Software


Customisation Reference Manual” for a complete list of
Pseudo Attributes.

PDMS ADMIN TRAINING – LEVEL3 (25/7/07 – 27/7/07)


24
Write / Prompt Statements

 Try these statements


WRITE |Please check the name you have given|
prompt |Please check the name you have given|

 You need to try the following 3 lines together


Prompt OFF
Prompt load escape |Please pick a SCTN|
Var !ItemName name of ID @

 Try changing the last line to


Var !ItemName name of ID SCTN@

 Try this
Var !ItemName name of ID SCTN BOX @
(For this, your prompt load escape statement can be “Please pick a SCTN or BOX”)

 Type this to clear the prompt


PROMPT DISMISS
Type this as a macro ([Link]) and let us diagnose this

PDMS ADMIN TRAINING – LEVEL3 (25/7/07 – 27/7/07)


25
String Expressions / Global Variables

 Change the highlighted line numbers in the previous


macro as below. Notice, how 2 or more strings can be
added together.

 We’ll see more of the string manipulation techniques,


when looking at built-in objects/ methods
Two more trials to understand Array and Global Variables:
1. Do a Q Var !OutStr within the macro
2. Try changing the !OutStr as a Global Variable, remove the Q var !OutStr within
the macro, and do a Q var !!OutStr after the macro is complete on the command
window. Now, you should be able to appreciate the utility of Global variables

PDMS ADMIN TRAINING – LEVEL3 (25/7/07 – 27/7/07)


26
ENJOY THE REST OF THE DAY
(DAY1)

PDMS ADMIN TRAINING – LEVEL3 (25/7/07 – 27/7/07)


27
If .. Else .. Endif

Syntax: If the condition defined by the


‘expression’ is satisfied, then
IF ( ‘expression’ ) THEN
PDMS/PML Syntax
ELSEIF ( ‘expression’ ) THEN Do something
PDMS/PML Syntax
ELSE Else, if another condition defined by
PDMS/PML Syntax ‘another expression’ is satisfied, then
ENDIF
Do something else

The simplest form of the IF construct is:


If all the conditions fail, then do
IF (‘expression’) THEN
PDMS/PML Syntax
ENDIF Do something different

PDMS ADMIN TRAINING – LEVEL3 (25/7/07 – 27/7/07)


28
Conditional Expressions

Some Conditional Expressions:


!A eq !B If variable !A equals !B
Type eq ‘ELBO’ If Type is ELBO
P1BOR EQ 50 If P1Bore is 50
NAME EQ ‘/P100’ If name is /P100
P1BOR GT 50 If p1bore is greater than 50
MATCHW (Name,’/P*’) EQ TRUE If name starts with /P
MATCH (TYPE,’ELBO’) NE 0 If Type is ELBO
MATCH (NAME,’/P100’) EQ 1 If name is /P100
MATCHW (DTXR,’*B16.9*’) If the description contains the text B16.9
PARA[1] OF CATREF EQ 50 If parameter 1 of Catalogue reference is 50
SKEY OF DETREF EQ ‘FLOR’ If SKEY of the detail reference is FLOR
PDMS ADMIN TRAINING – LEVEL3 (25/7/07 – 27/7/07)
29
Using If .. Else ..Endif Statements

 Update the [Link] to


include the If Statements
as shown here and save
it as [Link]

 Run the macro and you


can notice how the
macro behaves
differently now.
!!Our macro has likes and dislikes
too!!

PDMS ADMIN TRAINING – LEVEL3 (25/7/07 – 27/7/07)


30
Do .. Enddo Loops

PDMS ADMIN TRAINING – LEVEL3 (25/7/07 – 27/7/07)


31
Do .. Endo in Use

Type the macro as shown below ([Link])


If the “by “ syntax is missing, the
default increment is 1

Highlights of this macro


$1 indicates Argument 1
PML Syntax

!p indicates Counter Variable

The PML syntax gets executed 6 times

Conn p1 to p$!p These are the main logical

New sube /$!-leg$!p statement of this macro

PDMS ADMIN TRAINING – LEVEL3 (25/7/07 – 27/7/07)


32
Do .. Endo in Use

Type the macro as shown below ([Link])

This macro creates a list of all


TUBI elements with a length
greater than 1000mm.
[Link]() indicates the
total size of the array Try with following options:
 removing “Prec Var 0DP” and just
typing Var !Itle Itle
 Changing the Condition to list all
TUBI of lengths greater than 6m
 Changing the condition to list all
TUBI of lengths less than 100mm

PDMS ADMIN TRAINING – LEVEL3 (25/7/07 – 27/7/07)


33
Do .. Endo combined with If .. Endif

Change the macro [Link] to [Link]


as shown below:
 We have two Remarks,
one for more than 6m
and one for less than
100mm spool.
 We do a check and
report the remark based
on the length of the
TUBI segment

PDMS ADMIN TRAINING – LEVEL3 (25/7/07 – 27/7/07)


34
GoLabel

Type the macro as shown below ([Link])


If there is no From and To commands
Continue the Do Loop until advised

If the From command is missing,


then the default start value is 1

 This macro has a nested


Do loop (i.e.) A Do Loop
within a Do Loop.
 PML allows up to 8 levels
of nesting
 We transfer the control to
another location (i.e. advise)
once a predefined
Labels are case sensitive and are
supposed to be unique within a macro
condition has been
satisfied

PDMS ADMIN TRAINING – LEVEL3 (25/7/07 – 27/7/07)


35
Break Statements

 Break Statements get you out of the Do


Loop when you don’t want to be within the
Do Loop.

 Ideal, when you do not know initially as to


where is the end point of the loop, but you
would know once a condition is satisfied

Beware of Infinite Loops .. Can go on forever

This Program creates an


infinite Loop

Discuss and find the


reason

PDMS ADMIN TRAINING – LEVEL3 (25/7/07 – 27/7/07)


36
Skip Statement

 Skip Statements are used


to skip the Do loop only for
certain conditions

PDMS ADMIN TRAINING – LEVEL3 (25/7/07 – 27/7/07)


37
Different types of Alerts

!![Link]( ’You cannot do this!’ ) !![Link]( ‘Saving your data now' )

!![Link]( ‘Do not press this button again!' )

!Answer = !![Link]( ‘Test Passed – Continue ?’ ) !Answer = !![Link]( ‘OK to Exit this Session?’ )

PDMS ADMIN TRAINING – LEVEL3 (25/7/07 – 27/7/07)


38
Using Alerts to ask questions

 Modify the same macro as


below and save as [Link]
Break if !A is greater than 10

Do it if the User says YES

Other wise Skip

PDMS ADMIN TRAINING – LEVEL3 (25/7/07 – 27/7/07)


39
LUNCH BREAK
(DAY2)

PDMS ADMIN TRAINING – LEVEL3 (25/7/07 – 27/7/07)


40
Built-in Objects and Methods

 It is highly recommended to use


the PML reference manual, to
know more about the objects and
methods. All of these cannot be
covered during the training.

 When writing actual macros at


your work place, this manual is a
must and would be very handy

PDMS ADMIN TRAINING – LEVEL3 (25/7/07 – 27/7/07)


41
Basics of Objects and Methods

Source: [Link]
 Class
A class defines the abstract characteristics of a thing (object), including the thing's
PML has no characteristics (its attributes, fields or properties) and the things it can do (its behaviors or
Class definitions methods or features). For example, the class Dog would consist of traits shared by all dogs,
such as breed, fur color, and the ability to bark. Classes provide modularity and structure in an
object-oriented computer program. Collectively, the properties and methods defined by a class
are called members.

 Object
A particular instance of a class. The class of Dog defines all possible dogs by listing the
characteristics that they can have; the object Lassie is one particular dog, with particular
versions of the characteristics. A Dog has fur; Lassie has brown-and-white fur. In programmer
jargon, the object Lassie is an instance of the Dog class.

 Method
An object's abilities. Lassie, being a Dog, has the ability to bark. So bark() is one of Lassie's
methods. She may have other methods as well, for example sit() or eat(). Within the program,
using a method should only affect one particular object; all Dogs can bark, but you need one
particular dog to do the barking.

PDMS ADMIN TRAINING – LEVEL3 (25/7/07 – 27/7/07)


42
Methods of String Object

!A = ‘Hi How are you?’ !Value = ’10’


!B = ‘I am Fine’ !Now = ’23-Aug-2007’
!C = ‘How about you?’ !Pos = ‘E0 N0 U0’

Listed below are some of the methods of String object


!A = ![Link]() !A = ‘HI HOW ARE YOU?’
!B = ![Link]() !B = ‘i am fine’
!D = ![Link]() !D = 14 (Real Object)
!F = ![Link](‘How’) !F = ‘ about you?’
!F = ![Link](‘How’).trim() !F = ‘about you?’
!G = ![Link](‘How about’,’Where are’) !G = ‘Where are you?’
!NewPos = ![Link]() !NewPos would be a Position object
!RealValue = ![Link]() !Realvalue would be a real object
!SplitNow = ![Link](‘-’) !Splitnow would be an array variable

PDMS ADMIN TRAINING – LEVEL3 (25/7/07 – 27/7/07)


43
Methods of Array Object

Var !SiteLst eval(name) for all Site


Var !Zone1Lst eval(name) for all Zone with matchw (name,’/P*’)
Var !Zone2Lst eval(name) for all zone with matchw (name,’/P*’) ne true
Var !EquiDescLst eval(Desc) for all Equi for CE

Listed below are some of the methods of array object


![Link]() The contents of the array are sorted
!FirstSite = ![Link]() The value of the 1st element of array
!PipeSiteSeq = ![Link](‘/P100’) The index number of the value ‘/P100’
![Link](5,2) Deletes the array indices 5 and 6
!ComressedSiteLst = ![Link]() Compresses the array site, by removing the deleted elements
!AllzoneLSt = !Zone1Lst Appends the array !Zone2Lst at the end of
![Link](!Zone2Lst) !AllZoneLSt
![Link]() True if the array is empty
![Link]() Inverts the array (Useful to sort in descending order)
!a = ![Link]() Gives the maximum index number of the array
![Link]() Creates an array of unique values

PDMS ADMIN TRAINING – LEVEL3 (25/7/07 – 27/7/07)


44
Methods of Real Object

!R1 = 300
!R2 = -232
!R3 = 24.897

Listed below are some of the methods of String object

!R3int = ![Link]() !r3int = 25 (Nearest integer)


!R3int = ![Link]() !r3int = 24 (Integer Part)
!Answer = ![Link](200,500) !Answer = true, 300 is between 200 and 500
!R2abs = ![Link]() !R2 = 232 (Absolute value, ignore sign)
!R3Cosine = ![Link]() !r3Cosine = 0.907066 [Cos (24.897)]
!R3Bore = ![Link]() !R3Bore = 25mm, 25mm is the nearest bore
!R1sqrt = ![Link]() !R1sqrt = 17.3205, √300 = 17.3205
!R3cube = ![Link](3) !R3cube = 15432.7 (24.897 x 24.897 x 24.897)
!R1Str = ![Link](‘D3’) !R1str = 300.000 (3 decimal points)

PDMS ADMIN TRAINING – LEVEL3 (25/7/07 – 27/7/07)


45
Methods of File Object

!File1 = object file (‘c:\Aveva’)


!File2 = object file (‘C:\Aveva\pdms11.6.sp3\[Link]’)
!File3 = Object file (‘c:\temp\[Link]’)
!File4 = object file (‘c:\temp\[Link]’)

Listed below are some of the methods of File object

!Found = ![Link]() Check if the file exists and result is True/False


!Directory = ![Link]() !directory would be an array of directory contents
![Link](!File3) Copies !File2 to path specified in !file3
!File3Contents = ![Link]() Reads the contents of !File3 into an array
![Link](’OVER’,!File3Contents) Writes the contents of array into !file4 in overwrite mode
![Link](‘APPEND’,!Directory) Writes the contents of array into !File4 in Append mode
!File4Size = ![Link]() !File4size would be a real value (size in bytes)

PDMS ADMIN TRAINING – LEVEL3 (25/7/07 – 27/7/07)


46
Reading/Writing Files in PML/1 Syntax

Openfile /C:\temp\[Link] read !TxtFile


Do !i
Readfile $!Txtfile !TxtRecord[$!i]
Handle(41,325)
break
Endhandle The same thing in PML/2
Enddo Please note you can only !File3 = Object file (‘c:\temp\[Link]’)
Closefile $!TxtFile open 10 files at a same time in PML/1 !File4 = object file (‘c:\temp\[Link]’)
!File3Contents = ![Link]()
![Link](’OVER’,!File3Contents)

Openfile /C:\temp\[Link] over !Outfile


Do !i from 1 to ![Link]()
Writefile $!outfile |$!TxtRecord[$!i]| Nevertheless, both methods have their own
Enddo Benefits, which will be known when writing
Closefile $!outfile major programs

PDMS ADMIN TRAINING – LEVEL3 (25/7/07 – 27/7/07)


47
Exercise

 Create a macro to generate a report of Valves in the model.


 Your report should have
 Pipe name We will debug your code during
 P&ID reference this class

 Valve size
 Valve Stype
 Valve Description
 Valve Spec Use Construct statement:
Construct Distance PA to PL
 Valve Face-to-Face distance
 Valve weight stored in a UDA at SPREF

 Your report should be sorted based on Spec, Styp and Size


 Choose your own delimiter between the fields

 You should exclude all the instrument valves and all the pipes in the study
sites from your report

PDMS ADMIN TRAINING – LEVEL3 (25/7/07 – 27/7/07)


48
ENJOY THE REST OF THE DAY
(DAY2)

PDMS ADMIN TRAINING – LEVEL3 (25/7/07 – 27/7/07)


49
PMLLIB for Training

 Create the following folders:


c:\temp\PMLLIB
C:\temp\PMLLIB\COMMON
C:\temp\PMLLIB\COMMON\FORMS
C:\temp\PMLLIB\COMMON\FUNCTIONS
C:\temp\PMLLIB\COMMON\OBJECTS

 Edit your batch file, to include c:\temp\pmllib in your PMLLIB path

 All the PML/2 forms, functions and objects created during the training
should be saved in these folders.

PDMS ADMIN TRAINING – LEVEL3 (25/7/07 – 27/7/07)


50
Creating Forms

 Type the macro [Link] like the one


shown on right
 Save it in training PMLLIB path
 Remember to type PML REHASH ALL, every time
you create a new form / function / object
 PML REHASH ALL sometimes does not work. In
such situations delete the [Link] file from the
PMLLIB folder from Windows Explorer, and type
the PML REHASH ALL again. It will work
 Type show !!Trgform1 to show the form.
 Type Kill !!Trgform1 to kill the form definition

 All PML Forms are Global Variables, You can do a


Q var !!Trgform1
 They are also to be treated as objects
 These form objects can have gadgets, methods
and functions

PDMS ADMIN TRAINING – LEVEL3 (25/7/07 – 27/7/07)


51
Forms and Menus Objects (Gadgets)

 ALERT  OPTION
 ALPHA  PARAGRAPH
 BAR  RGROUP
 BUTTON  TEXT
 FORM  TEXTPANE
 FMSYS  TOGGLE
 FRAME  VIEW
 LIST  2D VIEW
 MENU  3D VIEW

PDMS ADMIN TRAINING – LEVEL3 (25/7/07 – 27/7/07)


52
Creating Forms – Exercise1

The PML code for the form

The Actual Form

PDMS ADMIN TRAINING – LEVEL3 (25/7/07 – 27/7/07)


53
Creating Forms – Exercise2

The PML code for the form

The Actual Form

PDMS ADMIN TRAINING – LEVEL3 (25/7/07 – 27/7/07)


54
PML Functions / Methods

 When writing big applications, you may frequently need to use the
same instructions (same set of commands) in your code.

 By declaring a function/ method and typing the needed instructions


into it you can replace the repeated instructions with a call to this
function / method.
 In PML/1, programmers used to create it as a separate macro, which would be called as and when
needed. But, these were basically methods – but PML/1 had no “Functions” functionality.

 Functions/ Methods are a very useful part of PML/2 programming


because your code will be smaller more stable, faster and easy to
debug.

 The difference between them is that functions generally return a value


and methods do not
 Some PML functions return the result as an argument to the function itself. Such functions are called
PML procedures

PDMS ADMIN TRAINING – LEVEL3 (25/7/07 – 27/7/07)


55
A Simple PML Function

 Type the code below, and save it as [Link] in the


local PMLLIB/functions folder.

 Do a PML REHASH ALL and check the result.


 Modify the function as a procedure as below and try the result

PDMS ADMIN TRAINING – LEVEL3 (25/7/07 – 27/7/07)


56
Understanding a Function

Function name Arguments

Definition of the function

Return Value

 All user-defined functions are global and only one may be defined per file.

 Note that define function must be the first line in the file and that its name and
the file name must correspond.

 The name of the external file must be lowercase and must have the .pmlfnc
suffix.
PDMS ADMIN TRAINING – LEVEL3 (25/7/07 – 27/7/07)
57
A Simple Method

 The code on the left


side creates a form as
shown.

 A simple method called


.init() has been defined
in the code

 This method initialises


the list of colors in the
form.

PDMS ADMIN TRAINING – LEVEL3 (25/7/07 – 27/7/07)


58
A Simple Object

Save this code as [Link] in the


objects folder of the PMLLIB path.

A method of an object have the same name


but a different ‘signature’ – i.e. different
arguments in its definition

This is called Methods Overloading

PDMS ADMIN TRAINING – LEVEL3 (25/7/07 – 27/7/07)


59

You might also like