Question
· Jan 12, 2023

Difference between Parameter and Property

Hi Community,

I am new to ensemble and cache object scripts ,i am trying to create a business service using Ens.BusinessService

but i have doubt what is the difference or uses between Parameters and property in defining classes in defining business service

Joe

Product version: Ensemble 2018.1
$ZV: Cache for Windows (x86-64) 2018.1.1 (Build 312_1_18937U) Fri Apr 26 2019 17:58:36 EDT
Discussion (5)2
Log in or sign up to continue

Parameter values are static values* and  the same for all objects.

Property values are different for each object.

Small example:

Class Circle Extends %RegisteredObject {
    
Parameter PI = 3.14;

Property Radius;

Method GetArea()
{
    quit ..#PI * ..Radius * ..Radius
}

ClassMethod Test()
{
    set circle = ..%New()
    set circle.Radius = 25
    write circle.GetArea()
}
}

* parameters can be calculated but not set by user.

I won't repeat the excellent definitions already provided, but can share some examples of class parameters where we use them:

Parameter FILES = "/files";
Parameter INSTANCE As COSEXPRESSION = "$p($SYSTEM, "":"", 2)";
Parameter RUNLEVEL As COSEXPRESSION = "$li($lb(""dev"",""Test"",""LIVE""), $lf($lb(""HCDEV"",""HCTEST"",""HCLIVE""), ..#INSTANCE))";

We use ..#FILES to prefix or normalize a directory off the top-level filesystem on the server.

We use ..#INSTANCE if we need to identify which IRIS instance, like in an email message, it came from.

We use ..#RUNLEVEL in conditionals or pass as a parameter, where we might want code only to run on "Test" or "LIVE".

Hi ,

Thank you for sharing very important things about parameter and property

I have one doubt while creating the custom business service i am using EnsLib.File.InboundAdapter like below 

Parameter ADAPTER = "EnsLib.File.InboundAdapter";

1.I just want to know it means the methods exits in  EnsLib.File.InboundAdapter class can i use them in my custom class by 

2.By adding .. 2 dots  like below we can access the methods exists in the class ?

Joe

Hi Joe,

The 2 dots syntax is used to access the properties and methods of the current object.
You can also use $this to access the current object.

For example, if you have a class called "MyClass" and you have a property called "MyProperty" in that class, you can access the property value by using the following syntax:

User.MyClass Extends EnsLib.BusinessService
{
    Property MyProperty;

    Method MyMethod()
    {
        set ..MyProperty = 10;
        set $this.MyProperty = 10;
    }
}

In your case, you can use the following syntax to access the methods of the EnsLib.File.InboundAdapter class:

User.MyClass Extends EnsLib.BusinessService
{
    Parameter ADAPTER = "EnsLib.File.InboundAdapter";
    Property Adapter = "EnsLib.File.InboundAdapter";

    Method MyMethod()
    {
        do ..Adapter.AdapterMethod()
        do $this.Adapter.AdapterMethod()
    }
}

Hope this helps.