Page 1 of 1

Cards to enter objects different from integers?

PostPosted: Thu Feb 04, 2010 5:37 am
by jonasdovern
Dear RATS users,
is it possible to program a construction that allows to enter for instance a number of equations on a supplementary card to a procedure (like it is used e.g. in the forecast-command)?

To use this procedure I would like to enter something like

Code: Select all
@testprocedure( options )
# eqn1 eqn2 ... eqnK

Ideally, I would like to enter cards that hold different type of objects (like with the forecast-command):

Code: Select all
@testprocedure( options )
# eqn1 result1
# ...
# eqnK resultK

where resultX is a series/integer/real.

I tried to define the array used with enter inside the procedure as a vec[equ] - but this seems to be not working as I receive an error message that additional memory of "-13 bytes cannot be satisfied".

Re: Cards to enter objects different from integers?

PostPosted: Thu Feb 04, 2010 8:05 am
by TomDoan
You might want to look at the CONDITION.SRC file. That uses ENTER to input a whole string of information, one per line with different fields.

Re: Cards to enter objects different from integers?

PostPosted: Thu Feb 04, 2010 9:47 am
by jonasdovern
Thanks Tom! I think something along those lines will help me! Best regards, Jonas

Re: Cards to enter objects different from integers?

PostPosted: Thu Feb 04, 2010 11:27 am
by jonasdovern
I guess I was too optimistic ;-)

Here's (part of) my code:
Code: Select all
procedure nowcastwithmM ne
   *
    option integer   ftime
    option integer   fsteps 3
    option switch   addf 0
   *
   local int      neqn k
   local model      lmod
   local vec[ser]   fcs
   local vec[int]    af
   local vec[equ]   eqnlist
   *
   if eqninput.and..not.%defined(ne) {
      disp "Please enter the number of equations behind the procedure name!"
      return
   }
   *
   comp neqn = ne
   dim af(neqn)
   *
   dim eqnlist(neqn)
   do k=1,neqn
           enter eqnlist(k)
   end do
   if addf {
      enter(varying,entries=naf) af
      if naf<>neqn {
         disp "Number of add-factors does not correspond to number of equations in the model!"
         return
      }
   }
   else {
      do k=1,neqn
         set af(k) ftime ftime+fsteps-1 = 0.0
      end do
   }
   *
   do k=1,neqn
            if k==1
         group lmod eqnlist(k)
      else
         comp lmod = lmod + eqnlist(k)
   end do
   *
   forecast(print=print,model=lmod,from=ftime,steps=fsteps,results=fcs,path) *
   # af
   *
   decl vec[ser] %mFCS(neqn)
   do k=1,neqn
      set %mFCS(k) ftime ftime+fsteps-1 = fcs(k)(t)
   end do k
   *
end procedure

When running, RATS would promt the error message
Code: Select all
## EQ3. Equation zÚ Has Not Been Defined
The Error Occurred At Location 0830 of NOWCASTWITHMM
Line 66 of NOWCASTWITHMM

(It's the forecast-command that is causing problems; the line number does not corrspond as I deleted some unimportant pieces from the code.)
The problem seems to be that the equations are not properly held by the eqnlist-array.

Best regards, Jonas