This topic to present SCADA BASIC script to generate Export.
Result :
-One export per day with first day of month to now. All day previous export is erased.
-One export the first of the month containing datas from first of previous month to now
Sub MENSUEL()
Dim StartDate as Double;
Dim EndDate as Double;
Dim FileName as Str;
If (DATETIME("DAY")==1) Then 'Premier du mois
If (DATETIME("MONTH")==1) Then 'Premier janvier
StartDate = DateTimeValue(1, 12, DATETIME("YEAR")-1, 8, 0, 0 ); 'Export du mois pr‚cedent le 01/01
FileName = ADDSTRING("BILANS-",TOC(DATETIME("YEAR")-1));
FileName = ADDSTRING(FileName,"-12");
FileName = ADDSTRING(FileName,".xlsx");
Else
StartDate = DateTimeValue(1, DATETIME("MONTH")-1, DATETIME("YEAR"), 8, 0, 0 ); 'Export du mois pr‚cedent le 1 du mois
FileName = ADDSTRING("BILANS-",TOC(DATETIME("YEAR")));
FileName = ADDSTRING(FileName,"-");
FileName = ADDSTRING(FileName,TOC(DATETIME("MONTH")-1));
FileName = ADDSTRING(FileName,".xlsx");
End If
Else
StartDate = DateTimeValue(1, DATETIME("MONTH"), DATETIME("YEAR"), 8, 0, 0 ); 'Export du mois en cours n'importe quel jour du mois en cours
FileName = ADDSTRING("BILANS-",TOC(DATETIME("YEAR")));
FileName = ADDSTRING(FileName,"-");
FileName = ADDSTRING(FileName,TOC(DATETIME("MONTH")));
FileName = ADDSTRING(FileName,".xlsx");
End If
EndDate = DATETIMEVALUE(DATETIME("DAY"),DATETIME("MONTH"), DATETIME("YEAR"), 8, 0, 0);
EXPORT("GENERATE_DATES", "BILANS", "BILANS", FileName, StartDate, EndDate);
End Sub
Just change layout and english comments
Sub MONTHLY()
Dim StartDate as Double;
Dim EndDate as Double;
Dim FileName as Str;
If (DATETIME("DAY")==1) Then '1rst day of month
If (DATETIME("MONTH")==1) Then '1rst January
StartDate = DateTimeValue(1, 12, DATETIME("YEAR")-1, 8, 0, 0 ); 'Export of previous month the 01/01
FileName = ADDSTRING("BILANS-",TOC(DATETIME("YEAR")-1));
FileName = ADDSTRING(FileName,"-12");
FileName = ADDSTRING(FileName,".xlsx");
Else
StartDate = DateTimeValue(1, DATETIME("MONTH")-1, DATETIME("YEAR"), 8, 0, 0 ); 'Export of previous month the 1rst of month
FileName = ADDSTRING("BILANS-",TOC(DATETIME("YEAR")));
FileName = ADDSTRING(FileName,"-");
FileName = ADDSTRING(FileName,TOC(DATETIME("MONTH")-1));
FileName = ADDSTRING(FileName,".xlsx");
End If
Else
StartDate = DateTimeValue(1, DATETIME("MONTH"), DATETIME("YEAR"), 8, 0, 0 ); 'Export of current month to any day of this month
FileName = ADDSTRING("BILANS-",TOC(DATETIME("YEAR")));
FileName = ADDSTRING(FileName,"-");
FileName = ADDSTRING(FileName,TOC(DATETIME("MONTH")));
FileName = ADDSTRING(FileName,".xlsx");
End If
EndDate = DATETIMEVALUE(DATETIME("DAY"),DATETIME("MONTH"), DATETIME("YEAR"), 8, 0, 0);
EXPORT("GENERATE_DATES", "BILANS", "BILANS", FileName, StartDate, EndDate);
End Sub
And thanks to the Service team, since version 11.1.5002, the ADDSTRING method can have up to 10 parameters...
FileName = ADDSTRING("BILANS-",TOC(DATETIME("YEAR")));
FileName = ADDSTRING(FileName,"-");
FileName = ADDSTRING(FileName,TOC(DATETIME("MONTH")));
FileName = ADDSTRING(FileName,".xlsx");
can be replaced by
FileName = ADDSTRING("BILANS-", TOC(DATETIME("YEAR")), "-", TOC(DATETIME("MONTH")), ".xlsx");
When do you implement the possibility to do this with a calendar and not by scada ??
Thanks
Hi Romain,
Who is "you" ?
I think having a calendar component is on the pipe. But this calendar won't probably generate ax export.
For information, we did in Malaysia (thanks Abdul!) a library allowing a user generating exports easily.
This library will be tested in qualification and should be integrated in 11.2
If you want to test it and give a feedback (as I encourage you) you can ask Abdul to send you the package.
Nico
"I think having a calendar component is on the pipe."
Finally! when?
Dunno...not official yet...
Don't have too much hope 🙂
pffff I don't understand how we can work without this kind of component....
I agree. Should be very good having it!
At least the library could give us time to wait the component...


