Automatic Generation

9 Posts
4 Users
0 Likes
40 Views
ACHT
 ACHT
(@a-chaverotarcinfo-com)
Posts: 161
Reputable Member
Topic starter
 

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

 
Posted : 11/12/2015 3:43 pm
n.kunzer
(@n-kunzerarcinfo-com)
Posts: 1236
Member Moderator
 

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 

 
Posted : 15/12/2015 9:03 am
f.martin
(@f-martinarcinfo-com)
Posts: 148
Member Admin
 

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");
 
Posted : 15/12/2015 2:31 pm
(@r.buisson@arcinfo.com)
Posts: 0
New Member Guest
 

When do you implement the possibility to do this with a calendar and not by scada ??

Thanks

 
Posted : 17/12/2015 2:46 pm
n.kunzer
(@n-kunzerarcinfo-com)
Posts: 1236
Member Moderator
 

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

 
Posted : 17/12/2015 4:48 pm
(@s.epaillard@arcinfo.com)
Posts: 0
New Member Guest
 

"I think having a calendar component is on the pipe."

Finally! when?

 
Posted : 17/12/2015 4:53 pm
n.kunzer
(@n-kunzerarcinfo-com)
Posts: 1236
Member Moderator
 

Dunno...not official yet...
Don't have too much hope 🙂

 
Posted : 17/12/2015 4:55 pm
(@s.epaillard@arcinfo.com)
Posts: 0
New Member Guest
 

pffff I don't understand how we can work without this kind of component....

 
Posted : 17/12/2015 4:58 pm
n.kunzer
(@n-kunzerarcinfo-com)
Posts: 1236
Member Moderator
 

I agree. Should be very good having it!
At least the library could give us time to wait the component...

 
Posted : 17/12/2015 5:03 pm