So I ask again, why do you have to rename the file? Just create it with the proper name to start with.
I am not trying to rename an extg. file. I've already created it with a proper name. but part of the name should be the date (which should be dynamically generated daily) - and for this reason, i'm hoping to generate this within the OnStart so that different functions doing different things can share the same filename. like a global variable.
But as i mentioned earlier, i discovered there's no way for OnStart to accept parameters nor can it return a result which i can assign to a variable....in my limited knowledge, i cannot find a way around this and so am stuck...
will very much appreciate just a point to the right direction.
Inside your function On start you assign the filename string to a global variable.
This gives you access to the filename. But to me it would be more of use to store the handle to the file which was opened in OnStart.
If you want to rename the file automatically, you will need to watch the date in your code and if it changes to the next day, you will have to close the current file, generate a new filename and open/create this new file. Then update the file handle with this newly opened file and all your functions would be writing to your new file.
Inside your function On start you assign the filename string to a global variable.
This gives you access to the filename. But to me it would be more of use to store the handle to the file which was opened in OnStart.
If you want to rename the file automatically, you will need to watch the date in your code and if it changes to the next day, you will have to close the current file, generate a new filename and open/create this new file. Then update the file handle with this newly opened file and all your functions would be writing to your new file.
thanks dominik but i dont quite understand how assigning a filename string to a global variable inside the OnStart will allow my other functions(outside OnStart) to access the filename since as i mentioned, in my limited knowledge, it seems OnStart does cannot output or return a variable which i can then assign to another outside itself nor can it accept parameters by reference. ...I am not trying to rename a file but trying to generate a filename dynamically daily with date as part of this filename. ....hope its ok to seek further clarification since it's fuzzy to me.
JimSingadventure #: i dont quite understand how assigning a filename string to a global variable inside the OnStart will allow my other functions(outside OnStart) to access the filename
If it is globally declared, every function as access. Learn to code.
servertime.day_of_week != 0 // ( not sunday please)
/* comments about mqldate time. use it in mql5 !!! comments all below:
MqlDateTime
The date type structure contains eight fields of the int type:
struct MqlDateTime { intyear; // Year intmon; // Month intday; // Day inthour; // Hour intmin; // Minutes intsec; // Seconds intday_of_week; // Day of week (0-Sunday, 1-Monday, ... ,6-Saturday) intday_of_year; // Day number of the year (January 1st is assigned the number value of zero) };
So I ask again, why do you have to rename the file? Just create it with the proper name to start with.
I am not trying to rename an extg. file. I've already created it with a proper name. but part of the name should be the date (which should be dynamically generated daily) - and for this reason, i'm hoping to generate this within the OnStart so that different functions doing different things can share the same filename. like a global variable.
But as i mentioned earlier, i discovered there's no way for OnStart to accept parameters nor can it return a result which i can assign to a variable....in my limited knowledge, i cannot find a way around this and so am stuck...
will very much appreciate just a point to the right direction.
thanks dominik but i dont quite understand how assigning a filename string to a global variable inside the OnStart will allow my other functions(outside OnStart) to access the filename since as i mentioned, in my limited knowledge, it seems OnStart does cannot output or return a variable which i can then assign to another outside itself nor can it accept parameters by reference. ...I am not trying to rename a file but trying to generate a filename dynamically daily with date as part of this filename. ....hope its ok to seek further clarification since it's fuzzy to me.
Don't Hijack other threads for your off-topic post. Next time, make your own, new, thread.
Don't post pictures of code, they are too hard to read.
Please edit your (original) post and use the CODE button (Alt-S)! (For large amounts of code, attach it.)
General rules and best pratices of the Forum. - General - MQL5 programming forum (2019)
Messages Editor
“Why this is false?” What is “this”.
Do you really expect an answer? There are no mind readers here and our crystal balls are cracked.
How To Ask Questions The Smart Way. (2004)
Be precise and informative about your problem
TimeToStruct(TimeCurrent(),servertime);
servertime.day_of_week != 0 // ( not sunday please)
/* comments about mqldate time. use it in mql5 !!! comments all below:
MqlDateTime
The date type structure contains eight fields of the int type:
struct MqlDateTime
{
int year; // Year
int mon; // Month
int day; // Day
int hour; // Hour
int min; // Minutes
int sec; // Seconds
int day_of_week; // Day of week (0-Sunday, 1-Monday, ... ,6-Saturday)
int day_of_year; // Day number of the year (January 1st is assigned the number value of zero)
};
*/
this is the basic function :
returned value (1 = Friday)One simple script for MT5 B and four questions & problems - General - MQL5 #81 (2023)
The code:
Startup Result:
Thanks bro :)