Error "G0315 : Call using pointer on left-hand side" when running error correction model (ecm)

Dear Gaussian,

I've noticed that the varma src does not work (while the arma one works)
Even when trying to run the following ecm.e (example file) it does not work:
the error messages are:
c:\program files\gauss70\src\vmutils.src(1302) : error G0315 : 'eq1 = _vm_eqProc' : Call using pointer on left-hand side
c:\program files\gauss70\src\vmutils.src(1315) : error G0155 : Nested procedure definition
#IF without #ENDIF
Does anyone have an idea to deal with that?

Thank you in advance,
Tony

/*
** ecm.e
*/

library varma;
#include varma.ext
varmaset;

load y[362,2] = ecm.txt;

print "ECM Model";
{  a, B, va, coeffs, vc, h, res, f, retcode }
= ecm("",y[.,1:2], 0, 0, 0, 1, 0, 1);

format /ld 12,4;
print;
print;
print "eigenvalues";
print va;

 

5 Answers



0



I just ran the example file ecm.e in the GAUSS 15 and it ran fine. The file I ran had a slightly different load line than yours:

load y[362,3] = ecm.asc;

and the second input to the ecm procedure was y[2:3]. It also did not have the #include varma.ext line. I mention those for completeness, but do not think they are relevant.

I think that the problem is in your copy of varmautil.src. Pointers to procedures in GAUSS are used with these steps:

  1. Assign a local variable to the address of another procedure.
  2. Declare the variable just assigned to be a procedure pointer. After this is done, you cannot assign to this variable again.
  3. Call your function with the procedure pointer.

Here is a toy example:

x = 4;

//Assign 'fct' to point at the proc 'square'
fct = □

//Call main function
{ x_squared, x_cubed } = main(x, fct);

proc (2) = main(x, fct);
    local ret_square, ret_cube, fct_cube;
    
    //Declare the input 'fct' to be a proc pointer
    //after this point it CANNOT be assigned to again
    local fct:proc;
    
    //Call 'square' using the proc pointer, 'fct'
    ret_square = fct(x);

    //Assign 'fct_cube' to point at the proc 'cube'
    fct_cube = &cube;
    
    //Declare the local variable 'fct_cube' to be a proc pointer
    //after this point it CANNOT be assigned to again
    local fct_cube:proc;

    //Call 'cube' using the proc pointer, 'fct_cube'
    ret_cube = fct_cube(x);
    
    retp(ret_square, ret_cube);
endp;

proc (1) = square(x);
    retp(x .* x);
endp;

proc (1) = cube(x);
    retp(x .*x .*x);
endp;

Now if we make one change the code above and assign to one of the procedure pointers AFTER it is declared as a local:proc, like this:

x = 4;

//Assign 'fct' to point at the proc 'square'
fct = □

//Call main function
{ x_squared, x_cubed } = main(x, fct);

proc (2) = main(x, fct);
    local ret_square, ret_cube, fct_cube;
    
    //Declare the input 'fct' to be a proc pointer
    //after this point it CANNOT be assigned to again
    local fct:proc;
    
    //Call 'square' using the proc pointer, 'fct'
    ret_square = fct(x);

    //Declare the local variable 'fct_cube' to be a proc pointer
    //after this point it CANNOT be assigned to again
    local fct_cube:proc;

    //Assign 'fct_cube' to point at the proc 'cube'
    fct_cube = &cube;
    
    //Call 'cube' using the proc pointer, 'fct_cube'
    ret_cube = fct_cube(x);
    
    retp(ret_square, ret_cube);
endp;

proc (1) = square(x);
    retp(x .* x);
endp;

proc (1) = cube(x);
    retp(x .*x .*x);
endp;

Then we receive Error G0315 : Call using pointer on left-hand side. It is likely that something like this is happening in your varmautil.src file. The current version of the file does not have this problem. I would recommend reinstalling the application module, because if your version of the file has been modified this may not be the only issue in your local version.

aptech

1,773


0



Thank you very much!

I am using GAUSS 7.0  and it may have some bugs.

Here is the problematic proc in  varmautil.src , which resulted in  this error.

" c:\program files\gauss70\src\vmutils.src(1302) : error G0315 : 'eq1 = _vm_eqProc' : Call using pointer on left-hand side"

 

proc eq_ecm(b);

local ny,_zeta,_pi,_vc,_beta,s0,ss,sz,e;
{ _zeta, _pi, _vc, _beta } = getECMPars(b);
e = _pi * _vm_my;
if not scalmiss(_beta);
e = e + _beta * _vm_mx;
endif;
if not scalmiss(_vm_eqProc);
local eq1:proc;
eq1 = _vm_eqProc;
e = e | eq1(b);
endif;
retp(e);

endp;

 

Is there any way to get rid of that error?

 

I  removed " local eq1:proc" and added eq1 to "local ny,_zeta,_pi,_vc,_beta,s0,ss,sz,e;" which is at the beginning, to make it like " local eq1, ny,_zeta,_pi,_vc,_beta,s0,ss,sz,e;" then, it works! But then what does "eq1"  mean?  a local variable? not a proc?

 

Thanks in advance!

Tony



0



There is a typo in this sentence from above

"Here is the problematic proc in  "varmautil.src" , which resulted in  this error."

It is not varmautil.src . The correct source file name is "vmutils.src" which is the original source from GAUSS.

Thanks,
Tony



0



The problem with this code sample below is that you are not allowed to assign to GAUSS variable after you declare it to be a procedure pointer.

proc eq_ecm(b);
   local ny,_zeta,_pi,_vc,_beta,s0,ss,sz,e;
   { _zeta, _pi, _vc, _beta } = getECMPars(b);
   e = _pi * _vm_my;
   if not scalmiss(_beta);
      e = e + _beta * _vm_mx;
   endif;
   if not scalmiss(_vm_eqProc);
      local eq1:proc;   //Declare as procedure pointer
      eq1 = _vm_eqProc; //Illegally assign to just declared procedure pointer
      e = e | eq1(b);
   endif;
retp(e);
endp;

What the code needs to do instead is to:

  1. Declare eq1 as a local variable.
  2. Assign the value of _vm_eqProc (which is a procedure pointer) to eq1.
  3. Declare eq1 as a procedure pointer (which means it cannot be assigned to again.

This code should resolve your problem:

proc eq_ecm(b);
   local ny,_zeta,_pi,_vc,_beta,s0,ss,sz,e;
   { _zeta, _pi, _vc, _beta } = getECMPars(b);
   e = _pi * _vm_my;
   if not scalmiss(_beta);
      e = e + _beta * _vm_mx;
   endif;
   if not scalmiss(_vm_eqProc);
      local eq1;   //Declare as local (could be done at top of procedure in initial 'local' statement
      eq1 = _vm_eqProc; //Legal assignment
      local eq1:proc;   //Declare as procedure pointer
      e = e | eq1(b);
   endif;
retp(e);
endp;

aptech

1,773


0



Thank you very much for your help!

Your Answer

5 Answers

0

I just ran the example file ecm.e in the GAUSS 15 and it ran fine. The file I ran had a slightly different load line than yours:

load y[362,3] = ecm.asc;

and the second input to the ecm procedure was y[2:3]. It also did not have the #include varma.ext line. I mention those for completeness, but do not think they are relevant.

I think that the problem is in your copy of varmautil.src. Pointers to procedures in GAUSS are used with these steps:

  1. Assign a local variable to the address of another procedure.
  2. Declare the variable just assigned to be a procedure pointer. After this is done, you cannot assign to this variable again.
  3. Call your function with the procedure pointer.

Here is a toy example:

x = 4;

//Assign 'fct' to point at the proc 'square'
fct = □

//Call main function
{ x_squared, x_cubed } = main(x, fct);

proc (2) = main(x, fct);
    local ret_square, ret_cube, fct_cube;
    
    //Declare the input 'fct' to be a proc pointer
    //after this point it CANNOT be assigned to again
    local fct:proc;
    
    //Call 'square' using the proc pointer, 'fct'
    ret_square = fct(x);

    //Assign 'fct_cube' to point at the proc 'cube'
    fct_cube = &cube;
    
    //Declare the local variable 'fct_cube' to be a proc pointer
    //after this point it CANNOT be assigned to again
    local fct_cube:proc;

    //Call 'cube' using the proc pointer, 'fct_cube'
    ret_cube = fct_cube(x);
    
    retp(ret_square, ret_cube);
endp;

proc (1) = square(x);
    retp(x .* x);
endp;

proc (1) = cube(x);
    retp(x .*x .*x);
endp;

Now if we make one change the code above and assign to one of the procedure pointers AFTER it is declared as a local:proc, like this:

x = 4;

//Assign 'fct' to point at the proc 'square'
fct = □

//Call main function
{ x_squared, x_cubed } = main(x, fct);

proc (2) = main(x, fct);
    local ret_square, ret_cube, fct_cube;
    
    //Declare the input 'fct' to be a proc pointer
    //after this point it CANNOT be assigned to again
    local fct:proc;
    
    //Call 'square' using the proc pointer, 'fct'
    ret_square = fct(x);

    //Declare the local variable 'fct_cube' to be a proc pointer
    //after this point it CANNOT be assigned to again
    local fct_cube:proc;

    //Assign 'fct_cube' to point at the proc 'cube'
    fct_cube = &cube;
    
    //Call 'cube' using the proc pointer, 'fct_cube'
    ret_cube = fct_cube(x);
    
    retp(ret_square, ret_cube);
endp;

proc (1) = square(x);
    retp(x .* x);
endp;

proc (1) = cube(x);
    retp(x .*x .*x);
endp;

Then we receive Error G0315 : Call using pointer on left-hand side. It is likely that something like this is happening in your varmautil.src file. The current version of the file does not have this problem. I would recommend reinstalling the application module, because if your version of the file has been modified this may not be the only issue in your local version.

0

Thank you very much!

I am using GAUSS 7.0  and it may have some bugs.

Here is the problematic proc in  varmautil.src , which resulted in  this error.

" c:\program files\gauss70\src\vmutils.src(1302) : error G0315 : 'eq1 = _vm_eqProc' : Call using pointer on left-hand side"

 

proc eq_ecm(b);

local ny,_zeta,_pi,_vc,_beta,s0,ss,sz,e;
{ _zeta, _pi, _vc, _beta } = getECMPars(b);
e = _pi * _vm_my;
if not scalmiss(_beta);
e = e + _beta * _vm_mx;
endif;
if not scalmiss(_vm_eqProc);
local eq1:proc;
eq1 = _vm_eqProc;
e = e | eq1(b);
endif;
retp(e);

endp;

 

Is there any way to get rid of that error?

 

I  removed " local eq1:proc" and added eq1 to "local ny,_zeta,_pi,_vc,_beta,s0,ss,sz,e;" which is at the beginning, to make it like " local eq1, ny,_zeta,_pi,_vc,_beta,s0,ss,sz,e;" then, it works! But then what does "eq1"  mean?  a local variable? not a proc?

 

Thanks in advance!

Tony

0

There is a typo in this sentence from above

"Here is the problematic proc in  "varmautil.src" , which resulted in  this error."

It is not varmautil.src . The correct source file name is "vmutils.src" which is the original source from GAUSS.

Thanks,
Tony

0

The problem with this code sample below is that you are not allowed to assign to GAUSS variable after you declare it to be a procedure pointer.

proc eq_ecm(b);
   local ny,_zeta,_pi,_vc,_beta,s0,ss,sz,e;
   { _zeta, _pi, _vc, _beta } = getECMPars(b);
   e = _pi * _vm_my;
   if not scalmiss(_beta);
      e = e + _beta * _vm_mx;
   endif;
   if not scalmiss(_vm_eqProc);
      local eq1:proc;   //Declare as procedure pointer
      eq1 = _vm_eqProc; //Illegally assign to just declared procedure pointer
      e = e | eq1(b);
   endif;
retp(e);
endp;

What the code needs to do instead is to:

  1. Declare eq1 as a local variable.
  2. Assign the value of _vm_eqProc (which is a procedure pointer) to eq1.
  3. Declare eq1 as a procedure pointer (which means it cannot be assigned to again.

This code should resolve your problem:

proc eq_ecm(b);
   local ny,_zeta,_pi,_vc,_beta,s0,ss,sz,e;
   { _zeta, _pi, _vc, _beta } = getECMPars(b);
   e = _pi * _vm_my;
   if not scalmiss(_beta);
      e = e + _beta * _vm_mx;
   endif;
   if not scalmiss(_vm_eqProc);
      local eq1;   //Declare as local (could be done at top of procedure in initial 'local' statement
      eq1 = _vm_eqProc; //Legal assignment
      local eq1:proc;   //Declare as procedure pointer
      e = e | eq1(b);
   endif;
retp(e);
endp;
0

Thank you very much for your help!


You must login to post answers.

Have a Specific Question?

Get a real answer from a real person

Need Support?

Get help from our friendly experts.

Try GAUSS for 14 days for FREE

See what GAUSS can do for your data

© Aptech Systems, Inc. All rights reserved.

Privacy Policy