Subscribe for automatic updates: RSS icon RSS

Login icon Sign in for full access | Help icon Help
Advanced search

Pages: [1]
  Reply  |  Print  
Author Topic: CONSTANT query  (Read 10998 times)
Gary C.
Posts: 109


« 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
Nuno G.
Posts: 38


« Reply #1 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
Sebastien F.
Four Js
Posts: 545


« Reply #2 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
Gary C.
Posts: 109


« Reply #3 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
Pages: [1]
  Reply  |  Print  
 
Jump to:  

Powered by SMF 1.1.21 | SMF © 2015, Simple Machines