ifthen2.gms : Test nested $ifThen and $endIf

Description

Contributor: Alex


Small Model of Type : GAMS


Category : GAMS Test library


Main file : ifthen2.gms

$title Test nested $ifThen and $endIf  (IFTHEN2,SEQ=452)

$onText
Contributor: Alex
$offText

$ifThen.C1 1==1 display '$ifThen.C1 1==1';
$  ifThen.C2 1==1
   display 'C2true 1';
$  else.C2
   abort   'C2false 1';
$  endIf.C2  $remark finished $endIf C2 1
display 'C2 1'
$endIf.C1    $remark finished $endIf C1 1
display 'C1 1'

$ifThen.C1 1==1  display '$ifThen.C1 1==1';
$  ifThen.C2 0==1
   abort   'C2true 2';
$  else.c2
   display 'C2false 2';
$  endIf.C2 $remark finished $endIf C2 2
display 'C2 2'
$endIf.C1   $remark finished $endIf C1 2
display 'C1 2'

$ifThen.C1 0==1  abort '$ifThen.C1 0==1';
$  ifThen.C2 1==1
   abort 'C2 true 3';
$  else.c2
   abort 'C2false 3';
$  endIf.C2  $remark finished $endIf C2 3
abort 'C2 3'
$endIf.C1    $remark finished $endIf C1 3
display 'C1 3'

$ifThen.C1 0==1  abort '$ifThen.C1 0==1';
$  ifThen.C2 0==1
   abort 'C2true 4';
$  else.c2
   abort 'C2false 4';
$  endIf.C2 $remark finished $endIf C2 4
abort 'C2 4'
$endIf.C1   $remark finished $endIf C1 4
display 'C1 4'


scalar count / 0 /;
$escape =
$onEcho > in.gms
$  ifThen.C1 %=1==1
   display 'from inside'; count := count + 1;
$  endIf.C1
$offEcho

$onDollar
$ifThen.C1 1==1
$batInclude in 1
$endIf.C1

$ifThen.C1 1==1
$batInclude in 0
$endIf.C1

$ifThen.C1 0==1
$batInclude in 1
$endIf.C1

$ifThen.C1 0==1
$batInclude in  0
$endIf.C1

abort$(count<>1) 'something went wrong',count;