0

using inputbox in Lazarus/Free Pascal gives you a dialogue with "OK" and "Cancel".

Does pressing "cancel" do anything else then returning the default string (which would be the same if I press ok without entering anything in the input field)? Apparently It does so using Delphi! The doc for inputbox is down at the moment, so it's not possible to check there. Thanks!

Albin
  • 1,000
  • 1
  • 11
  • 33
  • In Delphi, `Cancel` returns false, while OK returns true. You use it like `if InputBox(....) then`. – Ken White Sep 04 '18 at 12:29
  • @KenWhite using Lazarus `inputbox` doesn't return true when ok is pressed it returns the string that was typed into the input field (`InputQuery` has the behaviour you are describing)! – Albin Sep 04 '18 at 12:51
  • 2
    Lazarus is open source. `InputBox()` implementation contains only two lines of code: `Result := ADefault; InputQuery(ACaption, APrompt, Result);` – Abelisto Sep 06 '18 at 07:22
  • @Abelisto of course, completely forgot about the option to check in the source code myself! Thanks for the hint! – Albin Sep 06 '18 at 13:51

1 Answers1

0

InputBox() only returns a string. This string is the one edited and confirmed by the user, or the default passed as argument.

Companion to InputBox() is InputQuery(), which returns true or false depending whether the user confirmed or not. The actual string to show and confirm is passed as a var parameter, and is hence returned back.