git @ Cat's Eye Technologies OpenZz / master testsuite / looptest_while.zz
master

Tree @master (Download .tar.gz)

looptest_while.zz @masterraw · history · blame

!!
!!  Zz Dynamic Parser Library
!!  Copyright (C) 1989 - I.N.F.N - S.Cabasino, P.S.Paolucci, G.M.Todesco
!!
!!  The Zz Library is free software; you can redistribute it and/or
!!  modify it under the terms of the GNU Lesser General Public
!!  License as published by the Free Software Foundation; either
!!  version 2.1 of the License, or (at your option) any later version.
!!
!!  The testsuite test scripts are distributed with Zz as part of it,
!!  also under the LGPL.
!!
!!  The Zz Library is distributed in the hope that it will be useful,
!!  but WITHOUT ANY WARRANTY; without even the implied warranty of
!!  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
!!  Lesser General Public License for more details.
!!
!!  You should have received a copy of the GNU Lesser General Public
!!  License along with this library; if not, write to the Free Software
!!  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
!!

!! Testsuite program for 'while' loop
!! Tests use of nested loops and compound conditional logic
!!
!!REFERENCE OUTPUT:
!!__________x 
!!_________xxx 
!!________xxxxx 
!!_______xxxxxxx 
!!______xxxxxxxxx 
!!_____xxxxxxxxxxx 
!!____xxxxxxxxxxxxx 
!!___xxxxxxxxxxxxxxx 
!!__xxxxxxxxxxxxxxxxx 
!!_xxxxxxxxxxxxxxxxxxx 
!!xxxxxxxxxxxxxxxxxxxxx 
!!_xxxxxxxxxxxxxxxxxxx 
!!__xxxxxxxxxxxxxxxxx 
!!___xxxxxxxxxxxxxxx 
!!____xxxxxxxxxxxxx 
!!_____xxxxxxxxxxx 
!!______xxxxxxxxx 
!!_______xxxxxxx 
!!________xxxxx 
!!_________xxx 
!!__________x 
!!a-1-2-3-4-5
!!a-1-2-3-4-5
!! END OUTPUT

/idx = 0;
/width = 10;
/fill="X"
/spacing="_"

/while (idx <= width*2) {
  /tmp = "";

    /if (idx <= width) { /curwidth = idx; } else { /curwidth = (2*width) - idx }

    /spc = 0;
    /while (spc < (width - curwidth)) {
      /tmp = tmp & spacing;

      /spc = spc + 1;
    }

    /stuff = 0;
    /while (stuff < ((curwidth*2)+1)) {
      /tmp = tmp & fill;

      /stuff = stuff + 1;
    }

    /print tmp;
    /idx = idx +  1;
}


!! Further testing with complex logic
/str="a";
/val=1;
/while (val <= 5) || (9==1) { /str = str & "-" & val;  /val = val + 1 }
/print str;

!! Test all operators in boolean output
/str="a";
/val=1;
/while ((val <= 5) || (9==1)) && ((1==1) && (1<=2)) || ((2>=3) && (2!=2) && (2>2) && (2<2)) ...
    { /str = str & "-" & val;  /val = val + 1 }
/print str;