发布日期:2022-04-26 点击率:313
<script
var cpro_id = "u1457042"; <iframe id="iframeu1457042_0" qctm?rdid=1457042&dc=2&di=u1457042&dri=0&dis=0&dai=3&ps=425x362&dcb=BAIDU_SSP_define&dtm=BAIDU_DUP_SETJSONADSLOT&dvi=0.0&dci=-1&dpt=none&tsr=0&tpr=1459707669697&ti=%E6%80%8E%E4%B9%88%E8%AE%BE%E7%BD%AE%E5%AF%BC%E5%87%BA%E5%8F%98%E9%87%8F%E7%9A%84TXT%E6%96%87%E4%BB%B6%E8%B7%AF%E5%BE%84%E5%90%8D_%E7%94%B5%E6%B0%94%E8%87%AA%E5%8A%A8%E5%8C%96%E6%8A%80%E6%9C%AF%E7%BD%91&ari=1&dbv=0&drs=1&pcs=645x335&pss=970x426&cfv=0&cpl=22&chi=50&cce=true&cec=gbk&tlm=1402385675<u=http%3A%2F%2Fwww.dqjsw.com.cn%2Fdiangongdianzi%2Fdianlidiangong%2F79135.html&ecd=1&psr=1366x768&par=1366x728&pis=-1x-1&ccd=24&cja=false&cmi=34&col=zh-CN&cdo=-1&tcn=1459707670&qn=2911babf353785cf&tt=1459707669670.193.303.304" vspace="0" hspace="0" marginwidth="0" marginheight="0" scrolling="no" style="border:0; vertical-align:bottom;margin:0;" allowtransparency="true" align="center,center" width="200" height="200" frameborder="0"> |
问:我用C 脚本使内部变量保存在一个名字为“name”的txt 文档里,这样重新启动时也可以显示其保存值,而不是初始值。
但是这个txt 文档的路径名不知道改怎么设定,其默认的文件路径为:C:WINDOWSsystem32
请问该怎么设置路径名?
我的程序如下:程序里并没有设置路径的语句。
#include "apdefap.h"
void onClick(char* lpszPictureName, char* lpszObjectName, char* lpszPropertyName)
{
#define MaxLineLength 80
FILE *fpFile;
char *strTag[5] = { "TagA", "TagB", "TagC", "TagD", "TagE" };
char *pTmp;
char buffer[MaxLineLength];
double dVal;
int i;
fpFile = fopen(GetTagChar("Filename"), "w+" ); //open file to write
printf ("C-script: write file: %s
", GetTagChar("Filename"));
if (fpFile !=NULL)
{
for (i=0; i<=4; i++){
dVal = GetTagDouble(strTag[i]);
sprintf(buffer, "%s;%lf
", strTag[i],dVal);
// Search for '.' and replace with ','
pTmp = strchr(buffer, (int)'.');
if (pTmp != NULL){
*pTmp = ',';
}
fputs(buffer,fpFile);
printf("%s
", buffer);
}
fclose(fpFile); //close file
} else {
printf ("Error: File not found!
");
}
}
答:fpFile = fopen(GetTagChar("Filename"), "w+" ); //open file to write
这条语句中可以看到路径存放在变量名为Filename的字符串变量中,你在TAG Management中查找下该变量。或者在Global script中找找,也有可能是全局变量。
嫌麻烦的话直接改成:
fpFile = fopen("D:\Filename.txt"), "w+" ); //open file to write
下一篇: PLC、DCS、FCS三大控
上一篇: 索尔维全系列Solef?PV