?
Solved

Hello guys, I need a help with format, I need to insert string inside another string

Posted on 2006-06-02
4
Medium Priority
?
190 Views
Last Modified: 2010-04-05
This bellow is a test, but I don't know how to make it work.

Var
  S, V1, V2 : String;
begin
  V1 := '10.10.1.10';
  V2 := 'Trator';
  S := 'Connection=%' + ' Database=%' + ' é uma boa base';
  Format('%1:S %1:S',[V1, V2]);
  ShowMessage(S)



0
Comment
Question by:hidrau
4 Comments
 
LVL 11

Accepted Solution

by:
ZhaawZ earned 800 total points
ID: 16820693
v1 := '10.10.1.10';
v2 := 'trator';
s := format('Connection=%s Database=%s é uma boa base', [v1, v2]);
showmessage(s);
0
 
LVL 5

Assisted Solution

by:Scay7
Scay7 earned 400 total points
ID: 16820967
v1 := '10.10.1.10';
v2 := 'trator';
showmessage('Connection='+v1+' Database='+v2+' é uma boa base');

peace Scay7
0
 
LVL 28

Assisted Solution

by:2266180
2266180 earned 800 total points
ID: 16822933
if you wish the result to be
Connection=10.10.1.10 Database=trator é uma boa base
then

ZhaawZ is the correct one using format function and scay7's without using format function.
also, if you construct the format string dynamically, then something like this should do it:
Var
  S, V1, V2 : String;
begin
  V1 := '10.10.1.10';
  V2 := 'Trator';
  S := 'Connection=%s' + ' Database=%s' + ' é uma boa base';// see here the change (this is constructed dynamically)
  s:=Format(s,[V1, V2]);// see here the change
  ShowMessage(S)

if you wish the outcome to be something else, then give us an example of what showmessage should show.
0
 
LVL 1

Author Comment

by:hidrau
ID: 16831992
Thanks Guys

0

Featured Post

Learn to develop an Android App

Want to increase your earning potential in 2018? Pad your resume with app building experience. Learn how with this hands-on course.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
SQL Database Recovery Software repairs the MDF & NDF Files, corrupted due to hardware related issues or software related errors. Provides preview of recovered database objects and allows saving in either MSSQL, CSV, HTML or XLS format. Ensures recov…
In this video I will demonstrate how to set up Nine, which I now consider the best alternative email app to Touchdown.
Suggested Courses

588 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question