Help on a simple repeat until loop

Regrading the following query:

========
Newsgroups: comp.lang.pascal.borland
Subject: Help on a simple repeat until loop
From: Har...@starnetinc.com (Harfst)
Date: 26 Jan 1996 04:35:05 GMT

What is wronge with a loop like this

Repeat
        Writeln('Enter width and length');
        Readln(Width, Length);
Until Width > 0 AND Length > 0;

Thanks,
Greg Harfst
??????????????????????????????????

6:13PM  1/26/96
Greg,
I see two things wrong with what you have, but the variable types
are important, too.

The terminating statement should be written:
Until (xxxxx) AND (xxxxx);
BUT--"Length" is a reserved word for Length(stringvar).

The following "quicky" program shows some of my own preferences.
Entering numbers as a string of numerical characters is more user
friendly than real or integers. As shown in this example, if you
make a typo that is not numeric, you repeat the entry. With
the entries being strings you can make a convenient, non-ambiguous
exit. This also allows you to keep on testing the program with
various entries without leaving the program.

The first VAL statement in this program is unconventional. "Code" is
equal to the string character location of the first non-numeric char.
If everything is OK Code = 0. This allows you to split the string into

two or more variables. It also allows a very flexible means of
delimiting the variables. You can use one or more spaces, which is
transparent to someone who thinks they are entering numbers this way.
You can use , ; / : | or any convenient delimiter chracter with
no space or with one or more spaces following the delimiter.
The reason for the multiple spaces not causing a crash is because VAL
accepts leading spaces (BUT NOT TRAILING) and still gets the right
number value. Conventional string manipulations could have been used
but this is much more compact.

Clif
______________________

PROGRAM RptUntil;

       { 1/26/96    <clifp...@airmail.net>
An example of entry of two variables by a single character string
which uses VAL to convert to numbers.

If either entry is not > 0 or is not a pure number, another set of
entries is prompted. Since the entry is a string, the program can be
terminated by just pressing <Enter>.  }

USES CRT;

VAR
s, L, W : STRING[40] ;
Len, Wid: REAL ;
Code, Sum :INTEGER ;

BEGIN
ClrScr;
Writeln('    *** Just press <Enter> to exit ***');
REPEAT
    REPEAT
          Writeln;     Write('Enter width and length: ');
          Readln(s);
          IF s = '' THEN EXIT;

          VAL(s, Wid, Code);  {Code = location of first non-numeric char}
          W := COPY(s, 1, Code - 1);      {width as a char string}
          L := COPY(s, Code + 1, LENGTH(s) - Code + 1);  

          VAL(W, Wid, Code);    {Converts W str to Wid real}
          Sum := Code;
          VAL(L, Len, Code);
          Sum := Sum + Code;    
          IF Sum <> 0 THEN Writeln('** ERROR! **')
    UNTIL (Wid > 0) AND (Len > 0) AND (Sum = 0);

    Writeln('Width = ', Wid, '  Length = ', Len);
    Writeln('Area = ', Wid * Len);
UNTIL s = '';
END.