Download SetStyle() Sample
It would be a lie if we said that developing a product like DataEase 8 or even DataEase in general was done by designing the product and then implementing that design. We develop DataEase the same way you use it, by incremental and evolutionary methods.
We have of course a long list of ideas, needs, technical requirements, bugs, shortcomings etc, that result in a general directions of the product development, but we constantly have to feed the process with feedback from you our own discoveries and experience with the changes we make.
OML was implemented in DFW many years ago, but due to a combination of bad documentation, risky and unstable behaviour, a bad editor and a completely new approach it never became very popular. You can say that it wasn't very DataEasy.
This is why we in DE8 decided that we would allow users to do everything they could already do in OML directly in the know formats of Derivations (BRL) and DQL (ExecDQL) via making functions.
The first function we did this way was SetColor(). You could already set the colour on an object programatically in OML but it was awkward and with OML then bad reputation and tendency to not only GPF in runtime but also corrupt your form in Design Time it was a high risk and work intensive activity.
You would also have to set it in minute detail in decimal....not very user friendly as the example below will show:
-- Set Color of fill
Button11.Fill.Color.Red := 128 .
Button11.Fill.Color.Green := 145 .
Button11.Fill.Color.Blue := 45 .
-- Set Color of Font
Button11.Font.Color.Red := 128 .
Button11.Font.Color.Green := 145 .
Button11.Font.Color.Blue := 45 .
-- Set Color of Border
Button11.Border.Color.Red := 128 .
Button11.Border.Color.Green := 145 .
Button11.Border.Color.Blue := 45 .
-- Set Color of fill
This little sample set the colour of the Font, Fill and Border of a button but as you will find out if you try to use it, it will not set the shade, shine which would be 3 new lines for each property.
I think maybe this illustrates why OML never became a hit with the general public, so we wanted to allow our developers to do this much quicker and easier and hence the development of SetColor().
SetColor() basically have 4 parameters which is ObjectName( Same name and rule as for OML) and the a String value for each of the 3 properties - Font, Fill, Border. We use string so one can input it either as decimal (same way as for OML) or in hex "#FF0F0A" format.
As each colour contain a 3 8 bit RGB elements the number in decimal is unmanageable and this is where Hex is so brilliant, as each byte is represented by to letter 00 to FF.
Since each function will set all three properties in one go, you would need to be able to tell it not to set (keep) the current property and you simply do that by setting -1, so SetColor("MyField","#ff0000","-1","-1") would set the font of MyField red and retain the remainder of the properties.
It is easy to see that this is a major leap forward in Ease of use, but as you start working with it extensively you realise that where the OML approach basically is a showstopper, the SetColor() funciton is great when you want to do it in a small way, but if you are manipulating your app in a big way it is to much work and it is also to inflexible.
Firstly. DE8 objects have many more properties than Font, Fill and Border. They have properties as Font, Shade, Box, Border Width etc etc. Should we make functions that include all of them, or should we make specific functions for each property? i.e. SetFont(), SetBorderWidth()
There is already one feature in DataEase that in itself is underused which solve all of these features;
If you can programatically change the style of any object, you can do any or all properties in one go, hence the birth of SetStyle().
SetStyle is the simplest of functions with only two parameters both string. Objectname to manipulate and Style to Apply.
SetStyle("MyObject","MyStyle") and you have changed the style.
The style you make and save in Design mode, and you can make as many and as divers styles as you please.
Combine SetStyle() with GetStyle() and SetVar()/GetVar() and you can read the current style, store it in a global variable, apply the new style and revert to the old style when you are finished.
The only thing it would take would be a derivation (action) like this:
And the reverse derivation would be: