From: bcastaing on
Hello to everybody

I would like to read a value in a txt file. For example, the value
will following the egual sign. So I want to look for language and get
"fr" as value.


language = fr
country = france

Thank you by advance and have a nice day.
From: Pegasus [MVP] on


<bcastaing(a)gmail.com> said this in news item
news:389dabc3-ca3b-440b-b55a-a93ca9221025(a)w16g2000yqw.googlegroups.com...
> Hello to everybody
>
> I would like to read a value in a txt file. For example, the value
> will following the egual sign. So I want to look for language and get
> "fr" as value.
>
>
> language = fr
> country = france
>
> Thank you by advance and have a nice day.

The Split function is your answer:
sString = "language = fr"
aString = split(sString, "=")
wscript.echo trim(aString(2))

From: bcastaing on
On 8 fév, 12:27, "Pegasus [MVP]" <n...(a)microsoft.com> wrote:
> <bcasta...(a)gmail.com> said this in news itemnews:389dabc3-ca3b-440b-b55a-a93ca9221025(a)w16g2000yqw.googlegroups.com...
>
> > Hello to everybody
>
> > I would like to read a value in a txt file. For example, the value
> > will following the egual sign. So I want to look for language and get
> > "fr" as value.
>
> > language = fr
> > country = france
>
> > Thank you by advance and have a nice day.
>
> The Split function is your answer:
> sString = "language = fr"
> aString = split(sString, "=")
> wscript.echo trim(aString(2))

Thank you very much for your quick answer.
But my text file will have many lines, and I would like to find a
value for each parameter I look for.
For example, if I look for language, I want to get fr, If I look for
country, I will have france ....

Thanks
From: mayayana on
If you have it set up like an INI file
see here:

http://www.jsware.net/jsware/scripts.php5#classpk

In the download is a class that you can paste
into your script. It will let you treat an INI
file like an object.

Otherwise, you can use Split to divide
your file into an array of lines before proceeding.
Pegasus was giving you the basic idea, but
you can't expect someone to write your script
for you. If you don't know how to open the file
or handle arrays, etc. then you need to download
the WSH help file:

http://www.microsoft.com/downloads/details.aspx?FamilyId=01592C48-207D-4BE1-
8A76-1C4099D7BBB9


--
--
<bcastaing(a)gmail.com> wrote in message
news:0c09e83e-e107-4458-8224-6a7361e07eb3(a)m31g2000yqd.googlegroups.com...
On 8 f�v, 12:27, "Pegasus [MVP]" <n...(a)microsoft.com> wrote:
> <bcasta...(a)gmail.com> said this in news
itemnews:389dabc3-ca3b-440b-b55a-a93ca9221025(a)w16g2000yqw.googlegroups.com..
..
>
> > Hello to everybody
>
> > I would like to read a value in a txt file. For example, the value
> > will following the egual sign. So I want to look for language and get
> > "fr" as value.
>
> > language = fr
> > country = france
>
> > Thank you by advance and have a nice day.
>
> The Split function is your answer:
> sString = "language = fr"
> aString = split(sString, "=")
> wscript.echo trim(aString(2))

Thank you very much for your quick answer.
But my text file will have many lines, and I would like to find a
value for each parameter I look for.
For example, if I look for language, I want to get fr, If I look for
country, I will have france ....

Thanks


From: LikeToCode on
This can get you started. strString would be the variable you charged from
either a ReadAll() or ReadLine() method. This will produce the value you are
looking for but you can also tweak this to count the number of occurrences of
your search term in the whole file, etc.

Dim strString, strSearch, intLength
strSearch = InputBox ("Enter your Search Term")
If strSearch <> "" Then
strString = "country = france"
intLength = Len(strSearch) + 2
MsgBox RegExp(strString,strSearch)
End If

Function RegExp(Strng,Patrn)
Dim objRegExp, Matches, Match, intCount
Set objRegExp = New RegExp
With objRegExp
.Pattern = "\b" & Patrn & "\b.*$"
.IgnoreCase = True
.Global = True
End With
Set Matches = objRegExp.Execute(Strng)
For Each Match In Matches
intCount = Match.length - intLength
RegExp = Right(Match.Value, intCount)
Next
End Function