FileValue
Top  Previous  Next


Returns a string from a specified column and row in a text file

This function is useful to for example read from a file exported from a database, output from programs called with DOS / DOSR or the output from a VBScript.Begin..End section.

FileValue (FileName, StartTag, EndTag, Delimiter, Column, Row)

FileName
Name of text file to read value from, include full path if not current directory  
Maximum file size is 300k, larger files will not be opened  

StartTag [Optional parameter]
Tag (text string) to start reading after;all text before the start tag is ignored  
When the StartTag parameter is present, the row parameter is relative to the row after start tag  

EndTag [Optional parameter]
Tag (text string) to start reading before; all text after the start tag is ignored  
Notice: EndTag is ignored if StartTag is not present.  

Delimiter
Column delimiter  
Valid options: semicolon | comma | colon | tab  

Column
Column to read from, 1-100  
Notice: columns must be delimited with the character specified in the delimiter parameter  

Row
Row to read from, 1-10000  
Notice: when the StartTag parameter is present, the row parameter is relative to the row after start tag  

Examples
Text file "myfile.txt":

row1col1,row1col2,row1col3
row2col1,row2col2,row2col3
row3col1,row3col2,row3col3
dataset2
row5col1,row5col2,row5col3
row6col1,row6col2,row6col3
row7col1,row7col2,row7col3

end

MessageBox FileValue(c:\myfile.txt,,,comma,1,1)

Displays "row1col1"

SET myvar=FileValue(c:\myfile.txt,,,comma,2,5)
MessageBox %myvar%


Displays "row5col2"

MessageBox FileValue(c:\myfile.txt,dataset2,end,comma,1,1)

Displays "row5col1"

MessageBox FileValue(c:\myfile.txt,dataset2,end,comma,1,4)

Displays "empty variable?" - there are only three rows between "dataset2" / "end".