Are their any known limitations in relation to copycode.
I have implemented a quicksort algorithm using copycode. The idea is that any data type can be used, since the type of data array elements are determined at compile time. This doesn’t seem to work for some reason.
First I have used #tempidx1, since the compiler seems to have problems with a construction like &2&(#qs.l), so I replaced #qs.l with a temporary variable. That seems to solve this problem. But when I run the test program, #tempidx1 is 0 while #qs.l is 4, even after the assignment.
Personally I have no clue what’s going on. That’s why I would like to know if their are any restrictions in relation to arrays.
First, a note. Probably 20 years ago I did a timing comparison of Natural’s internal sort versus a double bubble sort (bi directional bubble sort) I had written. Natural won by a factor of ten. Have not run such a timing comparison in a long while, but I would be willing to be Natural still wins, by a large margin.
Are you saying that if you insert a WRITE #tempidx1#qs.l between lines 0250 and 0260 they are different? If so, what are their formats? Also, formats of other variables in the code.
NAT0475 INCLUDE statements must be nested on less than 20 levels.
The documentation http://techcommunity.softwareag.com/ecosystem/documentation/natural/nat426mf/sm/include.htm
says: Because &n& is a valid part of an identifier, this notation may not be used as a copy code parameter substitution in other positions described above (i.e. abc&1& or &1&abc&2&). In other words, a string may only come after copy code parameters, not before or between.
But the reason for your &2&(#qs.l)-Problem is another one. Try this:
define data local
1 #a10 (A10/1:10)
1 #qs
2 l (N1) init <1>
end-define
write #a10(l) /* works
write #a10(#qs.l) /* doesn't work
end
:shock: Could you post a compilable example of your code?
Whereas #a10 (l) works for your example, suppose I had:
define data local
1 #a10 (A10/1:10)
1 #qs
2 L (N1) init <1>
1 #qq
2 L (N1) init <3>
end-define
write #a10(L) /* works
write #a10(#qs.L) /* doesn’t work
end
Now #a10 (L) produces an error message that the L is not adequately qualified.
Worse, there does not appear to be a way to reference this properly except for the somewhat clumsy code:
move #qs.L to #sub /* where #sub might be I2 or N1
write #a10 (#sub)
define data local
1 #a10 (A10/1:10)
1 #qs
2 L (N1) init <1>
1 #qq
2 L (N1) init <3>
end-define
write #a10(L) /* NAT0434 --> OK
write #a10(#qs.L) /* NAT0281 --> not OK
end
After thinking twice about that problem:
I think write #a10(#qs.L) should be a valid code… Seems like I have to open a empower service call.