0
votes

AS. Nevermind. Had wrong gut feeling about continue on while/repeat loops. Made fool of myself :-)

See the commented line. If i uncomment it - compilation goes okay. If i keep it commented, then warning is given about undefined result. It seems compiler fails to account for pseudo-procedures like Break and Continue.

Is it happenning with prior Delphi versions ? Is there QC for it ?

//returns 0 or win32 error code
function TfmMain.callQDN(DeviceName: string;
  out buff: string): DWORD;
const len_step = 8192;
var res, len, err: DWORD;
    lpDeviceName: PChar;
begin
  SetLength(buff, len_step);
  len := Length(buff);

  lpDeviceName := nil;
  if DeviceName>'' then lpDeviceName := @DeviceName[1];

  repeat
    Res := QueryDosDevice(lpDeviceName, @buff[1], len);

    if Res = 0 then begin
       err := GetLastError;
//       Result := err;

       if err = ERROR_INSUFFICIENT_BUFFER then begin
          len := len_step + len;
          SetLength(buff, len);
          continue;
       end;

       Result := err;
    end else begin
       Result := 0;
       SetLength(buff, res); // res+1 ?
    end;

  until (Result = 0);

end;
1

1 Answers

0
votes

I'm stupid.

Continue re-checks the condition, not just starts the loop body again