Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Reading From A File

Status
Not open for further replies.

benaam

Programmer
Jan 11, 2001
20
US
hi
I have a properties file in the following format:

Status = on
Path = c:/somedir

Now from my Code I need to read from this file the above two parameters. How do I do that?Some sample code would be helpful
Thanx in Advance
 
Here's a simple way using list functions. Use a <cffile action=&quot;read&quot;.... to read the contents of the file into a variable &quot;var1&quot;.

Then use the following code to extract the values from #var1#.

<cfset statusVar = listgetat(var1,1,&quot;#chr(10)#&quot;)>
<cfset statusVar = listgetat(statusVar,2,&quot;=&quot;)>

<cfset pathVar = listgetat(var1,2,&quot;#chr(10)#&quot;)>
<cfset pathVar = listgetat(pathVar,2,&quot;=&quot;)>

You can combine each pair of <cfset> statements into a single statement by nesting the listgetat() functions but I broke it up onto two lines a pair so it's easier to read.

Hope this helps,
GJ
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top