INIT value

velo85

New Member
Hi,
How can i set init value for variable to be some other variable, and how to set init for date var to be today + 1.

DEF VAR a AS DATE INIT TODAY + 1.
DEF VAR b AS DATE INIT a.

OE 10.2.
 

Rob Fitzpatrick

ProgressTalk.com Sponsor
Hi,
How can i set init value for variable to be some other variable, and how to set init for date var to be today + 1.

DEF VAR a AS DATE INIT TODAY + 1.
DEF VAR b AS DATE INIT a.

OE 10.2.
Answer: don't try to use INITIAL for this.

Think of INITIAL as being a syntactical shortcut that lets you avoid writing a following ASSIGN statement. However an important difference between INITAL and ASSIGN is that you can ASSIGN a variable the value of another variable (among other things), whereas the INITIAL option can only take a constant value. For example, you can initialize a date to TODAY (which is a constant) but not to TODAY + 1 (which is an expression).

Also, if you don't have a good reason to define your variables (and temp-tables and input parameters) as UNDO, they should be defined as NO-UNDO. Otherwise you are unnecessarily slowing down your code, growing your LBI file, and potentially introducing side-effects that may be difficult to find. And do the next programmer who will have to maintain your code a favour: don't abbreviate keywords, even though the compiler lets you.

Try this:
Code:
define variable a as date no-undo.
define variable b as date no-undo.

assign
  a = today + 1
  b = a
.

display a b.
P.S.: "10.2" is not an OpenEdge version. 10.2A is a version; 10.2B is a different version. More info: Product Life Cycle Guide.
 
Top