Advertisement
tolikpunkoff

Yes/No ask from console

Dec 2nd, 2022
1,501
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 0.57 KB | None | 0 0
  1. program tmpyn;
  2. uses SysUtils,Keyboard;
  3.  
  4. function Ask(FilePath:UnicodeString):boolean;
  5. var K: TKeyEvent;
  6.     KS:String;
  7. begin
  8.     WriteLn ('File ', FilePath, ' is exists! Replace file? [Y/N]');
  9.     InitKeyBoard;
  10.    while true do begin
  11.       K:=GetKeyEvent;
  12.       K:=TranslateKeyEvent(K);
  13.       KS:=KeyEventToString(K);
  14.  
  15.       if (KS='Y') or (KS='y') then begin DoneKeyBoard; exit(true); end;
  16.       if (KS='N') or (KS='n') then begin DoneKeyBoard; exit(false); end;
  17.    end;
  18.  
  19.   DoneKeyBoard;
  20.   exit(false);
  21. end;
  22.  
  23. BEGIN
  24.   WriteLn(Ask('C:\Temp\777'));
  25.   Readln;
  26. END.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement