Home The Company Publications Products Links Tips

Tips, Tricks, and Techniques

Last update: 30 April 2004

Initialize internal tables

Question

Is the following Natural code valid? If not, why not? If so, under what conditions, and what, if any, are the results of execution?
....+....1....+....2....+....3....+....5....+....6....+....7.. 
ASSIGN #A = '456' - '123' 
ASSIGN #B = 'DEF' - 'ABC' 
Does #A contain '333'? What about #B? Solution
Assuming both #A and #B are of format/length A6,
#A contains '456123' and
#B contains 'DEFABC'.

Initialize internal tables

 
....+....1....+....2....+....3....+....5....+....6....+....7.. 
1 #MONTHS 
  2 #MTH(A3/12)     INIT<'Jan', 'Feb', 'Mar', 'Apr', 
                         'May', 'Jun', 'Jul', 'Aug', 
                         'Sep', 'Oct', 'Nov', 'Dec'> 
  2 #DAYS(N2/12)    INIT<30, 28, 31, 30, 31, 30, 
                         31, 31, 30, 31, 30, 31> 
  
It's easier to see the relationship of "columns" to "rows" like this:
....+....1....+....2....+....3....+....5....+....6....+....7.. 
1 #MONTHS(A5/12)   INIT<'Jan' - '30', 
                        'Feb' - '28', 
                        'Mar' - '31', 
                        'Apr' - '30', 
                         ... 
                        'Dec' - '31'> 
1 REDEFINE #MONTHS
  2 #ELEMENT(12) 
    3 #MTH(A3) 
    3 #DAYS(N2) 

 

Initialization of a super descriptor

....+....1....+....2....+....3....+....5....+....6....+....7.. 
1 #SUPER(A5)  
1 REDEFINE #SUPER 
  2 #STATE(A2) 
  2 #COUNTY(P3) 
  ... 
ASSIGN #STATE  = 'CA' 
ASSIGN #COUNTY = 345              /* LA 
READ view BY ST-CTY FROM #SUPER 
becomes
....+....1....+....2....+....3....+....5....+....6....+....7.. 
1 #SUPER-DEF 
  2 #STATE(A2)     INIT<'CA'> 
  2 #COUNTY(P3)    INIT<345>      /* LA 
1 REDEFINE #SUPER-DEF 
  2 #SUPER(A5) 
... 
READ view BY ST-CTY FROM #SUPER



Back to NATURAL Tips, Tricks, Techniques -- Overview