Four Js Development Tools Forum

Discussions by product => Genero BDL => Topic started by: Gary C. on January 19, 2014, 06:57:46 pm



Title: CONSTANT query
Post by: Gary C. on January 19, 2014, 06:57:46 pm
Hi

I have been looking at using IMPORT FGL to aid the use of subdialogs. The following code will not compile:

imported.4gl
Code:

PUBLIC CONSTANT MAXCOLSPERTABLE = 100


import_test.4gl
Code:

IMPORT FGL imported

MAIN

    CONSTANT MYCONST = 100
   
    DEFINE idx SMALLINT,
        arrA ARRAY[MYCONST] OF INTEGER,
        arrB ARRAY[MAXCOLSPERTABLE] OF INTEGER
       

    LET idx = MAXCOLSPERTABLE

END MAIN

The compiler complains about the MAXCOLSPERTABLE being used to define the array size as it believes it is undefined, yet is happy with the LET statement and when using a local constant (MYCONST). Is this to be expected?

Thanks

Gary


Title: Re: CONSTANT query
Post by: Nuno G. on January 20, 2014, 08:45:15 am
I would suggest you to use this solution instead:


teste11.h:
===================================
PUBLIC CONSTANT MAXCOLSPERTABLE = 100

teste11.4gl:
===================================
&include "teste11.h"

MAIN

    CONSTANT MYCONST = 100

    DEFINE idx SMALLINT,
        arrA ARRAY[MYCONST] OF INTEGER,
        arrB ARRAY[MAXCOLSPERTABLE] OF INTEGER


    LET idx = MAXCOLSPERTABLE
    DISPLAY arrA.getLength()

END MAIN

I tested iy and it worked just fine.
HIH
Nuno


Title: Re: CONSTANT query
Post by: Sebastien F. on January 20, 2014, 09:41:58 am
Hi Collis,

Yes, it should be possible to use the MAXCOLSPERTABLE constant to define the array in the importing module. We will investigate and fix this. However, I strongly suggest you to use dynamic arrays instead of static arrays. I would not workaround this problem with the preprocessor. If you have to use static arrays (?why?), I would define the "max" constants and the static array in the same module: both define the data model and should be grouped.

Seb


Title: Re: CONSTANT query
Post by: Gary C. on January 20, 2014, 10:33:15 am
Hi

Thanks for the replies.

Nuno, I had originally used an include statement so will likely reinstate that approach.

Seb, the application in question uses tables with a dynamic number of columns and this approach overcomes the issues discussed here: https://4js.com/fjs_forum/index.php?topic=605.0

Gary