Jump to content

reading file help.


capo
 Share

Recommended Posts

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.

Link to comment
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 (:).
Link to comment
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

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...