Jump to content
Ian Branch

InputQuery issue..

Recommended Posts

Hi Team,

D12.2.

I am trying to get multiple inputs using InputQuery with the following code:

procedure TForm12.Button1Click(Sender: TObject);
var
  Values: array of string;
begin
  SetLength(Values, 3);  // Prepare for three input fields
  Values[0] := 'John';    // Default values
  Values[1] := '25';
  Values[2] := 'London';

  if InputQuery('User Information',
                ['Enter your name:', 'Enter your age:', 'Enter your city:'],
                Values,
                nil) then
  begin
    ShowMessage('Name: ' + Values[0] + sLineBreak +
                'Age: ' + Values[1] + sLineBreak +
                'City: ' + Values[2]);
  end;
end;

When run I getthe multiple inputs ok.

Cancel works fine.

If I click OK, I get an access violation.

image.thumb.png.b6122ab4d7ad98b598b74890fa993658.png

Is this a known issue?

Does multi input work?

 

Regards & TIA,

Ian

Share this post


Link to post

Use the overload without the last argument (which cannot be nil):

 

if InputQuery('User Information', 
  ['Enter your name:', 'Enter your age:', 'Enter your city:'], Values) then

 

Edited by pyscripter

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×