Macro Port Aliases
"Short Desc" is now useful! Simplify and future-proof EbsScripts, Text Fields, and Excel EbsLink reads
In v15.01, macro “Short Descriptors” gained significant functionality — they can be used as an Alias in EbsScripts, Text Fields, and in the Excel EbsLink.
The screenshots in this post are from the model “KS Pump with Port Alias Names.ebs” on my Ebsilon Tips OneDrive.”
Port Definitions
Here are Port Definitions in the Macro Interface inside the macro:
Previously, the Short Desc would only be used for display on the macro. Now these are MUCH more useful.
Short Desc as an Alias
Here’s a screenshot of the top-level of the model.
The two white Text Fields show the same info, but get the data using different syntax. Their text is shown in the blue Text Fields.
The top one, which uses the “._N” notation, was the only way to refer to the pipes connected at ports. Above, $._1.P refers to the pressure of the pipe at Port 1 of the object the Value-Field is attached to (as indicated with the $ symbol).
The bottom one shows the new way. Instead of the port number, the port can be referred to by its Short Desc, preceding it with an “x” as in “._xShortDesc”. Thus, $._xSuction.P gives the pressure of the pipe at the port named “Suction”.
It’s good to think of “Short Desc” as the name of the port.
In Excel
Use the powerful “expr” keyword to read model data using the ShortDescription syntax:
In EbsScripts
Use the “$” notation to mean “this object” and code like “$._xSuction.P” to refer to the pipe data you need.
Why is this Future-Proof?
On macros with many ports, I’ve used the circled up / down buttons to change the order of ports:
But that broke the EbsScripts in the macro! Many port numbers got shifted by one, and MANY references using the _N port number became incorrect. I had a specific reason for needing the many of the 30 ports clustered together, so I painstakingly edit every affected port number.
The Short Description alias solves this problem. A reference like $._xSuction.P is immune to the port numbering (i.e. the sequence of the ports).
This will also make your Text Field and EbsLink “expr” references robust.
Use this feature! As they say, “Your future self will thank you”.
Further reading
From the v15.01 Patch Notes, here’s a full list of what the Short Desc be used for.
I’ll write about the double-underscore syntax in a future post.
[+] macro-objects: value of “short-desciptor” can be used as alias for pipe-access (to be usable, the value of the short-descriptor must match the requirements for an EbsScript variable-name)
• ebsmacrobase._x[alias]:ebspipe : returns the pipe connected to the port specified by the alias
• ebsmacrobase.__x[alias]:ebscomp : returns the component connected to the other side of the pipe connected to the port specified by the alias
• ebsmacrobase.__px[alias]:ebspipe : returns the pipe connected to the other side of the pipe connected to the port specified by the alias
• ebsmacrobase.__dx[alias]:ebsdata : returns the data-object (component or pipe) connected to the other side of the pipe connected to the port specified by the alias
where [alias] has to be replaced by the specified short-descriptor,
e.g. hrsg_macro._xLiveSteam (i.e. the short-descriptor of some port has the value LiveSteam)