[Archive!] Any rookie question, so as not to clutter up the forum. Professionals, don't pass it by. Couldn't go anywhere without you - 2. - page 256

 
sergeev:

Look through the files. It's definitely there.

this one looks like it's from stdlib


thanks

kudos to

 

Good day everyone!

How do you clear a string of characters?

I did it like this :

int str_clear(string &str){


int size = 0;

size = StringLen(str);

str = "";

if (StringLen(str) > 0) {

return (0);
}else{

return (1);

}
}

Is there any way to do this with built-in functions?

 
BBSL:

Good day everyone!

How do you clear a string of characters?

I did it like this :

Is there any way to do this with built-in functions?


what prevents the variable containing the string from being set to "" ?

Your function will always return 1.

 
PapaYozh:


What prevents you from setting the variable containing the string to "" ?

Your function will always return 1.


Hello PapaYozh, nothing prevents... (except that we won't be able to write data to str at some point in time)

So there is no special function for this? ))

 
BBSL:


Hello PapaYozh, there is nothing in the way... (except that at a certain point in time we won't be able to write data to str)

So there is no special function for this? ))


How do you use the function int str_clear(string &str) ?

Bring any line from your EA/indicator/script where str_clear function is used.

 
PapaYozh:


How do you use the function int str_clear(string &str) ?

Please provide any line from your EA/indicator/script where str_clear function is used.


PapaYozh, you didn't answer my question...))

As for, int str_clear(string &str);, of course, it doesn't have to return "flag" from it to check its dimensionality, but it's not against programming rules both in MQL4 and C++))

For example, like this:

str_clear(str);
 
BBSL:


PapaYozh, you didn't answer my question...))

As for int str_clear(string &str);, of course, you don't have to return "flag" from it to check dimensionality, but it may seem not to contradict programming rules of both MQL4 and C++))

For example, here's an example:


1. Understand you are not returning a flag, but a 1. Always 1.

2. If instead of

str_clear(str);

use

str = "";

this will be "stripping the string of characters".

 
PapaYozh:


1. Understand you are not returning a flag but a 1. It's always 1.

2. If you instead

use

that would be "stripping the string of characters".


Thank you

So you don't allow that for some reason, the command str = ""; might not execute?

 
BBSL:


Thank you

So you don't allow that for some reason, the command str = ""; might not execute?


no I don't.

Inside your function is the same assignment command.

 

How to return the cost of an item ???

This does not work !

string Symb =Symbol() ;

double serew=MarketInfo(Symb,MODE_POINT) ;