Declaring methods

C#
public class MC_ExtraVestigingB2CDataManager {
    public int ImportData(lUnattended AS LOGIC) {
        var returnValue = 123+456;
        return returnValue;
    }
}

VO
CLASS MC_ExtraVestigingB2CDataManager
    // In VO you have to declare strongly typed methods in the class definition area
    DECLARE METHOD ImportData

METHOD ImportData(lUnattended AS LOGIC) AS DWORD STRICT CLASS MC_ExtraVestigingB2CDataManager
LOCAL returnValue AS DWORD
    returnValue := 123+456
RETURN returnValue

// Weakly typed methods don't have to be declared but will have neither strongly
//   typed parameters nor strongly typed return values!!!
METHOD ExportData() CLASS MC_ExtraVestigingB2CDataManager
    SELF:AddInfo(0,"Executing dummy export method."))
RETURN NIL

Please note that DEFAULT parameter values don't work (well) with stronly typed methods. However the benefits of using strongly typed methods is that you will be forced to pass all stronlgy typed parameters.


Declaring properties

C#
public class WinExportExtraVestiging: MC_DataDialog
{
    //Note that a backing store is not neccessary in latest version of C#
    //Following is only for demo purposes as an equivalent of VO
    private bool _isUnattended;

    public bool IsUnattended
    {
        get { return _isUnattended; }
        set { _isUnattended = value; }
    }
    ...
}


VO
CLASS WinExportExtraVestiging INHERIT MC_DataDialog
// In VO just like strongly typed methods, 
//   you have to declare strongly typed in the class definition area
HIDDEN _lUnattended AS LOGIC
DECLARE ACCESS IsUnattended
DECLARE ASSIGN IsUnattended
HIDDEN _IsValid AS LOGIC

ACCESS IsUnattended AS LOGIC STRICT CLASS WinExportExtraVestiging
RETURN _lUnattended

ASSIGN IsUnattended(lUnattended AS LOGIC) CLASS WinExportExtraVestiging
SELF:_lUnattended:= lUnattended

// Weakly typed property getter/setter methods don't have to be declared, 
//    but then you will also lack the benefits of strong typing!
ACCESS IsValid CLASS WinExportExtraVestiging
RETURN _IsValid
ASSIGN IsValid(newValue) CLASS WinExportExtraVestiging
SELF:__IsValid := newValue



Arrays

Note that unlike C#, arrays in VO are not zero index, so dummyArray[0] in C# is dummyArray[1] in VO.

Creating arrays

Object arrays

C# 

VO

var carList = new Car[] {
    new Car(){ Name ="Volvo", LicensePlate = "VO1V0" },
    new Car(){ Name ="Renault", LicensePlate = "RENAU1T" },
    new Car(){ Name ="Toyota", LicensePlate = "TOY0TA" }
    new Car(){ Name ="Mercedes", LicensePlate = "MERC3D3S" }
};



LOCAL carList AS ARRAY

// Arrays in VO are not strongly typed, we can use classes like below:
// However we would end up using for loops to find something we want,
// Since VO has limited features like lambda.

carList := { }
AAdd(carList, Car {"Volvo"})
AAdd(carList, Car {"Renault"})
AAdd(carList, Car {"Toyota"})
AAdd(carList, Car {"Mercedes"})






String array

C#
VO
var carArray = new string[][] {
    new string[]{ "Volvo", "VO1V0" },
    new string[]{ "Renault", "RENAU1T" },
    new string[]{ "Toyota", "TOY0TA" },
    new string[]{ "Mercedes", "MERC3D3S" }
};

LOCAL carArray AS ARRAY
carArray := { {"Volvo"}, {"Renault"}, {"Toyota"}, {"Mercedes"} }

Searching arrays

C#
VO

// No local variable definitions required at begin of methods
var toyotaCar = carList.Where(c=>c.Name == "Toyota");
Console.WriteLine(volvoCar.LicensePlate);


/// var toyotaLicensePlate = ???
/// Console.WriteLine($"{toyotaLicensePlate}");




// VO expects all local variables to be declared 
// at the start of each method
LOCAL nToyotaIndex AS DWORD
// Not supported in Visual Objects!
// ? volvoCar.Name

nToyotaIndex := AScan(carList, {|C| C[1] = "Toyota" })
? carArray[nToyotaIndex]






String formatting

C#
VO
var name = "Bill Gates";
String.Format("Example:{0}My name is: {1}", "\n", name)



LOCAL name AS STRING
FormatString("Example:{0}My name is: {1}", {CRLF, name})