Hello everyone ,
i try for a couple of days to solve the following problem with no success , i will demonstrate it in the next lines in a concise and clear way as much as possible and hope to find an elegant solution.
so here we go , consider i have a multiple AFL files (for the sake of simplicity assume there are only 5 files) , each one of them have only one variable , let's call it "iso"
each file is named after its ordinal number (1.afl , 2.afl , .. , 5.afl) and the iso variable is equal to the oridinal number of the file in which it exist. (e.g iso in 3.afl would equal to 3)
now i try to use #include_once to fetch the content of each file , simply i want to get the value of iso in each file.
AFAIK there's no direct way to use a dynamic address path in front of #include so i pursued the following approach
My first approach was to use a dynamic string variable as in the following code
Color = IIf(Ref(C,-1) < C,colorCustom1,colorCustom2); SetBarFillColor(Color);
Plot(C,"Close",colorBlack, styleNoTitle | styleCandle );
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} - {{DATE}} Open %1.5f , Hi %1.5f , Lo %1.5f , Close %1.5f (%.1f%%) , Vol %s"+"\n"+"{{VALUES}}", O, H, L, C, SelectedValue(ROC(C,1)),NumToStr(V,1.00)));
//---------------------------------------------------------------------------------*/
Export_Triggers = ParamTrigger("Start Data Export To A Separate File","Execute");
//---------------------------------------------------------------------------------
iso = 00;
FH_Content =
AFL_Content = "";
//---------------------------------------------------------------------------------
if (Export_Triggers)
{
for (i = 01; i <= 5; i++)
{
//Source_Path = "F:\\ZZ\\T.afl";
AFL_Files_Path = "F:\\ZZ\\"+i+".afl";
//Indirective_Ref = "#"+"Include_Once \""+AFL_Files_Path+"\"";
FH = fopen(AFL_Files_Path , "r"); FH_Content = fgets(FH); fclose(FH);
//FH = fopen(Source_Path , "w"); fputs(FH_Content,FH); fclose(FH);
//FH = fopen(Source_Path , "w"); fputs(Indirective_Ref,FH); fclose(FH);
#pragma nocache
#include_once AFL_Files_Path
_TRACE("iso = "+iso+"\n");
}
}
My second approach was to use a static string variable that contain address path to a file named T.afl , that file nest #include with the desired path to files where iso variable exist
Color = IIf(Ref(C,-1) < C,colorCustom1,colorCustom2); SetBarFillColor(Color);
Plot(C,"Close",colorBlack, styleNoTitle | styleCandle );
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} - {{DATE}} Open %1.5f , Hi %1.5f , Lo %1.5f , Close %1.5f (%.1f%%) , Vol %s"+"\n"+"{{VALUES}}", O, H, L, C, SelectedValue(ROC(C,1)),NumToStr(V,1.00)));
//---------------------------------------------------------------------------------*/
Export_Triggers = ParamTrigger("Start Data Export To A Separate File","Execute");
//---------------------------------------------------------------------------------
iso = 00;
FH_Content =
AFL_Content = "";
//---------------------------------------------------------------------------------
if (Export_Triggers)
{
for (i = 01; i <= 5; i++)
{
Source_Path = "F:\\ZZ\\T.afl";
AFL_Files_Path = "F:\\ZZ\\"+i+".afl";
Indirective_Ref = "#"+"Include_Once \""+AFL_Files_Path+"\"";
FH = fopen(AFL_Files_Path , "r"); FH_Content = fgets(FH); fclose(FH);
//FH = fopen(Source_Path , "w"); fputs(FH_Content,FH); fclose(FH);
FH = fopen(Source_Path , "w"); fputs(Indirective_Ref,FH); fclose(FH);
#pragma nocache
#include_once Source_Path
_TRACE("iso = "+iso+"\n");
}
}
My third approach was to copy the content of each 5 files and paste it into T.afl
Color = IIf(Ref(C,-1) < C,colorCustom1,colorCustom2); SetBarFillColor(Color);
Plot(C,"Close",colorBlack, styleNoTitle | styleCandle );
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} - {{DATE}} Open %1.5f , Hi %1.5f , Lo %1.5f , Close %1.5f (%.1f%%) , Vol %s"+"\n"+"{{VALUES}}", O, H, L, C, SelectedValue(ROC(C,1)),NumToStr(V,1.00)));
//---------------------------------------------------------------------------------*/
Export_Triggers = ParamTrigger("Start Data Export To A Separate File","Execute");
//---------------------------------------------------------------------------------
iso = 00;
FH_Content =
AFL_Content = "";
//---------------------------------------------------------------------------------
if (Export_Triggers)
{
for (i = 01; i <= 5; i++)
{
Source_Path = "F:\\ZZ\\T.afl";
AFL_Files_Path = "F:\\ZZ\\"+i+".afl";
Indirective_Ref = "#"+"Include_Once \""+AFL_Files_Path+"\"";
FH = fopen(AFL_Files_Path , "r"); FH_Content = fgets(FH); fclose(FH);
FH = fopen(Source_Path , "w"); fputs(FH_Content,FH); fclose(FH);
//FH = fopen(Source_Path , "w"); fputs(Indirective_Ref,FH); fclose(FH);
#pragma nocache
#include_once Source_Path
_TRACE("iso = "+iso+"\n");
}
}
None of the above approach work as i trace iso and find it is value equal to zero (the initialized value in the beginning of the code) ,
at this stage i were overwhelmed and have exhausted all of my tricks so i decided to ask for help ,
what do you think about this kind of problems ? does it have a solution ?
Thank you for your patience.