Download MetaTrader 5
To add comments, please log in or register
Thousands of developers have already published their products in the Market. Join them!
marana77
16
marana77 2015.10.15 05:54 

Hi, can someone please let me know how I can add two assigned variables in a single sentence. i can do it with one e.g. "this is an example for a single", variable.

But how can I do the same but with two or more variables. Sorry if this seems like a newbie question but I have tried searching for the answer but to no avail. Im doing this for an alert function

Thanks in advance. 

Carl Schreiber
5952
Carl Schreiber 2015.10.15 06:34  

do you mean:

int a,b,c;
a = b = c = 7;
Keith Watford
Moderator
7952
Keith Watford 2015.10.15 06:38  
  string a="A=";
  string b="B=";
  string x="AxB=";
  string p=", ";
  int A=2;
  int B=4;
  int C=A*B;
  string sentence=a+(string)A+p+b+(string)B+p+x+(string)C;
  Print(sentence);

 I'm not sure that I understand correctly, but this may give you a pointer

honest_knave
965
honest_knave 2015.10.15 08:28  

Trying taking a look at StringFormat() / PrintFormat()

marana77
16
marana77 2015.10.15 10:18  
honest_knave:

Trying taking a look at StringFormat() / PrintFormat()

 Thanks for the replies. Sorry if I wasn't clear before but what I mean is for instance

int A= 31

int B = 66

and I want to display an alert I would write

Alert("The value of variable A is ", A)

My question is how would I do the alert but display both A and B variables. I have tried something like

Alert("The value of variable A is ",A "and variable B is ",B)

but compiler returns an error.

Thanks  

honest_knave
965
honest_knave 2015.10.15 10:35  
   int    A=31;
   int    B=66;
   // Method 1
   Alert("The value of A is "+(string)A+" and B is "+(string)B);
   // Method 2
   Alert(StringFormat("The value of A is %i and B is %i",A,B));
   // Method 3
   Alert(StringConcatenate("The value of A is ",A," and B is ",B));
Demos Stogios
184
Demos Stogios 2015.10.15 15:11  

marana77:

 

Alert("The value of variable A is ",A "and variable B is ",B)

hello,

you have to put a comma after A

 

best regards 

/
To add comments, please log in or register