Page 1 of 1

VLF-One Interface

Posted: Tue Jun 09, 2020 8:34 am
by mwilliams
I was wondering if someone could post some sample code on how to create/write an interface. I can't seem to find an example.

Re: VLF-One Interface

Posted: Wed Jun 10, 2020 10:44 am
by MarkD
There's quite a few different interfaces available.

Could you elaborate on the type of interface you want to create?

PS: If you are looking for documented help then use the "Help" menu option:
Capture.PNG
Capture.PNG (12.6 KiB) Viewed 48510 times
Also, there's a large set of shipped examples, with source code.

Re: VLF-One Interface

Posted: Wed Jun 10, 2020 2:16 pm
by mwilliams
Hey Mark, I'm talking about an interface that a class might implement. Something similar to iListCellDesign.

In Java it would be something like

public Interface IEmployee
{
public String getName();
}

public class Manager implements IEmployee
{
private String name;

public String getName() {
return name;
}
}

Re: VLF-One Interface

Posted: Fri Jun 12, 2020 11:43 am
by MarkD
This a general Visual LANSA question (definitely not specific to VLF-ONE applications).

Here a simple Visual LANSA reusable part that defines a class that publicly exposes properties named TheLastName and The Address.

It also exposes methods named MyMethod1 and MyMethod2, along with signallable events named MyEvent1 and MyEvent2.

Code: Select all

Begin_Com Role(*EXTENDS #PRIM_OBJT)

* Define a simple event named MyEvent1 that is signalled with no arguments or parameters
Define_Evt Name(MyEvent1)

* Define a event named MyEvent2 that is signalled with 2 parameters named Name and Address
Define_Evt Name(MyEvent2)
Define_Map For(*INPUT) Class(#STD_ALPHA) Name(#Name)
Define_Map For(*INPUT) Class(#STD_ALPHA) Name(#Address)

* Define a property named TheLastName that is stored in variable #LocalSurname
Define_Com Class(#xsurname) Name(#LocalSurname)

Define_Pty Name(TheLastName) Get(*AUTO #LocalSurname) Set(*AUTO #LocalSurname)

* Define a property named TheAddress that returns a constant value
Define_Pty Name(TheAddress) Get(Get_TheAdress)

Ptyroutine Name(Get_TheAdress)
Define_Map For(*OUTPUT) Class(#STD_ALPHA) Name(#ReturnValue)
#ReturnValue := "121 Smith Street"
Endroutine

* Define a method named MyMethod1 that has no aruments (parameters)
Mthroutine Name(MyMethod1) Access(*PUBLIC)
Signal Event(MyEvent1)
Endroutine
 
* Define a method named MyMethod1 that has 2 arguemnst called UaseName and UseAddress
Mthroutine Name(MyMethod2) Access(*PUBLIC)
Define_Map For(*INPUT) Class(#STD_ALPHA) Name(#UseName)
Define_Map For(*INPUT) Class(#STD_ALPHA) Name(#UseAddress)
Signal Event(MyEvent2) Name(#UseName) Address(#UseAddress)
Endroutine

End_Com
Once it is compiled you reference it in other code using the DEFINE_COM operation.

You can create static instances of it using the DEFINE_COM operation or by using DEFINE_COM .......... REFERENCE(*DYNAMIC) and SET_REF you can dynamically create multiple instances.

Hope this is enough to get you started on Visual LANSA objects / classes.