Delphi Pages Forums  

Go Back   Delphi Pages Forums > Delphi Forum > General

Lost Password?

Reply
 
Thread Tools Display Modes
  #1  
Old 12-30-2005, 08:38 AM
douglas douglas is offline
Senior Member
 
Join Date: Jul 2001
Posts: 7,695
Default Multi-InputBox function

As you know, delphi has a InputBox routine....

I want to create the same routine where instead of one field, you have (n) fields and instead of just strings, you can use any field type.

so instead of...

[DELPHI]
function InputBox(const ACaption, APrompt, ADefault: string): string;
[/DELPHI]

you have something like...

[DELPHI]
function ExInputBox(const ACaption: String;
const APrompts: array of string;
const ATypes: Array of TFieldType;
const ADefaults: array of string;
var AValues: array of string): Boolean;
[/DELPHI]

where ATypes is the type expected for each (example: ftString, ftInteger, etc)

and AValues are the values returned from the fields after user enters values


the tricky part comes during validation

what to do if the field expects an integer and the entered value is not.

I'd like to see someone take this function and run with it and see what they came up with. I will then compare it against my working version and I will post mine.

I will award the point to the most intuitive (not counting mine)

However, of course if your's is better then my version, i may use it...



If this helps, please accept as answer!

Thanks!

UnS

ysApps
Reply With Quote
  #2  
Old 12-30-2005, 10:17 AM
AceOmega AceOmega is offline
Senior Member
 
Join Date: Sep 2004
Posts: 2,393
Default RE: Multi-InputBox function

Quick and dirty, probably not what you are looking for but here it is...


[DELPHI]type
TAppendThread = class(TThread)
private
{ Private declarations }
protected
procedure Execute; override;
end;

.
.
.

public
procedure MyAsk(AList : Array of TMyList);
{ Public declarations }
end;

.
.
.

procedure TForm1.Button19Click(Sender: TObject);
var
_MyList : Array of TMyList;
_Loop : Integer;
_NumberOfVals : Integer;
begin
_NumberOfVals := 5;
SetLength(_MyList,_NumberOfVals);
For _Loop := 0 to _NumberOfVals-1 do
begin
_MyList[_loop].Prompt := '';
_MyList[_loop].Value := '';
end;
_MyList[0].Prompt := 'Question 1';
_MyList[1].Prompt := 'Question 2';
_MyList[2].Prompt := 'Question 3';
_MyList[3].Prompt := 'Question 4';
_MyList[4].Prompt := 'Question 5';
MyAsk(_MyList);
end;

procedure TForm1.MyAsk(AList : Array of TMyList);
var
_loop : Integer;
begin
For _Loop := 0 to Length(AList)-1 do
AList[_loop].Value :=
InputBox('Input Box',
AList[_loop].Prompt,
AList[_loop].Value);
end;[/DELPHI]
Reply With Quote
  #3  
Old 12-30-2005, 10:18 AM
AceOmega AceOmega is offline
Senior Member
 
Join Date: Sep 2004
Posts: 2,393
Default RE: Multi-InputBox function

oops...

[DELPHI]type
TMyList = Record
Value : Variant;
Prompt: String;
end;[/DELPHI]
Reply With Quote
  #4  
Old 12-31-2005, 07:48 AM
chris_w chris_w is offline
Senior Member
 
Join Date: Jan 2004
Posts: 1,397
Default RE: Multi-InputBox function

Curious to see the working version.

Chris
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT. The time now is 02:55 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.