Errors, bugs, questions - page 3019

 
Andrei Trukhanovich:

it seems that count=0 works in the same way as count=-1 and in case of "" it copies a terminal null.

This is where the error lies, just shown with a practical example where ingeneral there can be both empty strings and count = 0 by itself (in a loop for example)

 
A100:

And how many

should it copy if count = 0 ?

Hint: 3 characters are copied when count = 3.

I'm not even going to argue. It works correctly.

Andrei Trukhanovich:

Looks like count=0 works the same way as count=-1 and in the case of "" it copies a terminal null, so you can't properly convert an empty string without additional checks

An empty string (NULL) does not contain a terminal null. Everything seems to work logically there.

 
fxsaber:

I'm not even going to argue. It works correctly.

If there are no arguments, then of course you don't have to.

fxsaber:

An empty string (NULL) does not contain a terminal null. In my opinion, everything works there logically.

An empty string is "" and NULL is not an empty string - it is an uninitialized string, i.e. it is not a string at all andStringToCharArray with NULL does not work, error result: 4009

 
A100:

If there are no arguments, then of course you don't need

An empty string is "" and NULL is not an empty string - it's an uninitialized string, i.e. it's not a string at all andStringToCharArray with NULL does not work, error result: 4009

You are mistaken, to put it mildly.

 
fxsaber:

You are mistaken, to put it mildly.

Please explain if you have anything to say on the merits

 
A100:

Please explain if you have anything to say on the merits

string Str = NULL;

Print(Str == "");
 
fxsaber:

Result: false

What is the contradiction with this statement?

Forum on trading, automated trading systems & strategy testing

Bugs, bugs, questions

A100, 2021.05.24 20:07

Empty string is "" while NULL is not an empty string - it is an uninitialized string which means it is not a string at all andStringToCharArray with NULL does not work and causes error: 4009


 
A100:

Result: false

And what is the contradiction with this statement?

The variable is initialized. You can, of course, think of string as a pointer to an internal string class.

 
fxsaber:

The variable is initialised. You can, of course, think of string as a pointer to an internal string class.

If it's initialized, then why the

void OnStart()
{
    uchar array[];
    const string text = NULL;
    StringToCharArray( text, array );
    Print( GetLastError());
}

error 4009

ERR_NOTINITIALIZED_STRING

4009

Uninitialized string

 
fxsaber:

I'm not even going to argue. It works correctly.

An empty string (NULL) does not contain a terminal null. In my opinion, everything works there logically.


That's not the problem, the problem is that this code returns 4 and should return 0.

Print(StringToCharArray( "ABC", array, 0, 0));
Reason: