Sign in to follow this  
Followers 0
capo

reading file help.

8 posts in this topic

Hey i need some help reading files. say if i have this in a text file:

te/xt

text

t/e/xt

{

/text/

}

text

text

text

how would i get read all of it and display in a message box without the

{

/text/

}

part?, so basically ignoring whatever is in the bracket and continue on.

Share this post


Link to post
Share on other sites



Hi and welcome to the forums :)

Look at StringReplace() in the help file, it will do the trick :lmao:


Broken link? PM me and I'll send you the file!

Share this post


Link to post
Share on other sites

hey,

I don't want to replace it o.o, i just want to ignore it and continue. :)

Share this post


Link to post
Share on other sites

Hi,

The input will be like:

blah blah blah

blahblahblah

blah

{

blah

}

blah

[

blah

]

(

blah

)

34

What i want is to ignore the { blah } bit, and continue on.

The output would be like:

blah blah blah

blahblahblah

blah

blah

[

blah

]

(

blah

)

34

I can use stringreplace to get rid of it, but i want some other way to do it(without deleting the { blah }). so i just want it to IGNORE it, kind of like autoit's comment (:).

Share this post


Link to post
Share on other sites

if ur gonna ignore it why not just get rid of it?


A great place to start Autoit 1-2-3

Share this post


Link to post
Share on other sites

I just said that i wanted some other way and be like autoit's comment ( ; ) ? :)

Share this post


Link to post
Share on other sites

Seems to work okay for plain line by line parsing... :)

$text = "blah blah blah" & @LF
$text &= "blahblahblah" & @LF
$text &= "blah" & @LF
$text &= "{" & @LF
$text &= "blah" & @LF
$text &= "}" & @LF & @LF
$text &= "blah" & @LF
$text &= "[" & @LF
$text &= "blah" & @LF
$text &= "]" & @LF & @LF
$text &= "(" & @LF
$text &= "blah" & @LF
$text &= ")" & @LF
$text &= "34" & @LF

$new_text = ""
$skip = False
$split = StringSplit($text, @LF)

For $i = 1 To $split[0]
    Select
        Case StringInStr($split[$i], "}")
            $skip = False
            ContinueLoop
        Case $skip
            ContinueLoop
        Case StringInStr ($split[$i], "{")
            $skip = True
            ContinueLoop
        Case Else
            $new_text &= $split[$i] & @LF
    EndSelect
Next

MsgBox (0, "", $text)
MsgBox (0, "", $new_text)

Cheers,

Brett

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