How do I declare and define constants in one kl file and access it another?

  • I am trying to create a single file for all the constants I'll need and refer to them in all the other files.


    I created a GlobalVars.kl file that looks like


    Code
    PROGRAM GlobalVars
    
    	VAR
    		maxSize	 : INTEGER
    
    	BEGIN
    		maxSize = 125
    END GlobalVars


    I created a QuickTest.kl that looks like:


    Code
    PROGRAM QuickTest
    
    	VAR
                    maxSize FROM GlobalVars : INTEGER
    
    	BEGIN
    		WRITE('maxSize: ',maxSize,CR)		
    END QuickTest


    Both files compile fine, but when I run quicktest.pc, I get:


    Intp-311 (Quick_Test, 7) uninitialized data is used.....abort all


    How do I accomplish this?

  • To have global constants I suggest creating the file myconst.kl

    Code
    CONST1 = 1
    CONST2 = 2


    and then include it in CONST field of all programs that need it

    Code
    PROGRAM prog
        CONST
            %INCLUDE myconst
        VAR
            myint : INTEGER
        BEGIN
            myint = CONST1
            WRITE(myint,CR)
    END prog

Advertising from our partners