Примеры
использования функций API |
Например мы должны создать ежедневный отчет, содержащий тревоги, возникавшие в течение дня. Тревоги будут перечислены в текстовом файле, в строках которого будут представлены дата и время события. ALARMS.TXT: .... 1/2/2001 09:16:58 1/2/2001 09:19:26 1/2/2001 09:21:39 1/2/2001 09:21:59 1/2/2001 09:22:19 1/2/2001 09:22:40 1/2/2001 09:23:00 .... This file describe how report will be. Этот файл описывает, каким будет отчёт ALARMS.RTF: ALARMS FOUND: {InsertAlarms()} Это — функция, вызванная в отчете: ALARM.WLL: Function void InsertAlarms() string line; int hh; int mn; int ss; int yy; int mm; int dd; int h1; int m1; int s1; int h2; int m2; int s2; int a; int i=0; int h=FileOpen("E:\ALARMS:TXT","rt"); While (FileEOF(h) == 0) line=FileReadLn(h); i=i+1; if (FileEOF(h) == 0) then ReportInsertText("Alarms at: "+line+Eol()); // convert date and time from text to numerical values a=StrPos(line,"/"); dd=StrToInt(StrSubString(line,1,a-1)); line=StrDelete(line,1,a); a=StrPos(line,"/"); mm=StrToInt(StrSubString(line,1,a-1)); line=StrDelete(line,1,a); a=StrPos(line," "); yy=StrToInt(StrSubString(line,1,a-1)); line=StrDelete(line,1,a); a=StrPos(line,":"); hh=StrToInt(StrSubString(line,1,a-1)); line=StrDelete(line,1,a); a=StrPos(line,":"); mn=StrToInt(StrSubString(line,1,a-1)); line=StrDelete(line,1,a); // making a time range starting 30" before and ending 30" after ss=StrToInt(line); s1=ss-30; m1=mn; h1=hh; if (s1<0) then s1=60+s1; m1=m1-1; if (m1==-1) then m1=59; h1=h1-1; if (h1<0) then h1=23; end end end s2=s1; m2=m1+1; h2=h1; if (m2==60) then m2=0; h2=h2+1; if (h2==24) then h2=0; end end ChartSetTimeRange(dd,mm,yy,h1,m1,s1,dd,mm,yy,h2,m2,s2); //da -30" a +30" // insert chart that show the problem found ReportInsertTemplate("AlarmChart"); // template previously inserted AlarmChart // contains only one chart object that show the gates where problems were found ReportInsertText(Eol()+Eol()+Eol()+Eol()); end end FileClose(h); end
Получившийся в конце дня отчёт может походить на это: ALARMS.001:
|