Welcome! Log In Create A New Profile

Advanced

[wd17]Define Type

Posted by Bart VDE 
Bart VDE
[wd17]Define Type
October 24, 2012 02:32PM
Hi,

Is it possible in Windev to define your own types (for a variable) ?

For example, in Delphi you can do something like this :

//define the type
Type
PossibleColors=(Red,White,Black)

//define a variable of that type
Var
Mycolor : PossibleColors

//use of the variable
If Mycolor = Red then showmessage('Color = Red')


is something like this possible in WD ?

Thx !
Peter Holemans
Re: [wd17]Define Type
October 24, 2012 02:55PM
Hi Bart,

Sure and there's different ways to implement this:
- As a class
- An associative array
- As a structure
- As a composite variable
Check out the online help:

http://doc.pcsoft.fr/en-US/?1514013&name=the_different_types_variables&q=Variable,Advanced%20types
Cheers,

Peter H.



Edited 2 time(s). Last edit at 10/24/2012 03:07PM by Peter H..
Pragma Tix
Re: [wd17]Define Type
October 24, 2012 03:32PM
Hi Bart,
No!
Enumerations are not available in WX17. They will be available in WD18.

#pragma
Bart VDE
Re: [wd17]Define Type
October 24, 2012 03:54PM
ah thanks, great, it's the "nouveauté" 66 of WD18.
I'm a bit surprised that something common like this wasn't supported.

For the moment I will work with good old constant values.

Thx for the help !

Bart
Peter Holemans
Re: [wd17]Define Type
October 24, 2012 04:00PM
Hi Pragma,

You're right... I didn't look at the sample more closely. Enumerations like in C# are indeed not available in pre-V18. But... Although not the same you could mimic similar behaviour by using associative arrays.

Here's an example:

aaColors is Associative array of string
aaColors = [["Red","Red"],["Blue","Blue"],["Green","Green"]]
MyColor is string = "Green"
IF NOT aaColors[MyColor] ~= "" THEN
    Info(Buildstring("The color chosen is %1", aacolors[MyColor]))
END

Cheers,

Peter H.



Edited 1 time(s). Last edit at 10/24/2012 04:01PM by Peter H..
Author:

Your Email:


Subject:


Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically. If the code is hard to read, then just try to guess it right. If you enter the wrong code, a new image is created and you get another chance to enter it right.
Message: