FB_FileOpen twincat

Join Date
Feb 2009
Location
Ant
Posts
54
Hi guys,

I get an 'Identifier expected' error on this line
Code:
fbFileOpen(' ','Hard Disk\My_Projects\Tilt6_1.txt',FOPEN_MODEREAD OR FOPEN_MODEBINARY,bFileOpen:=TRUE,Timeout);

I did it by the twincat book?
 
Here's an example I found via google:

Code:
fbFileOpen( 	sNetId := destNetId,
			sPathName := destFileName,
			nMode := FOPEN_MODEWRITE OR FOPEN_MODEBINARY,
			ePath := PATH_GENERIC,
			tTimeout := tAdsTimeout,
			bExecute := TRUE );
 
Could you get the error because there is a space in your code where an empty string is expected? If I am not mistaken, many TwinCAT functions need either an AMS net ID for the controller to perform the operation on or an empty string for the local one. Just guessing here.

Code:
fbFileOpen(' ',
 
LadderLogic, I tried it with '' but the compiler still expect an Identifier?

Maybe the timeout give some problem?

The book is just the 'info sys' site from beckhoff.
 
Last edited:
Still dont get it. I have the same identifier
"bFileOpen:=TRUE" or "bFileOpen=TRUE" gives no effect.

PROGRAM PLC_Files
VAR
fbFileOpen : FB_FileOpen;
bFileOpen : BOOL;
bFileOpenBusy : BOOL;
bFileOpenError : BOOL;
nFileOpenErrId : UDINT;
hFile : UINT;
Timeout : TIME:=t#3s;


END_VAR

fbFileOpen('','Hard Disk\My_Projects\Tilt6_1.txt',FOPEN_MODEREAD OR FOPEN_MODEBINARY,PATH_GENERIC,bFileOpen=TRUE,Timeout);
 
Last edited:
I sum them up:
sNetId := '',
sPathName := 'Hard Disk\My_Projects\....,
nMode := FOPEN_MODEREAD OR FOPEN_MODEBINARY,
ePath := PATH_GENERIC,
tTimeout := Timeout,
bExecute := bFileOpen

What I miss?

But I see it is possible, cause u dont get an error on line 2. Why is that?
 
Last edited:
Does fbFileOpen(); compile ?

Add in the itentifers one at a time to find the error. (I'm off out now!)
 
Now that I've found the appropriate library with FB_FileOpen in it, here's the code that compiles ok:

beck003.jpg
 

Similar Topics

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...
Replies
2
Views
4,097
There's already been some discussion about writing to a file in TwinCAT, but I didn't see that someone encountered problem similar to mine. My...
Replies
1
Views
3,182
Hi I'm doing a simple writing to .CSV file. I want to write the headers, but I have hard time indentifying when the file is empty. One idea was...
Replies
1
Views
2,001
Hi, I want to write a string into a file. This has to happen within a funcion (FUN, no FB) since I want to use it to log stuff to a file...
Replies
3
Views
6,591
I am using twincat 3 to send some strings over TCP/IP. Where the server is a sensor and my PLC is the client. I noticed that the sensor didnt...
Replies
2
Views
82
Back
Top Bottom