Sign in to follow this  
Followers 0
anybastard

read file and extract a numeric value

7 posts in this topic

Hi guys ,

i need your help to finish my tool .

My tool generare a txt file ( eg . pippo.txt )

This is my txt file for example

value 1 : 123aBc123

vaue 2: 345Def345

value 3: 678ghI678

Test Test : 123456

Value 4: abcdefgh

Value 5: ghl12345kkkl

I need to view in a message box the value present in "123456 " position

More info

Test Test : this part is a costant

123456 : is a numeric value only six element

Can you give me advice or suggest a code to view this value ?

Thanks so much for you help

Rgs

AnyB.

Share this post


Link to post
Share on other sites



??? Posted Image


AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Share this post


Link to post
Share on other sites

Try this:

$pippo = "value 1 : 123aBc123" & @LF & _
                "vaue 2: 345Def345" & @LF & _
                "value 3: 678ghI678" & @LF & @LF & _
                "Test Test : 123456" & @LF & @LF  & _
                "Value 4: abcdefgh"  & @LF & _
                "Value 5: ghl12345kkkl"
$array = StringRegExp($pippo, "Test.*\s(\d+)", 3)
MsgBox(0, "Test", $array[0])

Br,

UEZ


Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Hi to both

@ UEZ

Your code works fine ..but the problem is that my file is very long and not with constant value

This mean that for me this part is hard

$pippo = "value 1 : 123aBc123" & @LF & _                
               "vaue 2: 345Def345" & @LF & _                
            "value 3: 678ghI678" & @LF & @LF & _                
            "Test Test : 123456" & @LF & @LF  & _               
            "Value 4: abcdefgh"  & @LF & _              
            "Value 5: ghl12345kkkl"

Thanks again for your prompt replay

BR

AnyB

Edited by anybastard

Share this post


Link to post
Share on other sites

$pippo = FileRead("Pippo.txt")
$array = StringRegExp($pippo, "Test.*\s(\d+)", 3)
MsgBox(0, "Test", $array[0])

Br,

UEZ


Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites

@ UEZ

Your code works fine ..but the problem is that my file is very long and not with constant value

Well, UEZ just used that as an example. Take a look to FileRead function.

Share this post


Link to post
Share on other sites

Hi Guys ,

wow...now all work fine !!!

Thanks so much for your prompt help

Regards

An1B

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0