Easy to Create, Easy to Change - Easy to use!


setvalue


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

setvalue

Can I, or How can I use setvalue in a Subform field.

Written by Rainer 14/10/14 at 10:27:48 Dataease [{8}]FIVE

Re:setvalue

please answere

Written by Rainer 20/10/14 at 14:50:57 Dataease [{8}]FIVE

Re:setvalue

This is where the new policy of using our own products actively start to pay off....

With the introduction of SetClass we opened Pandoras box. If one can do this on this kind of object one suddenly want to be able to do it on all kinds of objects etc.

We too very quickly realized that manipulating objects in a subforms would be a major "feature" but it wasn't as straightforward as one would have hoped.

A subform is a Runtime "construction" so a subform with 20 rows with the field CustomerName in it will have 20 fields with the exact same name.

So what we did was simply to add a numbering feature to all SetFunctions.

SetState("CustomerName",0) will hide the first object named CustomerName (ObjectName not fieldname!)

SetState("CustomerName#1",0) will do exactly the same, when SetState("CustomerName#2",0) will hid the CustomerName object in Row two of the subform.

However, remember that this is CustomerName object in numbered order in the entire FORM so if you have a CustomerName object in the Main Form too this will be part of the same number sequence.

So to make things simple for yourself, simply rename the Object in the Subform to ex. subCustomerName so you are sure of your numbering and suddenly one also realize why fields have two names... column name and object name. The object name can always be changed, while the column name can only be changed in the table.

See for reference:
Update Functionality DataEase 8 - SetValue(), SetState(), SetColor(), SetFocus() ObjectNumber Added (Ver 8.0.0.1306)

You will soon want to manipulate objects in a row depending on values and status of that row so have a look at GetCurrent("RowNumber") too.

DataEase 8.2 - GetCurrent() updated! "RowNumber", "RecordNumber", "Version" (Ver. 8.2.0.1607)

Written by DataEase 20/10/14 at 17:39:32 Dataease [{8}]FIVE

Re:Re:setvalue

Thank's. And what do I do if I want all the "MY Field" changed in the same way . Meens I have 1/n subrecords, and I want them all to get the value "KO" for examlpe?

Written by Rainer 20/10/14 at 19:05:53 Dataease [{8}]FIVE

Re:Re:Re:setvalue

please answere

Written by Rainer 29/10/14 at 18:49:34 Dataease [{8}]FIVE

Re:Re:Re:Re:setvalue

You have to run a loop that sets all the MYFields from 1 to n. Or you can do SetValue("MYField#1","KO")+SetValue("MYField#2","KO")+etc...

To run a loop you need t use ExecDQL.

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

Re:Re:Re:Re:Re:setvalue

can you please give an example for the loop.

i can not do it this way ?

retval := ExecDQL("for AUFTRAG_POSITION with Belegnr=data-entry Field1; setvalue("Belegart",global BART)+setvalue("Druck_KZ",global BART)",global Belegnr,"","","","")+Wait(0,1).

Written by Rainer 30/10/14 at 09:07:02 Dataease [{8}]FIVE

Re:Re:Re:Re:Re:Re:setvalue

Download Sample

Firstly we need to get some basic rules in place. 

"" is the delimiter of a string (text) in DataEase so you can't use " in the middle of a text in a derivation, OML or DQL.

So concat("My name is "Ulrik" what is yours", name) will not work.

In 8.0 we introduced chr() to fix problems like this so you could do concat("My name is" ,chr(34),"Ulrik,chr(34),"what is yours",name)

This was a great improvement but when you start writing big texts into a derivation etc, it is awkward so we created StringEscape() which is a function that escapes codes into characters .

So StringEscape("My Name is /'Ulrik/' what is yours") will return the string: My Name is "Ulrik".

Then we took it one step further and integrated this feature in functions like ExecDQL, Concat etc. so you can simply write the code in directlhy into the ExecDQL.

ExecDQL("define /'counter/' number. define /'retval/' text . while counter<15 do retval := SetValue(concat(/'SomeText#/',counter+1),data-entry field1) . counter := counter +1 . end ",MyText)


This is the ExecDQL from the sample attached which basically set the value found int MyText in each SomeText field in the subform (15).

As you see you can write quite substantial DQLs straight into the function this way, but it might be simpler from a debugging viewpoint to use LabeExecDQL or MemoExecDQL where you can write the syntax without the Escaping.

The sample is created in the lastest internal release of DE8.2 and there seems to be a bug with StringEscape in the latest release version of DE8.2 (1631) so we include a download link to the latest Internal relase (1672).

There is a lot of fixes and new features in 1672 but as it is not currently a full release version there is no published fix list etc as of today. 

Feel free to use this version in production as all the fixes and improvement is tested and will not infer negatively on your applications.

http://www.dataease.com/static/files/DataEaseFull-...

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