Hi
I want to create, open, write and close a .txt file. And it works fine. BUT I can't do it again. I have to reactive the hole system before I can do it again.
I'm not an experienced programmer.
Any thoughts?
/David
------Code--------
FUNCTION_BLOCK FB_savefile
VAR
fbFileWrite : FB_FileWrite;
fbclose : FB_FileClose;
fbfileopen : FB_FileOpen;
Pathname: STRING;
initierat: BOOL := FALSE;
END_VAR
IF (runs > 1)
THEN Pathname := concat(concat(concat('c:\dill\',firstrun),startdatestr),'.txt');
ELSE Pathname := concat(concat('c:\dill\',firstrun),'.txt');
END_IF
IF (initierat = FALSE)
THEN fbfileopen(sNetId := '169.254.182.198.1.1', sPathName := Pathname,
ePath := PATH_GENERIC, nMode := FOPEN_MODEWRITE OR FOPEN_MODETEXT, bExecute := TRUE);
END_IF
IF (fbfileopen.bBusy = FALSE AND fbfileopen.bExecute = TRUE)
THEN fbfileopen.bExecute := FALSE;
hFiledill := fbfileopen.hFile;
initierat := TRUE;
END_IF
fbfilewrite.bExecute := FALSE;
IF (skrivarray = TRUE AND fbfileopen.bExecute = FALSE)
THEN fbfilewrite(sNetId := '169.254.182.198.1.1', hFile := hfiledill,
pWriteBuff := ADR(arr2), cbWriteLen := SIZEOF(arr2),
bExecute := TRUE);
END_IF
IF (fbfilewrite.bBusy = FALSE AND fbfilewrite.bExecute = TRUE)
THEN fbfilewrite.bExecute := FALSE;
fbclose.bExecute := FALSE;
fbclose(sNetId := '169.254.182.198.1.1', hfile := hfiledill, bExecute := TRUE);
hFiledill := 0;
END_IF
IF (fbclose.bBusy = FALSE AND fbclose.bExecute = TRUE)
THEN fbclose.bExecute := FALSE;
initierat := FALSE;
skrivarray:= FALSE;
END_IF
-------------------------------------
I want to create, open, write and close a .txt file. And it works fine. BUT I can't do it again. I have to reactive the hole system before I can do it again.
I'm not an experienced programmer.
Any thoughts?
/David
------Code--------
FUNCTION_BLOCK FB_savefile
VAR
fbFileWrite : FB_FileWrite;
fbclose : FB_FileClose;
fbfileopen : FB_FileOpen;
Pathname: STRING;
initierat: BOOL := FALSE;
END_VAR
IF (runs > 1)
THEN Pathname := concat(concat(concat('c:\dill\',firstrun),startdatestr),'.txt');
ELSE Pathname := concat(concat('c:\dill\',firstrun),'.txt');
END_IF
IF (initierat = FALSE)
THEN fbfileopen(sNetId := '169.254.182.198.1.1', sPathName := Pathname,
ePath := PATH_GENERIC, nMode := FOPEN_MODEWRITE OR FOPEN_MODETEXT, bExecute := TRUE);
END_IF
IF (fbfileopen.bBusy = FALSE AND fbfileopen.bExecute = TRUE)
THEN fbfileopen.bExecute := FALSE;
hFiledill := fbfileopen.hFile;
initierat := TRUE;
END_IF
fbfilewrite.bExecute := FALSE;
IF (skrivarray = TRUE AND fbfileopen.bExecute = FALSE)
THEN fbfilewrite(sNetId := '169.254.182.198.1.1', hFile := hfiledill,
pWriteBuff := ADR(arr2), cbWriteLen := SIZEOF(arr2),
bExecute := TRUE);
END_IF
IF (fbfilewrite.bBusy = FALSE AND fbfilewrite.bExecute = TRUE)
THEN fbfilewrite.bExecute := FALSE;
fbclose.bExecute := FALSE;
fbclose(sNetId := '169.254.182.198.1.1', hfile := hfiledill, bExecute := TRUE);
hFiledill := 0;
END_IF
IF (fbclose.bBusy = FALSE AND fbclose.bExecute = TRUE)
THEN fbclose.bExecute := FALSE;
initierat := FALSE;
skrivarray:= FALSE;
END_IF
-------------------------------------