PML Study
PML Study
To start out, I wanted to introduce the Dollar $ symbol and its meanings
$* = Comment line
$( = Starts a comment block
$) = Ends a comment block
Another neat trick that I like to use, especially when using the trace is
ALPHA REQ CLEAR (I will get more into this as I add more and more treads)
This command cleans your command line.
I really hope everyone gets involve and If i miss anything please added to the tread.
A query on usage in the field: how much do you use the $ comments (either $* or $(...$) )?
I want to be able to strip comments when publishing the PML, and am wondering just how
much trouble to go to with wierdly nested and hidden comments! (I will never mangle
anything, but might not strip all the comments if you do really odd things)
I use the $* comments as much as possible. Specially because I'm the kind of person who will
write a macro and forget about it and 6 months later someone is asking me to add some new
function to the macro. I try to add as much comments for my own personal benefit.
If you are new to pml and you want to make life easier. I suggest you try to comment as
much as possible. Also, name you macros something that will make since 6months to even
years from now. I have spend hours, days even months writing macros only to misplace them.
By adding as much comments, you are not only making your life easier but your employeer as
well. This go back to the ISEIT meeting.
I reckon better add the ALPHA LOG command...where you can take ur logs to a file and not
flood ur command line :)
---------------------------------------------------------------------------------------------------------------------
When using the Tracking, you might want to use the alpha log command first. Try this.
Turn trace on
$R6
The modify name form will come up and your command line filled with text.
$R
To turn off the Trace
Open the .txt file and check out some of the code. That is how I learn pml, by reading aveva's
code.
Just a note: You are only allowed to have one log file open at the time. Another option will be
to use Alpha Files. I'll get to that later.
$R<n>
Can also do $HR at the command line to get all options for $R
---------------------------------------------------------------------------------------------------------------------
If I do not remember wrong, you cannot use -- for inline comments where you can use the $*
syntax.
like:
handle any $* Taking care of a problem. If I remember correctly you cannot do this with --
endhandle
I recall reading somewhere that -- can only be used for commenting whole lines.
=====================================================================
This is the macro I am using to test comments so far - I have lots more odd things to add!
Code:
I didn't know I could comment out part of a line with the $*. !!
awesome!!!
(#17)
Then I have here synonyms with $S0 (all my syns + some more). Example :
$S0 FGF =new fla choo all new gask choo all new fla choo all (short sequence for inserting pair
of flanges)
And then finally there are some synonyms with $SU1 for running a macro. Example :
I don't understand the difference between $S0, $S1, $SU1. Is it supposed to be an argument?
Are not arguments in general $n - without 'S'? What does it actually do? And why it says :
When I try to run the macro for myself (in this case : $M/%PDMSUI%/DES/EQUI/$S1 )?
One question...
"$*" works any position in the line, and "--" works only at the beggining of the line.
What is an Array?
The simple answer to me would be a collection.
Type 2
!Array.Append('BOB')
!Array.Append('GEORGE')
!Array.Append('KELLY')
q var !Array
!Array.Clear()
!Array.Size()
!Array.Sort()
!Array.SortUnique()
!Array.Unique()
You can find out more in the PDMS Manual, Search Array Objects.
wats the difference between type1 and type2......sorry am just starting to learn PML..so
forgive me if im asking sumthing verryy basic!
1. How can we assign values to elements using PML...e.g. If I have to assign pspec /A300 TO
ALL PIPES WITH BORE SIZE 100
2. How do we collect elements and run a macro on them...e.g. collect ALL brances under
zone /10LAB and set/change Ispec to /HC
and so on.....
What is the difference between type1 and type2. Now, they are not called type1 and 2, I just
added that so everyone can see that you can do more that one way. An array is a collection
when you use the [ ] and specify a number, you are telling the exact order you want that item
to be in.
For example:
!Array[1] = !!CE
I am adding my current element to the first member of the array
Now, you added 2 questions. I believe that cvitte71 has a hot tread about collections.
In order to do what you are asking for we are going to need to use a loop. I'm going to be
posting another PML Basics (Loop) and I'll use your questions as examples.
Here we go again. Out of everything that I have learn about pml, I had the most difficulty
learning Loops. I didn't understand them, finally after many mistakes I got a handle on loops.
What is a loop?
It’s a series of commands that will continue to happen until the loop is broken.
Do
This starts a loop, now one of my first mistakes was that I didn't specify the number of times I
wanted the loop to run and I didn't know how to break the command
Enddo
For every "Do" you must have an "Enddo"
Now I know I haven't covered collections but you can check out a nice sticky threat cvitte71
has started. So let’s do a simple macro. This macro will collect all sections, check the gtype to
make sure its correct and print any sections that have the incorrect gtype.
var !Coll coll all (SCTN GENSEC) with (Gtype of Catref neq Gtype of Sctn) for $!!CE
I know this is not PML2; lets get the basics out first.
Do !x from 1 to !Coll.Size()
Now, what does this line mean? I already explained that the "Do" starts the loop.
The second parts "!x", is a number any number. In this case from 1 to !Coll.size().
In other words, the first time the loop runs, !x will equal 1 then 2 so on until it reaches !
Coll.Size()
What is !coll.size()?
It’s the number of items inside the !coll array.
Enddo
$**********************************************
with out the comments
$**********************************************
var !Coll coll all (SCTN GENSEC) with (Gtype of Catref neq Gtype of Sctn) for $!!CE
Do !x from 1 to !Coll.Size()
$P $!Coll[$!x] has the wrong Gtype
Enddo
Hello,
you can also use:
var !Coll coll all (SCTN GENSEC) with (Gtype of Catref neq Gtype of Sctn) for $!!CE
Do !x indices !Coll
$P $!Coll[$!x] has the wrong Gtype
Enddo
or
Do !x values !Coll
$P $!x has the wrong Gtype
Enddo
Do !x indices !Coll
!X is still a number
Do !x values !Coll
!x is now the item or an element
More examples, this is a request by 786PDMS
1. How can we assign values to elements using PML...e.g. If you have to assign pspec /A300
TO ALL PIPE WITH BORE SIZE 100
First, You have to do a collection for all Pipe with bore eq 100. Again, cvitte71 has a great
thread on collections going on.
Var !PIPE COLL ALL (PIPE) WITH (PARAM[1] OF CATREF OF SPCO EQ 100) FOR $!!CE
Do !x indices !PIPE
$!PIPE[$!x]
PSPEC /A300
Handle Any $* Why did I add a Handle, the pipe could of been claim or locked, this
way the macro will continue
$pError on $!PIPE[$!x] $*Printing the error so I can identify the element that the
pspec was not assigned
EndHandle
Enddo
2. How do we collect elements and run a macro on them...e.g. collect ALL brances under
zone /10LAB and set/change Ispec to /HC
Do !y indices !BRANCH
$!BRANCH[$!y]
Ispec /HC
Handle any
$pError on $!BRANCH[$!y]
EndHandle
Enddo
Are you going to examine OBJECTS, especially the COLLECTION OBJECT. And the use of this
object? Like you pointed out in your thread, the other collections thread explores multiple
ways to create the collection using both PML1 and PML2. Very intriquing. The multiplicities of
options in using PML can be daunting.
--------------------------------------------------------------------------------------------------
Yes, I'll start getting more into object collect & object collections. Here is another example
using a different type of collection
Do !y indices !BRANCH
$!BRANCH[$!y]
Ispec /HC
Handle any
$pError on $!BRANCH[$!y]
EndHandle
Enddo
PDMSGuru, I'm not a piping designer (my back ground is structural) and I got the
information on how to queary the pipe bore from a previous threat you answered, could you
double check my previous collection. I don't want to give anyone the wrong information.
Specially since we are not running pdms out of the box, we have customize pdms to an
extreme.
================================================================
As you get an array of element references directly by using the CollectAllFor function you
could also assign the attribute value without first jumping to the element, like:
Do !y indices !BRANCH
!BRANCH[!y].Ispec = /HC
Handle any
$p Error on $!BRANCH[$!y]
EndHandle
Enddo
The selected element would in this example remain the same also while running through the
loop.