TELL

<< Click to Display Table of Contents >>

Navigation:  Gekko User Manual > Gekko statements >

TELL

Previous pageReturn to chapter overviewNext page

The TELL statement prints a text string in the output window. TELL will abort with an error if the argument is not a string, in which case you may have to use the string() function to convert the type. PRT will also print scalar strings, but TELL is convenient for messages.

 


 

Syntax

 

tell < LINE  NOCR  MUTE > message ;

 

message

(Optional). The text to print (remember single quotes). Can be an expression that can be evaluated as a string.

LINE

(Optional). With <line>, an empty line is inserted before this message. This is similar to using tell; tell 'message';.

NOCR

(Optional). With <nocr>, no newline is inserted at the end of the string (no carriage return). This way, you can use several TELL's in succession on the same line.

MUTE

(Optional). Use <mute=no> to turn off general mute set with option interface mute = yes;. Use of <mute> or <mute=yes> will mute the message and is essentially like commenting out the TELL statement.

 

 


 

Examples

 

The TELL statement can be used to print text strings, for instance for messages:

 

tell;  //blank line
tell 'First line';
tell 'Second line';

 

Use <nocr> if you need to join text:

 

tell <nocr> 'The ';
tell <nocr> 'fox is ';
tell 'red.';

 

Use <mute=no> to overrule a general mute (typically used in program files), for instance:

 

option interface mute = yes;
open mybank;   //normally produces screen output
model mymodel; //normally produces screen output
tell <line mute=no> 'Databank opened and model loaded';
//
//Gekko keeps on muting from here

 

An alternative could be to put the OPEN and MODEL statements inside a BLOCK that turns on muting:

 

block interface mute = yes;
  open mybank;   //normally produces screen output
  model mymodel; //normally produces screen output
end;
tell <line> 'Databank opened and model loaded';
//
//Gekko does not mute from here

 

Below some examples, where scalars are inserted into the TELL statement in different ways:

 

%s1 = 'Value in ';
%d1 = 2010;
%s2 = ' is: ';
%v1 = 113.45;
%v2 = 10;
%s3 = %s1 + %d1 + %s2 + (%v1 + %v2);
tell %s3;
tell 'Value in ' + %d1 + ' is: ' + (%v1 + %v2);
tell 'Value in {%d1} is: {%v1 + %v2}';

 

This will print Value in 2010 is: 123.45 three times, so the three last TELLs are equivalent. When adding the scalars, it should be noted that scalar dates and scalar values are automatically converted to strings when added to a string with the + operator. So there is no need to use %s3 = %s1 + string(%d1) + %s2 + string(%v1);.

 

If you need to write curly braces like {%d1} literally, preprend the symbol ~ to indicate that Gekko should not try to in-substitute. For example:

 

tell 'The scalar name is ~{%d1}';

 

This will print 'The scalar name is {%d1}' on the screen, and not try to evaluate the inside of the {}-curlies. If you need to format values, you can either use the format() function, or use global formatting of {}-curlies via option string interpolate format val = ... . For instance. See more regarding format() function in the Gekko functions section (the code '6:0.00' means a 6 character wide field, where the number has exactly two decimals).

 

%v11 = 1/3; %v12 = 1/4; %v21 = 1/5; %v22 = 1/6;
tell '{format(%v11, '6:0.00')},{format(%v12, '6:0.00')}';
tell '{format(%v21, '6:0.00')},{format(%v22, '6:0.00')}';
//since the formatting is the same, you can use an option:
option string interpolate format val = '6:0.00';
tell '{%v11},{%v12}';
tell '{%v21},{%v22}';
 
//   result:
//   0.33,  0.25
//   0.20,  0.17

 

 


 

Options

 

option interface mute = no;

 


 

Related functions

 

format()

 


 

Related statements

 

DISP, PIPE, PRT, STRING