Page 1 of 1

Use of cards instruction

Posted: Tue Jun 07, 2011 11:45 am
by jonasdovern
Can I really only use the cards instruction with the functions that are listed in the reference manual under the header "Applicability"?

What I would like is to use the @condition procedure within another procedure that I wrote. The number of constraints should be handled flexibel, therefor I need the cards instruction ...

I have something like (I only list the relevant lines):

Code: Select all

procedure newproc
  option integer constraints 1
  local integer icon
  local index varcon entrycon
  local vec[real] valuecon
  
  dim varcon(constraints) entrycon(constraints) valuecon(constraints)
  do i=1,constraints
     enter varcon(i) entrycon(i) valuecon(i)
  end do i 

  /* Estimate a model 'olsmodel' here */

  list icon = 1 to constraints
  @condition(model=olsmodel,from=ftime,steps=fsteps,nosimulate,results=olsfcasts) constraints
  cards varcon(icon) entrycon(icon) valuecon(icon)

This works fine for constraints equal to 1, but not for more than 1 constraint.

If the use of cards is not possible here. Can I use any other approach?

Re: Use of cards instruction

Posted: Fri Jun 10, 2011 4:12 pm
by moderator
Yes, it is true that the applicability of the CARDS instruction is limited to specific instructions, so I don't think that code will work as written.

I'd probably be tempted to just modify a copy of CONDITION.SRC to accept the input in a different way, for use with your procedure.

Otherwise, you could use OPEN to open a text file, a sequence of DISPLAY(UNIT=unitname) commands to generate the necessary procedure call and supplementary cards into that file, a CLOSE command to close the file, and then a SOURCE command to execute the generated commands. That has the disadvantage of needing to generate a temporary file somewhere, but should be simple to implement. Again, though, I'd probably look to modifying a version of CONDITION.SRC as a more elegant solution.

Regards,
Tom Maycock
Estima

Re: Use of cards instruction

Posted: Wed Jul 13, 2011 2:43 am
by jonasdovern
Thanks Tom. (Sorry for the late reply; I was on holidays.) I guess I'll write a condition2.src in this case.

Are you thinking about making the cards indstruction more generally applicable? I think it is a very useful command for users that write a lot of more advanced procedures.