请教:下面两个按钮属性含义?先谢谢!
下面的C语句其中:
“T_RECORD_1","day_1","time_hour_1","time_min_1","time_sec_1","T_CODE_1","T_VALVE_1",
共记100条(因为字数限制没有写全)
《数据保存》按钮鼠标动作
#include "apdefap.h"
void OnClick(char* lpszPictureName, char* lpszObjectName, char* lpszPropertyName)
{
static int recode=101;
float a[700];
static float v_record=0;
char *aa[700]={
"T_RECORD_1","day_1","time_hour_1","time_min_1","time_sec_1","T_CODE_1","T_VALVE_1",
};
int i;
int record;
time_t t;
struct tm tblock;
FILE *fp;
SetTagBit("ad1a1_1",1);
while(i<700)
{ a[i]=GetTagFloat(aa[i]); i++; }
fp = fopen("D:\\thj.txt","w+b");
if (fp==NULL)
{fclose(fp);
return ;}
for(i=0;i<700;i++)
{ if(fwrite(&a[i],sizeof(float),1,fp)!=1)
{fclose(fp);
return ;
}
}
fclose(fp);
fp = fopen("D:\\thj.bak","w+t");
for(i=0;i<700;i++)
fprintf(fp,"%f,",a[i]);
fclose(fp);
SetTagBit("ad1a1_1",0);
return ;
}
《数据输入》按钮鼠标动作
#include "apdefap.h"
void OnClick(char* lpszPictureName, char* lpszObjectName, char* lpszPropertyName)
{
static int recode=101;
float a[700];
static float v_record=0;
char *aa[700]={
"T_RECORD_1","day_1","time_hour_1","time_min_1","time_sec_1","T_CODE_1","T_VALVE_1",
};
int i;
int record;
time_t t;
struct tm tblock;
FILE *fp;
SetTagBit("ad1a2_1",1);
fp = fopen("d:\\thj.txt","r+w");
if (fp==NULL)
{
fclose(fp);
return;
}
for(i=0;i<700;i++)
{ fread(&a[i],sizeof(float),1,fp);
SetTagFloat(aa[i],a[i]); }
fclose(fp);
SetTagBit("ad1a2_1",0);
return ;
}
最佳答案
数据保存按钮
把700个浮点数变量aa[i]的数据保存到文本文件D:\\thj.txt中,同时保存个D:\\thj.bak备份
数据输入按钮
把文本文件D:\\thj.txt的记录取出并写的变量浮点数变量aa[i]中(700个数据)
说白了数据配方的保存和取出功能
提问者对于答案的评价:
您的提示,我明白了,问题解决了,谢谢
原创文章,作者:more0621,如若转载,请注明出处:https://www.zhaoplc.com/plc263215.html