Simplicty and flexibility!


setcolor() attempt 2


Started by Simon B
Search
You will need to Sign In to be able to add or comment on the forum!

setcolor() attempt 2

So here I am again (had to wait a month to download another trial) to try figure out how to make setcolor() work.  Forget setstyle(), I have the same problem so i'm sticking with this for now.

I have a text field called hist_idn3 (text, 5chrs, virtual, prevent entry)

This looks up a value from another table

and

I have a 'support' field called rgb3 (text, 11chrs, virtual, prevent entry)

The derivation on rgb3 is
concat (lookup "entry2ordrecnos" "rgb3",if (hist_idn3 = "dec",SetColor("hist_idn3","-1","#00ff00","-1"),SetColor("hist_idn3","-1","#00ff00","-1")))


The above derivation should look up a value from a related table (it does), and also changes the colour of field hist_idn3 (it does) 

BUT, the IF rule states that if field hist_idn3 contains the text value dec the background colour is green, otherwise it is white.

But it's always green.

Tried

concat (lookup "entry2ordrecnos" "rgb3",if (hist_idn3 = "dec",SetColor("hist_idn3","-1","#00ff00","-1"),""))

But once that field meets the value dec and turns green, it stays green in all other records, regardless of the contents of hist_idn3.

The value is not rechecked, which is SHOULD as that's the whole point of creating the virtual 'support' field called rgb3.

"Any virtual or write protected field that is dependent on another field is execute when the first field in changed so if you don't want the function ONLY to be called when the derivation in the saved field is ACTUALLY triggered you need to create a "support" field (Virtual).

In the supportfield you do the manipulation like this(Object name of Supportfield is Manip): If (Field1 something, SetStyle("Style1"),SetStyle("Style2")))+SetState("Manip",0) -- Last SetState hide the support field."

So my simple question is, what is wrong wih my derviation?  What am i missing again? I've truied for months to make this work. With text fields, choice fields, in derivations, with support fields, using +, using concat, using getvalue(), using styles.  The only time it works is on a button, never on a field.  Please can someone just write whAT my script should be to work.  Not being funny but I donlt want the reasoning/science behind it, as for all the reasons I have changed my code to meet already but every reason and every change still gives me the same result.  And I still don't know what prism and columns has to do with any of this as prism is the exe running in the background so means nothing to me, and a column is just that, it is not a field or a field name (why does every field have 2 names?,one is prism and one is a gui ... no I don't understand that explanation either).

If I could just see what the code SHOULD be, then maybe i have a chance of learning this. (the demo of setcolour is for buttons, and the same does not work when changed to fields).

Anyone up for the challenge where all others have failed? lol



Written by Simon B 13/11/14 at 16:18:39 Dataease [{8}]FIVE

Re:setcolor() attempt 2

The first and most obvious problem is that you tell the field to be always green ;-)

concat (lookup "entry2ordrecnos" "rgb3",if (hist_idn3 =

 "dec",SetColor("hist_idn3","-1","#00ff00","-1"),SetColor("hist_idn3","-1","#00ff00","-1")))


What you do her is to switch the field green if hist_idn3 is "dec" and when it isn't "dec"... You derivation should be.

concat (lookup "entry2ordrecnos" "rgb3",if (hist_idn3 =

"dec",SetColor("hist_idn3","-1","#00ff00","-1"),SetColor("hist_idn3","-1","#ffffff","-1")))


Another thing you need to remember is that the presentation of fields are not related to the content of the field if you don't make it so through programming. If you change the colour/style/font etc of a field it will stay that way till you change it yourself or till you restart the app or close/open the form.

Which lead me to your next problem:

concat (lookup "entry2ordrecnos" "rgb3",if (hist_idn3 = "dec",SetColor("hist_idn3","-1","#00ff00","-1"),""))

Here you set the field to green but you never set it back to anything so it will rightly stay green "forever".


Written by DataEase 13/11/14 at 17:20:54 Dataease [{8}]FIVE

Re:Re:setcolor() attempt 2

I copy pasted in the 2nd colour as i'd already changed my database test to the 2nd example, but I HAD put in a different colour orginally lol.  However!  I know I put in 000000 as i thought i knew that was either white or black, either way anything but green.  I noticed you used ffffff so i used that and it worked!   Just checked and 000000 is black, not sure why filling in black wont work.  Tried various hex codes and for whatever reason black (#000000) is the only hex colour dataease wont fill in lol.  Using #000011 is an off black but that works so that's a workaround.

The 2nd example of the else value being blank i believed would revert to the default colour of that field, but now i understand it is a permanent change so there must always be an else value to put it back. 

One happy Deaser :D  Thank you for the plain english help, very much appreciated!  Glad to see I had it right mostly, just an odd anomoly with 000000 which you may want to investigate.  Must admit I laughed when I saw the same colour in the if then else.  That'll teach me to copy paste :D

THANK YOU :)


Written by Simon B 14/11/14 at 10:07:25 Dataease [{8}]FIVE

Re:Re:Re:setcolor() attempt 2

Incidently, the lexicon indicates i can use text value for the RGB code.  How do I enter that? i.e. red is 

R255, G150, B150

Tried "255150150" , "255.150.150" , 255,150,150" , can't find how to enter it :) thank you


Written by Simon B 14/11/14 at 10:34:06 Dataease [{8}]FIVE

Re:Re:Re:setcolor() attempt 2

Equations with more than one unknown....

You are right. "#000000" doesn't work. but "#000001" does.. 0 is a difficult thing in programming but still....

Talking of being unlucky... sorry.


Written by DataEase 14/11/14 at 11:13:12 Dataease [{8}]FIVE

Re:Re:Re:Re:setcolor() attempt 2

Vi invariably use String as Arguments in functions now. DataEase converts seamlessly between formats and string give many more options later for formatting etc.

the number of colours is 24bit i.e. 256x256x256 so you have 255 shades of red,green,blue in any combination.

So red is most significant and blue least significant so when black is 0, dark blue is 1 and light blue is 255, so far it is simple. but dark green is 256 and dark green is 65280 with a lot of shades of bluegreen in the mix between...

So using decimal numbers is very difficult, but using hex is very simple as it is position oriented and that is why hex is used for colours.

All colour pickers return the amount of RGB in decimal (individual) and the hex value as one #ff0000 (red) #00ff00 (green) and #0000ff (blue).

In SetColor() you can send the colour as -1 (no change), decimal (255 for blue or 16711680 for red but as you see the conversion is very awkward, or as hex #fffffff or #0c0c0c etc...).

Needless to say this was one of the first Set functions we made and as programmers we have a tendency to think like....programmers.

We started with decimal input and got the function to work, then we realised that it was annoying that we had to set the colour for all properties and introduced -1 as retain then we started to play with it and found decimal to be "impossible" and converted it to text and used Hex which is the obvious way of doing it.

And that is where we stopped....

In hindsight and with your input we realised that we shouldn't have stopped there but also added RGB decimal like string.

SetColor("MyButton","-1","R128","-1") or SetColor("MyButton","-1","R245G56B129","-1")

So we have now scheduled this fix.

The nice thing with this fix is that it will be backwards compatible so everything you have already got to work will work the same.


Written by DataEase 14/11/14 at 11:16:54 Dataease [{8}]FIVE

Re:Re:Re:Re:Re:setcolor() attempt 2

I guess an apology is due here for the trouble we have caused you and a big thanks for being so persistent and pointing us in the right direction.

Making a great tool need to be a great collaboration between publisher and customer, where we need to listen and you take the time to tell us where we go wrong.


Written by DataEase 14/11/14 at 11:47:09 Dataease [{8}]FIVE

Re:Re:Re:Re:Re:Re:setcolor() attempt 2

Thank you :)  And than you for putting up with me :D

I used RGB purely because that's what datease shows.  i.e. i find a fill colour that is pastel enough to be read with text over it, I then click define custom colours to find out the value so I can use it in situations like this.  Here it is shown as RGB not hex, and is the only reason i used RGB :)   Maybe worth showing hex as well, on your field/font/border colour picker/editor?  Just so you know how i came to use RGB :)


Written by Simon B 14/11/14 at 14:08:58 Dataease [{8}]FIVE

Re:Re:Re:Re:Re:Re:Re:setcolor() attempt 2

You got it right. Sometimes we just go to far in one direction without looking up and adjusting our bearings...

DataEase only use decimal and it is natural that the numbers you find there should be automatically usable in the functions.

I guess you can tell that these functions have a life of their own. It would be nice to say that we have a 5 year development plan with all the functions, features in neatly folded blueprint costed and specified, but it would be a lie.

We have an overall idea of what the product should do and be, but we develop it the same way our users develop in DataEase...by increment and evolution. Feed in, feedback, one step forward and two back...

Knowing this we develop in such a way that we can always add feature later without it having any impact on existing code etc.

So now we can add your decimal colours without it impacting on my hex ones ;-)

With MoveObject we opened another floodgate, and you quickly discover that you need much more than you initially anticipated.

We can now get the sizes of all objects and we can move then anywhere on the screen, but one then also discover that it would be nice to know where they where so we are also adding GetCurrent("Xpos","Object") and GetCurrent("YPos","object")..

And maybe it would be nice to get GetCurrent("FontColor"), GetCurrent("FillColor") and GetCurrent("BorderColor").... this would need to be hex ;-) though. 


Written by DataEase 14/11/14 at 14:37:44 Dataease [{8}]FIVE

Re:Re:Re:Re:Re:Re:Re:setcolor() attempt 2

Simon, Christmas come early this year ....

SetColor() is now updated to fit with your format.

SetColor("MyObject","R128G175B33","G128","#ff0000") ..

You only need to insert he elements you want R120 R255B44 etc.

You can also combine them with Hex but not within the same colour... i.e. R225#ff" won't work ...he,he.


Written by DataEase 19/11/14 at 17:11:47 Dataease [{8}]FIVE

Re:Re:Re:Re:Re:Re:Re:Re:setcolor() attempt 2

By the way, we have also corrected the blunder of #000000 not being black, but it won't be published until next release due to "late arrival".

You can however simply use 0 for any of you new elements.

SetColor("MyObject,"R0","R0","R0") will render the object black as night.

All this said and all this fix. By using SetStyle() you make life much easier for yourself both now (development) and later (change).


Written by DataEase 19/11/14 at 17:14:38 Dataease [{8}]FIVE

Re:Re:Re:Re:Re:Re:Re:Re:Re:setcolor() attempt 2

Thank you :)  May be work showing hex values in the colour picker, as that's the reason I use RGB as that and hue/sat/lum are the only values shown :)


Written by Simon B 24/11/14 at 09:40:43 Dataease [{8}]FIVE

Re:Re:Re:Re:Re:Re:Re:Re:Re:Re:setcolor() attempt 2

That would be helpful to, but to be honest it is a drag to add functionality to these old Dialogues. In future versions of DataEase, the dialogues will be made in DataEase and than you could even do it yourself ;-)

It is on the list however, so might happen before we know but it is not a priority.


Written by DataEase 24/11/14 at 10:20:32 Dataease [{8}]FIVE
DG3_ForumList