Requesting Code Sample - Writing to Text file in OptoScript

I want to be able to write to a text file from OptoScript, and I would certainly appreciate it if someone can post a sample code that accomplishes this.

Thanks!

Hi ErichB,

We have a few on the website already. I’d recommend you start with this example, in particular, the chart called “FTP” in block 7:
http://www.opto22.com/site/downloads/dl_drilldown.aspx?aid=3614

There’s also this nice File Management and FTP tutorial. Our talented illustrator did some great drawings in the manual showing how all the pieces work, you might at least want to check out the pictures:
http://www.opto22.com/site/documents/doc_drilldown.aspx?aid=2979

In a nutshell, you open a comm handle (using OpenOutgoingCommunication) which has a value of something like: “file:a,myfilename.txt” then use a command like TransmitString to put stuff in it. When you’re done putting stuff in the file you can use the CloseCommunication command.

Hope that helps!

-OptoMary

1 Like

Here’s another similar thread where I posted a very simple example of how you might log some data with a timestamp to a file.
Hope it’s helpful: Write text file - #4 by gmitchell

-OptoMary

Hi Mary,

I was having issues with my Opto22 account, hence my late reply. But I did see that example posted. And thanks to your example, my data logging routines work perfectly.

I was tinkering with the FTP example, and after struggling with it for days, I was about to take on a challenge to make a more simple, easy-to-follow example of FTP data logging. But since your example was simple and efficient (and eliminates the need of FTP login!), I see no need to take on that task anymore. Maybe I’ll find something else to improve upon…

Anyways, thanks for your help Mary!