WINCC中倒计时的实现

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

[精] 主题:回复:求助:倒计时!
*采用VBS的时间函数:
如果以天计算倒计时
Dim days = DateDiff("d",Now,DateSerial(2008, 10, 1))
则返回从现在到2008年10月1日间隔多少天。

*DateAdd(interval, number, date),两个时间相加。

如NewDate = DateAdd("m", 1, "31-Jan-95")
*DateDiff(interval, date1, date2 [,firstdayofweek[, firstweekofyear]])两个时间相减。

如:Function DiffADate(theDate)
DiffADate = "Days from today: " & DateDiff("d", Now, theDate)
End Function
*DatePart(interval, date[, firstdayofweek[, firstweekofyear]])给出某个时间的特定时间,比如给出某个时间的年,月,日等。

Function GetQuarter(TheDate)
GetQuarter = DatePart("q", TheDate)
End Function
WINCC中读取写字符串文本文件的步骤。

1,写字符串到文本文件中去:
{
FILE* pFile2=NULL;
pFile2=fopen("D:\\ww.txt","w");
rewind(pFile2);
fprintf(pFile2,"%s\n",GetTagChar("string2")); 将变量string2写到文本文件ww.txt中。

fclose(pFile2);
}
2,从文本文件中读字符串到变量中去:
{
FILE * pFile;
float temp;
char *tt;
char t[10];
char w[10];
pFile=fopen("D:\\ww.txt","r");
//rewind(pFile);
if (pFile!=NULL)
{tt=fgets(t ,10,pFile);
strncpy(&w[0],&t[0],strlen(&t[0])-1);
SetTagChar("string2",w); 从ww.txt文本中把字符串读到变量string2中。

}
fclose(pFile);
}
3读文本文件中的字符串到变量
FILE * pFile;
char temp;
pFile=fopen("D:\\tt.txt","r");
rewind(pFile);
fscanf(pFile,"%s\n",&temp);
SetTagChar("time",&temp); //Return-Type: BOOL
pFile=fopen("D:\\dayDiff.txt","r");
rewind(pFile);
fscanf(pFile,"%s\n",&temp);
SetTagChar("AccTime",&temp); //Return-Type: BOOL fclose(pFile);。

相关文档
最新文档