COUNT

<< Click to Display Table of Contents >>

Navigation:  Gekko User Manual > Gekko statements >

COUNT

Previous pageReturn to chapter overviewNext page

The statement is used to search for variables in databanks, using wildcards. The COUNT statement is essentially a compact INDEX statement without the output.

 

When counting timeseries, remember that default COUNT only counts series of the currently active frequency from the first-position databank. You may use : and ! to augment, for instance count *:*!*; to count all timeseries of all frequencies from all databanks.

 

Note that 'naked' wildcards are allowed in this statement, so you may for instance use a*b?c as wildcard instead of the more cumbersome {'a*b?c'}.

 

Wildcard logic, including double and triple stars etc., is explained more generally on the wildcards page.

 


 

Syntax

 

count <BANK=...  > type wildcards ;

 

BANK=

(Optional). A databank name indicating where the variables are to be located.

type

(Optional). Restrict the type of variables.

wildcard

The variables to be searched for. You may use banknames to indicate a particular bank, and you may separate the wildcards with commas. In general, wildcards are of the form a*x to find all variables starting with a and ending with x, or a?x to match exactly one character between a and x. You may use syntax like x[a*,*b] for array-series.

 

If a variable is stated without databank, the databank is assumed to be the first-position databank.

 

The following provides a list of all variables in all databanks:

 

count ***;                //all variables in all banks
count *:**;               //same as above
count *:%*, *:#*, *:*!*;  //same as above

 

 


 

Example

 

The following COUNT statement will look for timeseries beginning with f in the first-position databank (and with the current frequency):

 

reset;
fa = 1; fb = 2; fc = 3;
count f*;  //result: 3

 

 


 

Note

 

See the INDEX statement for more examples.

 

If you use variable names without wildcards or ranges, an existence check is performed (count = 1 if it exists, 0 otherwise).

 

See also the second half of this page regarding wildcards, syntax, etc.

 


 

Related statements

 

LIST, INDEX