Simplicty and flexibility!


retval := SetVar("VarName",Result) .
SetVar("MyVar","Value","Global") -- 8.6 onward. Will set a Variable on the global DataEase bus.

Set any named global variable anywhere to be used anywhere in an app within the same session.

There has been several CDF libraries that has tried to tackle this need over the more than 30 years DataEase have been around, but for some strange reason DataEase itself has never seen the need for implementing this very useful and necessary feature - before now.

The CDF libraries that has offered this service have all had the weakness that they have numbered the variables and also have a limited supply of them. For instance SetArray() has only 10 and SetGlobal() only 100.

SetVar is "unlimited" and you can name them. 

One avid and long-standing user has pointed out that it was quite useful to use numbers for the variables as you could then loop through and name them automatically, but you can of course still use number or a combination of text and numbers as DataEase automatically convert between formats. See Examples below.


Variable Name: String

This is the name you want to give the variable it can be concatenated like this concat("MyVar",Counter) or you can use a date, number etc.

Value: String

The value you want to put into the global variable. It can be anything and it will be automatically converted to string, and converted back when read by GetVar()

[Option: String]

Option is GLOBAL which will allow you to set a variable on the shared DataEase bus. This means you can share global variables between the DataEase applications on the same computer/user.


Nothing. This is the standard for most new functions so they can be added in chains without impacting the result.


Example 1

SetVar("MyStyle",GetStyle("MyButton") -- This will read the stylename of button my button and put it in the Global variable MyStyle.

You can now reset the button to original style by using: 

Example 2

Define "counter" number .
Define "Retval" text .

For MyForm ;
Retval := SetVar(concat("MyVar",Counter),CustomerName) .

List records

CustomerName .

This example will generate a numbered variable for each customerName, but it would maybe be better to use for instance CustomerNr as the name for the variable.

Define "counter" number .

Define "Retval" text .

For MyForm ;
Retval := SetVar(CustomerNr,CustomerName) .

List records

CustomerName in order ;
CustomerNr .

You will now be able to retrieve the value of the Global variable by referncing with the CustomerNr.


As part of the DataEase for Windows restoration project we have come to a big omission in DataEase - Global Variables or transfer of information between processes if you like.

It amazes us how many wishes, needs and wants from almost every user, that has been blatantly ignored by "us". We have had no qualms in brushing off desperate user with a CDF or a receipt long as your arm to "fix" a problem in our product.

In DataEase 8 we have deemed to remedy a lot of these omissions. It might be too late for a lot of users, but that excuse is getting to old too. When we took over development we were told that yes LegEasy DOS is how it should have been done back in 1994 but alas, now it was too late. We can't hide behind "too late". It is only too late if we think that DataEase will ever be used by people that have already used it, but our goal is to get it to be used by people that have never used it too.

Just because there is some CDF's that can transfer a limited number of variables, and there is an SQL return code that one can use for the same, doesn't mean that the problem is solved. Especially not when we are going to tell you all to not use DQL body for printing.

What? Not using DQL body for printing, not using DQL for printing? No! It doesn't work, and it never have. It is the achilles heel of DataEase for Windows and a couple of hours working with it is enough to kill the spirit of the bravest.

DQL without Printing is both effective and amazing, but the way the body has been implemented is just backwards.

I can guarantee you that nobody that make a living from using DataEase use the DQL body for anything. So if you are a new user, don't even try.

The fact that the Data-Entry form is as limited doesn't make the situation any better.

Use DQL for processing, and use Report for printing! End of story!

The only reason we use DQL for printing is that that is what we used to do in DFD, and the reason we used to do that in DFD is because we need to have a data-entry form.

In DataEase 8, we have introduced Virtual Editable Field so you can make a DataEntry form as a normal for with relationships etc. Then you use the new SetGlobal("Variablename",Value) to set the global variables either in a virtual field or directly on the button that Fire the Report. In the report you set the Filter and use GetGloal("Variablename") and the job is done.

With Set/GetVar() you can have as many global variables as you like and you can give them descriptive names.

You can of course use them for anything you like, the above is just an example.


See Also

On the forum about SetVar

Retval := SetVar ... results in dataease fatal exception

During month end I have to run numerous reports.  At present I do it a rather long winded way as they are all DQL reports.  so I have a DQL that does this but it's repetitive as I have to enter a date range for each DQL report.  So I'm...

Product: Dataease [{8}]FIVE. Written by Simon B 14/04/15 at 14:09:27

Re:Retval := SetVar ... results in dataease fatal exception

Note:Fad ADMIN table whas 1 record. Iv'e also tried putting run procedure "pce_REPORT_CRITERIA" .outside the for loop, no difference.The reason I have </...

Product: Dataease [{8}]FIVE. Written by Simon B 14/04/15 at 15:09:02

Re:Re:Retval := SetVar ... results in dataease fatal exception

We use Setvar()/GetVar() extensively and have never had any problems with them.This is the kind of Yeti problem that we can't really address without a sample app the showcase the problem....

Product: Dataease [{8}]FIVE. Written by DataEase 16/04/15 at 15:05:35


What is the limit on the string you can pass onto this variable?...

Product: Dataease [{8}]FIVE. Written by Jeyarajah Arulrajah 11/11/17 at 19:24:47

SetVar()/GetVar() and Strings in <=8.5 vs >=8.6

Funny you ask the question just now.The limit is and has been for any string in DataEase 255 from 1.0 through to 8.5We have a function that is MemoSetGlobal() and MemoGetGlobal() but the limitation on that is that you need a memo to be...

Product: Dataease [{8}]FIVE. Written by DataEase 12/11/17 at 13:26:21

On the blog about SetVar

New Functions in 8 - SetVar()+GetVar() - Time to take control!

As part of the DataEase for Windows restoration project we have come to a big omission in DataEase - Global Variables or transfer of information between processes if you like.It amazes us how many wishes, needs and wants from almost every user,...

Product: Dataease [{8}]FIVE. Written by DataEase 02/11/12 at 20:25:35

New Function(s) in 8 - SetVar()/GetVarl() - Internal function from (Ver

SetVar() and GetGlobal() is fully implemented in DataEase 8 from version build 1172.Format: SetVar("Variablename","Value") where both parameters are string. Returns Empty String.Format: GetVar("Variablename") where parameter is string. R...

Product: Dataease [{8}]FIVE. Written by DataEase 29/11/12 at 15:51:17

New Function(s) in 8 - SetVar() and GetVar(), set and read named global variables (Ver

These two functions have been partly implemented for a while, but due to structural changes in PRISM we had to disable them in release. These changes have now been made and they are free to use.It is more than 30 years since DataEase 1.0 was re...

Product: Dataease [{8}]FIVE. Written by DataEase 04/12/12 at 10:06:48

DO NOT USE! SetGlobal()+GetGlobal(). (Will be renamed to SetVar()+GetVar())

We admit that we mad a bad judgement call when we named our new Global Variable functions SetGlobal() and GetGlobal()There is a CDF with the same functions that has been widely used for years, and migration old apps will then have problems...

Product: Dataease [{8}]FIVE. Written by DataEase 02/08/13 at 11:35:53

Re:DO NOT USE! SetGlobal() GetGlobal(). (Will be renamed to SetVar() GetVar())

Can't you remove this in DE8 Native ?...

Product: Dataease [{8}]FIVE. Written by Jeyarajah Arulrajah 14/08/13 at 21:03:12

Enable/Disable based on Global variable using SetStyle(),SetState(),SetVar(),GetVar(),MoveObject()

Download Sample! We got a request from a user on how to control the users...

Product: . Written by DataEase 25/09/15 at 08:54:32