module / include

 

Hi,


till now, one of my scripts imported several ex4 modules written by myself but today I wondered why I am doing this...

I mean, is it important for code protection? AFAIK, you could just publish the one big compiled ex4 module which includes all the other mqh's...Till now, I had to publish the main ex4 and the other ex4's which are imported by the main module...

Today I came across GetLastError() only working within one module and I am considering converting the ex4s into mqh's and then including them into the main ex4 only publishing the main ex4...

I have the strange feeling that I am missing sth...

Is it really possible and recommendable?

Is it harder to crack several smaller ex4 than one huge ex4 which includes mqh's?

I mean, there certainly are huge differences between these two models that I am aware of but there certainly are some advantages like having the one global lastErrorVariable and having access to the same variables etc.


Thanks for your tips,


Daniel.

 

well, I just use masses of includes - makes for reusable code - is personal perhaps.

but... I really do hate globals - they have danger written all over them!

externals are reqd evil... but rest of my code I do upmost to make so single function and blackbox that globals just not needed, also formals are minimal due to my brand of KISS design.

code hacking?

from what I see, is beyond easy. personally, never understood the paranoia... most people will vote with their wallet IF the product is any good and if not they start acting like idiots and hacking etc.

at end of day - is individual/kinda the ethos of masses that dictates actions...

if can crack one, can crack all, yes?

if MT does #include as per 'wat I grew up on', then is simple "ooooh ah - an include decl, better make "this source code file" my main input stream, and let's all repeat until start unwinding via EOF markers..." just like recursion! eventually always end back at base/root/whatever (if don't then get out yer worry beads ! :)

so, I'd expect end product .ex4 to not really have any info bout 'how' it was formed - eg, I am therefore I exist... just summation of many bits - just like if one massive monolithic (errrr... old style programming gunk :) ten billion line source file.

I wait patiently for OOPs gunk to arrive - then can be more happy with blackbox paradigm...

hahaaa - globals give me instant sweats - guaranteed - LOL

but... i have an int gError; that use instead of last_error since is transient one-shot destructive read goodie - i not like that at all. So all my code is guaranteed access 1 or 100 times to that last error code. ie, when trade op or actually, any builtin that can have return status is called and it decides to throw wobbly, gError <- GetLastError(); no messin around - so guess in this instance, gotta love globals - lol



You remember old concept of data sharing? Common attribute? Can not one have, like stdlib.mqh/.ex4 which [of course :] everybody uses for "string ErrorDescription(int error_code);"

Could use this idea for simple little file having build Common declarations. Ever notice the "loading stdlib.ex4" or whatever the exact text is, on Experts tab?

I always get that when my first [of many - lol] error messages start to appear. the code not needed till ref'd then is sucked into memory. Not relevant to the above idea, just an aside...

anyway, all your .ex4's could build with this Common ref. just like we do with "#include <stdlib.mqh>" which is nuffin more than hdr file really - check it out in includes dir.

just idea... insane? who knows, but IF dead set on having global functionality btwn .ex4's then maybe is idea

edit.1 maybe another analogy/should of said: Common memory resident data segment... now that is going back a bit. but was cool cuz zillions of team members could all hack away in their own little universes and reference identifiers actually built into this common segment. - just a biggie declarations file (usually native machine code decs...), compiled/assembled and then linked etc to form a loadable chunk that stayed in predefined memory address range. Then all the other separately compiled progies were linked to this common segment - like dll fixup or windoz kludge stuff I guess. So... as long as remembered to load the data segment with this file... hey presto! End result is external refs were mapped to correct memory locs. Well, that's what I meant I guess - do same type idea using mechanism that stdlib uses... ok?


ah man, this thread might get interesting once I go away - hope some bright sparks input, yes?

this is all interesting stuff !

:o))



regards D

 

Hi Ukt,


thanks for this elaborated answer. I do have trouble getting the gist of what you're saying though :/

Certainly I do use mqh's for making the declarations for my imports but since I figured I do not have to deliver the mqh's since it's build into the compiled code I don't see any necessity of importing rather than including...

For the global stuff, I really do not like it either, don't intend to use it. But GetLastError() is called by my LoggingEngine which is another module than the one having started the Engine so we cannot log the errors caused by the module calling the LogStuff, we have to pass the error as param to the function which is somewhat annoying...

I guess I will try using includes rather than imports...Maybe I am seeing what I missed before then.

 

yes, excuse my drivel... not help does it?

btw - i got started again and decided to delete text - no point really, just loose more time and get me and you more confused.

in the end, you have the answer, yes? is called function interface design...

am sure you make decision best for you

regards

 

well, ukt, the thing is that I really appreciate your brainStorming way of writing, I only often don't understand it _unfortunately_. Probably it's because English is not my native tongue either and I am not really coming from a programming background...So please keep writing what you're thinking, hopefully I get used to it and understand it.

I _really_ did not mean to discourage you!

 

naw... no probs friend! you good dude cuz you take time to reply - tbh, a reply is gold to me :)

know wat mean? some ask, ask, ask... never return to give. ok, is life for sure but still cause me ache in head. I to soft, not mean to ramble all time cuz it for sure takes time! gotta get hard! yeah... that's it! concrete is me ;o))

i am stuck in pretty low level kinda work methods with mt - why? well, for my sins, not really place faith in indicators as we talk history if use indicators, yes?

dead data - mean nuffin cept maybe clue but is essentially dead/past/not gonna stop hail storms over wheat crops in next few hours is it?

i wrote some other post somewhere here - relates trader i know, price action only... watch candle as grow/shrink etc. makes solid repeatable weekly pips on manual screen time only trades.

my mind says YES... EA,EA,.... but not so easy is this EA thingy - anyway, keep thinking and maybe i also get so EA can do as this trader does....

ah man... is amazing all this stuff, love and hate same time - lol

i do in own way shout at support BUT i again reaffirm my honest thankyous to MetaQuotes - they offer world, tools to attempt.... the impossible (teehee)

best to you Daniel - a good dude U B!

;-)

 
I did send you an eMail btw, did you receive it?
 

hi D, I go look, get 100's incoming hostiles per day + waaaay too many adrs = needs be sorted else i really start loose plot - lol

gimme couple ticks ok?

thanks 4 email wat not got/seen yet ;o)


edit.1 oky doky ... amaizin i find - i compose and send - thank you vmuch