Cannot insert variables into file

Cannot insert variables into file

tomanT9U6N
Contributor Contributor
462 Views
2 Replies
Message 1 of 3

Cannot insert variables into file

tomanT9U6N
Contributor
Contributor

Hello, I can open and close the text file datum.txt, but I can't insert anything into it. Each time I get the error: wrong command on the line FILE WRITE $text TO "out"

Do you know where I have the error?

 

STRING $text = "test"
FILE OPEN "c:\PowerMill\datum.txt" FOR APPEND AS "out"
FILE WRITE $text TO "out"
FILE CLOSE "out"
0 Likes
Accepted solutions (1)
463 Views
2 Replies
Replies (2)
Message 2 of 3

old_snickers
Advocate
Advocate
Accepted solution

It has to be something like this:

 

FILE OPEN "anypath\anyfile.txt" FOR WRITE AS out

FILE WRITE $text to out

....

FILE CLOSE out

 

This worked for me.

I don't know the "append"-command, but mainly I think the quotes at "out" are wrong.

0 Likes
Message 3 of 3

Sean571
Advocate
Advocate

APPEND works just as well as WRITE, but the problem again is the quotes. so I believe that this should work:

STRING $text = "test"
FILE OPEN "c:\PowerMill\datum.txt" FOR APPEND AS out
FILE WRITE $text TO out
FILE CLOSE out



@old_snickers  Appending just adds to the text file whereas writing will override anything in the text file.

Sean Wroblewski
Applications Engineer