webDOMinator - Minion Scripting Language Reference

Search a Command:
<< Back to Filesystem and Shell Commands

read

Usage...
read:file-handle:variable
Reads the next line from the file specified by file-handle into variable. The variable can be any var, global, or a DOM or program variable.
This applies to webDOM version 2.0.0 and above.

User Comments on read

Reading from a specific line

Written by: webDOMinator 2 years and 6 months ago

Recently in version 2.5.3 of webDOM the read command has been updated to include a way to read from just one line of a file instead of having to read through multiple lines to get to just the one you want. This looks like

Code

var:thirdline=
open:r:foo;c:\blah.txt
read:foo#3:var.thirdline
close:foo
echo:var.thirdline

The above code will just pull out the third line of the file "blah.txt" and echo it to the status & output window.

So the use of the #3 pulls out the third line of the file handle associated with it. In this case from the file handle "foo".

NOTE: If you do not close a file, it will not reset where webDOM reads from the file when using the single line read method. This means that if you forget to close the file and you want to do another specific line read of the file it will pull the incorrect information. This can also be considered that instead of pulling from the mentioned line, it's pulling from the last line + whatever number you mentioned... ie:
Code

var:thirdline=
var:fourthline=
open:r:foo;c:\blah.txt
read:foo#3:var.thirdline
echo:var.thirdline
read:foo#2:var.secondline
echo:var.secondline
close:foo

var.secondline would not actually be the second line, since the file line cursor was already at 3, it would be 3 + 2 thus var.secondline would contain whatever was in the fifth line. In this case, it's best to do something like:
Code

var:secondline=
var:thirdline=
open:r:foo;c:\blah.txt
read:foo#2:var.secondline
read:foo:var.thirdline
close:foo
echo:var.secondline
echo:var.thirdline

The third line in this case comes right after the second line so we used just a regular read command with no line number included.

Post a Comment About the "read" Command
Title:
Comment:
Post as Anonymous:
User Login
Username:
Email:
Password:
webDOMinator is copyright ©2008, 2009, 2010, 2011, 2012 Nathaniel D. Gibson. All Rights Reserved.
Contact | Tutorials | Forum
By using webDOMinator you are taking all liability in to your own hands. Nathaniel D. Gibson is not responsible for any damages, loss, or defamation (legal or otherwise) caused to you or your business from using this program. Nathaniel D. Gibson is not associated with, affiliated with, nor responsible for the content submitted and displayed by users of this site.