VLF-One Interface

This Q&A forum allows users to post and respond to "How Do I Do ....." questions. Please do not use to report (suspected) errors - you must use your regional help desk for this. The information contained in this forum has not been validated by LANSA and, as such, LANSA cannot guarantee the accuracy of the information.
Post Reply
mwilliams
Posts: 36
Joined: Sat May 28, 2016 1:45 am

VLF-One Interface

Post 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.
MarkD
Posts: 692
Joined: Wed Dec 02, 2015 9:56 am

Re: VLF-One Interface

Post 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 48505 times
Also, there's a large set of shipped examples, with source code.
mwilliams
Posts: 36
Joined: Sat May 28, 2016 1:45 am

Re: VLF-One Interface

Post 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;
}
}
MarkD
Posts: 692
Joined: Wed Dec 02, 2015 9:56 am

Re: VLF-One Interface

Post 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.
Post Reply