It is currently Mon Apr 21, 2014 6:54 am




Post new topic Reply to topic  [ 6 posts ] 
 read from text file 
Author Message
Trooper
Trooper

Joined: Fri Jun 01, 2012 4:00 am
Posts: 10
Post read from text file
how to read values from text file and write to tags only once when values are changed?
can any one give solution for this


Fri Jun 01, 2012 8:43 pm
Profile
Moderator
Moderator

Joined: Sun Apr 02, 2006 2:46 pm
Posts: 1982
Location: Sacramento, CA
Post Re: read from text file
You can do this in scripting either automatically every x amont of time or manually when someone presses a button. The script will be something like this:
Code:
fileStr = system.file.readFileAsString("C:\\Path\\To\\File.txt")
system.tag.writeToTag("Path/To/Tag", fileStr)
Of course that script is really simple, so in order to give you a better script what does your file look like? Is it a CSV? There are several ways to read in values and write them to tags.

_________________
Travis Cox
Inductive Automation
Technical Support Rep.


Sun Jun 03, 2012 7:49 pm
Profile WWW
Moderator
Moderator

Joined: Sun Apr 02, 2006 2:46 pm
Posts: 1982
Location: Sacramento, CA
Post Re: read from text file
I just noticed that you posted this question twice: one here and one the Ignition section. Please don't post this question to two different forums. In the future you only need to post the question once and we will answer it.

_________________
Travis Cox
Inductive Automation
Technical Support Rep.


Sun Jun 03, 2012 7:52 pm
Profile WWW
Trooper
Trooper

Joined: Fri Jun 01, 2012 4:00 am
Posts: 10
Post Re: read from text file
this is not a csv file,it is a text file with comma delimited.
atleast give me the reply for how to find out "a text file is changed or not"?
what are the steps to find the text file is changed or not in ignition?
please mention the steps.


Fri Jun 08, 2012 10:40 pm
Profile
General
General

Joined: Sun Feb 25, 2007 2:54 pm
Posts: 546
Post Re: read from text file
You could try this as well. The posted version is for 7.3, bit I'll post the 7.4 and 7.5 versions really next week
viewtopic.php?f=88&t=7885


Sat Jun 09, 2012 11:39 am
Profile WWW
General
General

Joined: Tue Mar 24, 2009 9:14 am
Posts: 782
Location: Hudson, MI
Post Re: read from text file
I'll requote myself from the duplicate post...
JordanCClark wrote:
Since you're looking for only changed values, you would need to grab the previous values. You can do this by either:

1: reading all your tags and comparing the values.
2: renaming the file with the current values to hold the previous values. Then read two files (one with the current values and the one you renamed) and compare.


How many tags are you processing? Depending on the number, there may not be a whole lot of overhead to worry about anyway.

_________________
Jordan

Duct tape is like The Force. It has a light side, a dark side, and it holds the universe together.


Mon Jun 11, 2012 1:15 am
Profile
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: