Errors, bugs, questions - page 3138

 
Valeriy Yastremskiy #:

The dimensionality of a static array is a constant, not an int.

Sorry, I answered without checking.

I join the question, constant static int, ushort, the effect is the same, although in help:

Variables

Array index can only be an integer.

Forum on trading, automated trading systems & strategy testing

Bugs, bugs, questions

x572intraday, 2022.01.08 20:44

   int dim=5;
   int Arr1[5];// OK
   int Arr2[dim];// '[' - invalid index value

Either I'm totally fucked up, or if not a bug, poke a swat in the Help.


 
Valeriy Yastremskiy #:

Sorry, answered without checking.

I join the question, constant static wint, ushort effect is the same, although in the help:

Variables

Only an integer can be an array index.


The answer was almost correct. A variable is not a constant.

 
Valeriy Yastremskiy #:

Sorry, answered without checking.

I join the question, constant static wint, ushort effect is the same, although in help:

Variables

Only an integer can be an array index.


Instead of

int dim=5;

put at the top of the program.

#define  dim 5
But personally I find this... not so much as a crutch, but a kind of not very convenient alternative to the desirable, but not working and not feasible, original option.
 
Alexey Viktorov #:

The answer was almost correct. A variable is not a constant.

I.e. declaring a constant integer variable is not a constant?

 
x572intraday #:

Instead of

put at the top of the program

But personally, I find this... not as a crutch, but as a not very convenient alternative to a desirable, but unworkable and unrealizable original variant.

Well substitution is different, of course instead of dim by substituting an integer the compiler swallows.

 
Valeriy Yastremskiy #:

I.e. declaring a constant integer variable is not a constant?

A constant variable is not a constant value. The keyword is variable.
 
Alexey Viktorov #:
A constant variable is not a constant value. The keyword is variable.
Thank you, that makes more sense)
 

I understand why, but there is very little information on IsStopped() in Help. I would like more details:

  1. Is there any sense in shoving it into all loops in a row? Or are there situations when it's not necessary to do it all over again? Or, for better safety, should we add them everywhere? I suspect that the function is most useful inhigh-loaded loops, for example, when trying a huge rates_total in small TFs, when trying a large number of graphical objects, etc.?
  2. Where else, besides loops, can/should I shove it? I haven't seen any examples, except for cycles, anywhere else.
 
x572intraday #:

I understand why, but there is very little information on IsStopped() in Help. I would like more details:

  1. Is there any sense in shoving it into all loops in a row? Or are there situations when it's not necessary to do it all over again? Or, for better safety, should we add them everywhere? I suspect that the function is most useful inhigh-loaded loops, for example, when trying a huge rates_total in small TFs, when trying a large number of graphical objects, etc.?
  2. Where else, besides loops, can/should I shove it? I haven't seen any examples, except for loops.

This is most often used in loops where you can accidentally get an infinite loop. Or intentionally looped in a script or service.

 

Why cant we do this?

void OnStart()
  {
   TFunc f = someFunction;
  }

class Test
  {
  } ;
typedef void (*TFunc)(Test*);
void someFunction(Test &a)  { }



cannot cast function 'someFunction' to type 'TFunc'


Reason: