karlek
Member
Hello to everyone,
I am trying to achieve simple writing of a string to a text file in TwinCAT. The code I am using can be found below. Problem is that fPuts FB call gives me an error code 0x703 ("Unknown or invalid nMode or ePath parameter."). Beckhoff online documentation states that for using FB_FilePuts "The file must previously have been opened in the text mode." So where am I making a mistake?
Thank you in advance
PROGRAM MAIN
VAR
anInput1 AT %I* : INT;
napon : INT;
cb1anIn1 AT %Q* : BYTE:=1;
otvoriDatoteku : FB_FileOpen;
zatvoriDatoteku : FB_FileClose;
fPuts : FB_FilePuts;
hFile : UINT;
bFileOpen : BOOL;
bFileOpenBusy : BOOL;
bFileOpenError : BOOL;
nFileOpenErrId : UDINT;
bFileCloseBusy : BOOL;
bFileCloseError : BOOL;
nFileCloseErrId : UDINT;
bFilePuts : BOOL;
bFilePutsBusy : BOOL;
bFilePutsError : BOOL;
nFilePutsErrId : UDINT;
END_VAR
otvoriDatoteku(bExecute:=FALSE);
otvoriDatoteku(
sNetId:='5.11.48.178.1.1',
sPathName:='c:\TestFile.txt',
nMode:=FOPEN_MODEAPPEND OR FOPEN_MODETEXT,
ePath:=PATH_GENERIC,
bExecute:=TRUE,
bBusy=>bFileOpenBusy,
bError=>bFileOpenError,
nErrId=>nFileOpenErrId);
hFile:=otvoriDatoteku.hFile;
fPuts(bExecute:=FALSE);
fPuts(
sNetId:='5.11.48.178.1.1',
hFile:=hFile,
sLine:='linija1$L',
bExecute:=TRUE,
bBusy=>bFilePutsBusy,
bError=>bFilePutsError,
nErrId=>nFilePutsErrId);
zatvoriDatoteku(bExecute:=FALSE);
zatvoriDatoteku(
sNetId:='5.11.48.178.1.1',
hFile:=hFile,
bExecute:=TRUE );
I am trying to achieve simple writing of a string to a text file in TwinCAT. The code I am using can be found below. Problem is that fPuts FB call gives me an error code 0x703 ("Unknown or invalid nMode or ePath parameter."). Beckhoff online documentation states that for using FB_FilePuts "The file must previously have been opened in the text mode." So where am I making a mistake?
Thank you in advance
PROGRAM MAIN
VAR
anInput1 AT %I* : INT;
napon : INT;
cb1anIn1 AT %Q* : BYTE:=1;
otvoriDatoteku : FB_FileOpen;
zatvoriDatoteku : FB_FileClose;
fPuts : FB_FilePuts;
hFile : UINT;
bFileOpen : BOOL;
bFileOpenBusy : BOOL;
bFileOpenError : BOOL;
nFileOpenErrId : UDINT;
bFileCloseBusy : BOOL;
bFileCloseError : BOOL;
nFileCloseErrId : UDINT;
bFilePuts : BOOL;
bFilePutsBusy : BOOL;
bFilePutsError : BOOL;
nFilePutsErrId : UDINT;
END_VAR
otvoriDatoteku(bExecute:=FALSE);
otvoriDatoteku(
sNetId:='5.11.48.178.1.1',
sPathName:='c:\TestFile.txt',
nMode:=FOPEN_MODEAPPEND OR FOPEN_MODETEXT,
ePath:=PATH_GENERIC,
bExecute:=TRUE,
bBusy=>bFileOpenBusy,
bError=>bFileOpenError,
nErrId=>nFileOpenErrId);
hFile:=otvoriDatoteku.hFile;
fPuts(bExecute:=FALSE);
fPuts(
sNetId:='5.11.48.178.1.1',
hFile:=hFile,
sLine:='linija1$L',
bExecute:=TRUE,
bBusy=>bFilePutsBusy,
bError=>bFilePutsError,
nErrId=>nFilePutsErrId);
zatvoriDatoteku(bExecute:=FALSE);
zatvoriDatoteku(
sNetId:='5.11.48.178.1.1',
hFile:=hFile,
bExecute:=TRUE );