Libraries: File Mapping without DLL - page 4

 
sergeev:
treat them as a long variable of sizeof(<Type>)*<Number_Elements> and everything will work out :)
So this class is needed to transfer only a pointer? I thought it was possible to use arrays at once :(
 
baramantan:
So this class is needed to transfer a pointer only? I thought it was possible to use arrays at once :(
did you even realise what you were asking? :)
 
sergeev:
treat them as a long variable of sizeof(<Type>)*<Number_Elements> and everything will work out :)

void OnStart()
{
CMemMapFile hmem;
int err=hmem.Open("Local\\\\test",111,modeCreate);

int data[];
ArrayResize(data,50);

err=hmem.Write(data,ArraySize(data)*sizeof(int));

ArrayInitialize(data,0);
hmem.Seek(0,SEEK_SET);
err=hmem.Read(data, ArraySize(data)*sizeof(int) );


hmem.Close();
}

Did I do it right? If not, what is wrong?

 

baramantan:

Did I do it right?
Ask Debug. He knows 100%.
 
sergeev:
Ask debag. He knows 100%.

And why do you have to respond to my post by shifting arrows?

Can you show by example how to pass an array int or double?

 

How will you check it if you don't even have debug? Are you used to study computer science on a blackboard without a computer at school?

If you want details and examples, read MSDN.


In general, people can be impudent. They have already transferred everything to MQL and chewed it all up with comments,
so for them to write functions for their slivators as well :) it turns out to be strange.

;)

 
sergeev:

How will you check it if you don't even have debug? Are you used to study computer science on a blackboard without a computer at school?

If you want details and examples, read MSDN.


In general, people can be impudent. They have already transferred everything to MQL and chewed it all up with comments,
so for them to write functions for their slivators as well :) it turns out to be strange.

;)

Now I don't understand why you got into my posts with my questions - if you don't want to answer them in substance? I'm shocked, editorial staff!
 

Well, I'll answer my own questions. I had to pick up this half-finished, undercooked product.

This class cannot handle int and double arrays for a very simple reason.

The declared function cannot accept arrays of int or double types. The class can only handle uchar " virtual int Write(const uchar &buf[],int sz); // write the specified number of bytes into memory "

I've forged the recipe to finalise it for my needs, I'm posting what I got, you can only pass int arrays. If the author doesn't finalise his creation, I'll post my own later.

Files:
MemMapLib.mqh  17 kb
MemMap.mq5  2 kb
 
baramantan:

I'll answer my own questions. I had to do some digging

so I fulfilled my goal :)

This class cannot accept int and double arrays for a very simple reason.
The declared function cannot accept arrays of int or double type.

Well, it's an obvious truth. It accepts uchar, not <some_needed_type>.

In the same way you can demand from this, as you put it, "semi-finished product" to save an array of structures with strings. Stomping your foot - why the author didn't anticipate the "data format I need".

But you were given one universal function. less than a byte there is nowhere to split. That's why it is stored.

Since any data type can be translated into uchar array (read bytes), it is the most universal for such a class.

I cobbled the recipe to finalise it for my needs, I'm posting what I got, you can only pass int arrays.

It was with uchar, now it is with int.

yes. progress :)
 
sergeev:

so I've fulfilled my goal :)

Well, it's an obvious truth. it accepts uchar, not <some_necessary_type>.

In the same way you can demand from this, as you put it, "semi-finished product" to save an array of structures with strings. Stomping your foot - why the author didn't anticipate the "data format I need".

But you were given one universal function. less than a byte there is nowhere to split. That's why it is stored.

Since any data type can be translated into uchar array (read bytes), it is the most universal for such a class.

It was uchar, now it's int.

yeah. progress :))

I'm not a mega programmer, of course. But I don't understand where universality is? uchar can't be universal because it limits the user, namely: uchar is only for positive values. The minimum value is zero, the maximum value is 255.

Any data beyond the value of uchar becomes equal to the maximum or minimum value of uchar.

Based on what I said, I asked from the beginning "how to pass int or double". I don't understand your point, chief.