CodeMorphis
Joined: 02 Dec 2003 Posts: 252
|
Posted: Sat Jan 17, 2004 11:33 am Post subject: Programming Tip #3: Modifying Component Port Interfaces |
|
|
Programming Tip #3: Modifying Component Port Interfaces
Each Synopsis component has a port interface that allows you to access its service(s) and/or data values. In the Synopsis Help documentation there are discussions about the two types of port interfaces:
- Data ports (blue)
- Process ports (red)
In this article we will take a look at how some components allow you to modify their port interfaces depending on your programming needs.
Let's consider the Add component, available from the "Math" tab in the component tray.
Of particular interest are the input data ports, which are blue and are located at the top of the component. Now as we know, the Add component receives data input from the two data ports and "adds" them together, passing the resulting value to the sole output data port (the blue port at the bottom of the component). The input values of course, can be of any value type, that is, they can be integers, floating point values or even character strings.
Often, one needs to add more than two values together, or in the case of strings, concatenate more than two strings. Rather than use a series of Add components to do the job, we can simply modify the input port interface of the Add component to allow it to accept more than 2 input arguments.
Double click the Add component to bring up the component's property dialog.
Note the value of the "Number of add arguments" property, which is by default 2. Let's change this value to 4, for example. When we click on the OK button in the property dialog, the port interface of the component changes. Specifically, it now has 4 input data ports as opposed to 2:
We can now specify 4 input arguments for the add service. The Add component allows for between 2 and 16 arguments.
Some other components that allow you to modify the port interface include:
- The Console Print component (I/O tab of the component tray)
- The Switch component (Logic tab)
- The Set Variable component (Data tab)
- The Variable component (Data tab)
|
|