Loading ...
Sorry, an error occurred while loading the content.

Re: [AutoIt] Re: Delim example question

Expand Messages
  • Brian Keene
    ... Well no... Look at the string in $TestVar & tell me what is between each word. ... Ok test over. The answer is a . By using the as the delimiter
    Message 1 of 19 , Aug 26, 2003
    View Source
    • 0 Attachment
      On Wed,8/27/03 00:27:11 <tutor2000@...> writes:
      > > ' WATCH WORDWRAP!
      > > $TestVar = "Email me at <myemail@...> for your ebook and I want
      > > to write it to mylist.txt"
      > > $DELIM = " "
      > Why is delim set to " " not < or > Ohhhhhhh you're looking for @
      > then
      > when there's a space you're stopping?

      Well no... Look at the string in $TestVar & tell me what is
      between each word. ... Ok test over. The answer is a " ". By
      using the " " as the delimiter I'm able to get the
      "<myemail@...>" by itself in 1 of the array elements
      when I pass the string to StrSplit() inside of ItemExtract().

      In the for loop we are looking for the "@" so that we can
      recognize among all of the other words that the 1 item we're
      looking for is an email address. It's the only unique char. I
      could think of that was in the email address string. The "<"
      and ">" have already been stripped from the address by the
      StringTrimLeft & StringTrimRight functions.

      > > $TLen = StringSizeLines( $TestVar, " " )
      > > For $C = 1 To $TLen
      > > $EMailAddr = StringTrimLeft( StringTrimRight(
      > ItemExtract( $TestVar, $C, $DELIM ), 1 ), 1 )
      >
      > Grrrrrrr what is the 1 for above

      Lets disect the above statement from the inside out. We pass
      the ItemExtract() function the string, the item #, and
      the delimiter. As we progress thru the loop it eventually
      returns the email address with the "<" & ">" on the ends of the
      string. The StringTrimRight chops off the ">" with the 1st 1
      inside its parameters. Then the StringTrimLeft chops off the
      "<" with the 2nd 1 inside its parameters. Then the resulting
      string is placed in the $EMailAddr variable.

      > > If( StringInStr( $EMailAddr, "@" ) )
      > > ExitLoop
      > > EndIf
      > > Next
      > > MsgBox( 0, "Email Address", $EMailAddr )
      > > Exit
      >
      > I'm getting there. Then the questions will really start

      Keep'em coming.

      Regards
      Brian Keene

      In troubling times, it's good to read true stories by real people
      about real people doing good things in simple ways.
      When you get a chance visit: http://www.HeroicStories.com

      > > > --- Brian Keene <brian_keene@j...> wrote:
      > > > > I disagree. If he doesn't want the "<" or ">" he can still do
      >
      > > > > the following in 1 line with the ItemExtract function. The
      > > > > majority of the line strips off the "<" & ">" with the
      > > > > StringTrim's.
      > > > >
      > > > > ' =========== Script Starts Here ===========
      > > > > ' WATCH WORDWRAP!
      > > > > $TestVar = "Email me at <myemail@h...> for your ebook and I
      > want
      > > > to write it to mylist.txt"
      > > > > $ITEM = 4
      > > > > $DELIM = " "
      > > > > ' ******* Here's the 1 line I'm talking about. ********
      > > > > $EMailAddr = StringTrimLeft( StringTrimRight( ItemExtract(
      > > > $TestVar, $ITEM, $DELIM ), 1 ), 1 )
      > > > > MsgBox( 0, "Email Address", $EMailAddr )
      > > > > Exit
      > > > > #Include "C:\AU3_Functions\Data Management\Text
      > > > Functions\StrSplit.au3"
      > > > > Func ItemExtract( $STRING, $ITEM, $DELIM )
      > > > > $A = StrSplit( $STRING, $DELIM )
      > > > > Return( $A[$ITEM] )
      > > > > EndFunc
      > > > > ' =========== Script Stops Here ===========
      > > > >
      > > > > On Tue, 26 Aug 2003 <larrydalooza@y...> writes:
      > > > > > You need a tailored function...
      > > > > > $string = "Email me at <myemail@h...> for your ebook"
      > > > > > MsgBox(4096,"test",ExtractEmail($string))
      > > > > > Exit
      > > > > >
      > > > > > Func ExtractEmail($a)
      > > > > > $c=0
      > > > > > $b = StringInStr($a,"<")
      > > > > > If $b Then
      > > > > > $a = StringTrimLeft($a,$b)
      > > > > > Else
      > > > > > $c=1
      > > > > > EndIf
      > > > > > $b = StringInStr($a,">")
      > > > > > If $b Then
      > > > > > $a = StringLeft($a,$b - 1)
      > > > > > Else
      > > > > > $c=1
      > > > > > EndIf
      > > > > > SetError($c)
      > > > > > Return $a
      > > > > > EndFunc
      > > > > >
      > > > > > --- In AutoItList@yahoogroups.com, "Tutor2000"
      > <tutor2000@y...>
      > > > > > wrote:
      > > > > > > Grrrrrrrrrrr my head
      > > > > > > Maybe this will help me even more
      > > > > > > Let's say I want to read this line
      > > > > > > Email me at <myemail@h...> for your ebook and I want to
      > write it
      > > > > > > to mylist.txt
      > > > > > > I need to write <> and the email address between
      > > > > > > Can you give me an example on that if you have time?
      > > > > > >
      > > > > > > ' ItemExtract parameters.
      > > > > > > $TestVar = "This is a test and only a test so help me
      > > > GOD!!!!!!!"
      > > > > > > $ITEM = 9
      > > > > > > $DELIM = " "
      > > > > > >
      > > > > > > ' Constructing message for MsgBox.
      > > > > > > $MSG = "$TestVar = """ & $TestVar & """" &@CR
      > > > > > > $MSG = $MSG & "$ITEM = """ & $ITEM & """" &@CR
      > > > > > > $MSG = $MSG & "$DELIM = """ & $DELIM & """" &@CR&@CR
      > > > > > > $MSG = $MSG & "Result = """
      > > > > > > ' Here's where I extract the item from the string & place
      >
      > it in
      > > > > > > ' the $MSG variable.
      > > > > > > $MSG = $MSG & ItemExtract( $TestVar, $ITEM, $DELIM )
      > > > > > > $MSG = $MSG & """" &@CR
      > > > > > > ' Print out the result.
      > > > > > > MsgBox( 0, "ItemExtract() Test", $MSG )
      > > > > > > Exit
      > > > > > > #Include "C:\AU3_Functions\Data Management\Text
      > > > > > > Functions\StrSplit.au3"
      > > > > > > Func ItemExtract( $STRING, $ITEM, $DELIM )
      > > > > > > $A = StrSplit( $STRING, $DELIM )
      > > > > > > Return( $A[$ITEM] )
      > > > > > > EndFunc
      > > > > > > ' =========== Script Stops Here ===========

      ________________________________________________________________
      The best thing to hit the internet in years - Juno SpeedBand!
      Surf the web up to FIVE TIMES FASTER!
      Only $14.95/ month - visit www.juno.com to sign up today!
    • Tutor2000
      Okay starting to get it; I m gonna start asking questions on simpler stuff Rick ... want ... do ... place
      Message 2 of 19 , Aug 26, 2003
      View Source
      • 0 Attachment
        Okay starting to get it;

        I'm gonna start asking questions on simpler stuff

        Rick

        --- In AutoItList@yahoogroups.com, Brian Keene <brian_keene@j...>
        wrote:
        > On Wed,8/27/03 00:27:11 <tutor2000@y...> writes:
        > > > ' WATCH WORDWRAP!
        > > > $TestVar = "Email me at <myemail@h...> for your ebook and I
        want
        > > > to write it to mylist.txt"
        > > > $DELIM = " "
        > > Why is delim set to " " not < or > Ohhhhhhh you're looking for @
        > > then
        > > when there's a space you're stopping?
        >
        > Well no... Look at the string in $TestVar & tell me what is
        > between each word. ... Ok test over. The answer is a " ". By
        > using the " " as the delimiter I'm able to get the
        > "<myemail@h...>" by itself in 1 of the array elements
        > when I pass the string to StrSplit() inside of ItemExtract().
        >
        > In the for loop we are looking for the "@" so that we can
        > recognize among all of the other words that the 1 item we're
        > looking for is an email address. It's the only unique char. I
        > could think of that was in the email address string. The "<"
        > and ">" have already been stripped from the address by the
        > StringTrimLeft & StringTrimRight functions.
        >
        > > > $TLen = StringSizeLines( $TestVar, " " )
        > > > For $C = 1 To $TLen
        > > > $EMailAddr = StringTrimLeft( StringTrimRight(
        > > ItemExtract( $TestVar, $C, $DELIM ), 1 ), 1 )
        > >
        > > Grrrrrrr what is the 1 for above
        >
        > Lets disect the above statement from the inside out. We pass
        > the ItemExtract() function the string, the item #, and
        > the delimiter. As we progress thru the loop it eventually
        > returns the email address with the "<" & ">" on the ends of the
        > string. The StringTrimRight chops off the ">" with the 1st 1
        > inside its parameters. Then the StringTrimLeft chops off the
        > "<" with the 2nd 1 inside its parameters. Then the resulting
        > string is placed in the $EMailAddr variable.
        >
        > > > If( StringInStr( $EMailAddr, "@" ) )
        > > > ExitLoop
        > > > EndIf
        > > > Next
        > > > MsgBox( 0, "Email Address", $EMailAddr )
        > > > Exit
        > >
        > > I'm getting there. Then the questions will really start
        >
        > Keep'em coming.
        >
        > Regards
        > Brian Keene
        >
        > In troubling times, it's good to read true stories by real people
        > about real people doing good things in simple ways.
        > When you get a chance visit: http://www.HeroicStories.com
        >
        > > > > --- Brian Keene <brian_keene@j...> wrote:
        > > > > > I disagree. If he doesn't want the "<" or ">" he can still
        do
        > >
        > > > > > the following in 1 line with the ItemExtract function. The
        > > > > > majority of the line strips off the "<" & ">" with the
        > > > > > StringTrim's.
        > > > > >
        > > > > > ' =========== Script Starts Here ===========
        > > > > > ' WATCH WORDWRAP!
        > > > > > $TestVar = "Email me at <myemail@h...> for your ebook and I
        > > want
        > > > > to write it to mylist.txt"
        > > > > > $ITEM = 4
        > > > > > $DELIM = " "
        > > > > > ' ******* Here's the 1 line I'm talking about. ********
        > > > > > $EMailAddr = StringTrimLeft( StringTrimRight( ItemExtract(
        > > > > $TestVar, $ITEM, $DELIM ), 1 ), 1 )
        > > > > > MsgBox( 0, "Email Address", $EMailAddr )
        > > > > > Exit
        > > > > > #Include "C:\AU3_Functions\Data Management\Text
        > > > > Functions\StrSplit.au3"
        > > > > > Func ItemExtract( $STRING, $ITEM, $DELIM )
        > > > > > $A = StrSplit( $STRING, $DELIM )
        > > > > > Return( $A[$ITEM] )
        > > > > > EndFunc
        > > > > > ' =========== Script Stops Here ===========
        > > > > >
        > > > > > On Tue, 26 Aug 2003 <larrydalooza@y...> writes:
        > > > > > > You need a tailored function...
        > > > > > > $string = "Email me at <myemail@h...> for your ebook"
        > > > > > > MsgBox(4096,"test",ExtractEmail($string))
        > > > > > > Exit
        > > > > > >
        > > > > > > Func ExtractEmail($a)
        > > > > > > $c=0
        > > > > > > $b = StringInStr($a,"<")
        > > > > > > If $b Then
        > > > > > > $a = StringTrimLeft($a,$b)
        > > > > > > Else
        > > > > > > $c=1
        > > > > > > EndIf
        > > > > > > $b = StringInStr($a,">")
        > > > > > > If $b Then
        > > > > > > $a = StringLeft($a,$b - 1)
        > > > > > > Else
        > > > > > > $c=1
        > > > > > > EndIf
        > > > > > > SetError($c)
        > > > > > > Return $a
        > > > > > > EndFunc
        > > > > > >
        > > > > > > --- In AutoItList@yahoogroups.com, "Tutor2000"
        > > <tutor2000@y...>
        > > > > > > wrote:
        > > > > > > > Grrrrrrrrrrr my head
        > > > > > > > Maybe this will help me even more
        > > > > > > > Let's say I want to read this line
        > > > > > > > Email me at <myemail@h...> for your ebook and I want to
        > > write it
        > > > > > > > to mylist.txt
        > > > > > > > I need to write <> and the email address between
        > > > > > > > Can you give me an example on that if you have time?
        > > > > > > >
        > > > > > > > ' ItemExtract parameters.
        > > > > > > > $TestVar = "This is a test and only a test so help me
        > > > > GOD!!!!!!!"
        > > > > > > > $ITEM = 9
        > > > > > > > $DELIM = " "
        > > > > > > >
        > > > > > > > ' Constructing message for MsgBox.
        > > > > > > > $MSG = "$TestVar = """ & $TestVar & """" &@CR
        > > > > > > > $MSG = $MSG & "$ITEM = """ & $ITEM & """" &@CR
        > > > > > > > $MSG = $MSG & "$DELIM = """ & $DELIM & """" &@CR&@CR
        > > > > > > > $MSG = $MSG & "Result = """
        > > > > > > > ' Here's where I extract the item from the string &
        place
        > >
        > > it in
        > > > > > > > ' the $MSG variable.
        > > > > > > > $MSG = $MSG & ItemExtract( $TestVar, $ITEM, $DELIM )
        > > > > > > > $MSG = $MSG & """" &@CR
        > > > > > > > ' Print out the result.
        > > > > > > > MsgBox( 0, "ItemExtract() Test", $MSG )
        > > > > > > > Exit
        > > > > > > > #Include "C:\AU3_Functions\Data Management\Text
        > > > > > > > Functions\StrSplit.au3"
        > > > > > > > Func ItemExtract( $STRING, $ITEM, $DELIM )
        > > > > > > > $A = StrSplit( $STRING, $DELIM )
        > > > > > > > Return( $A[$ITEM] )
        > > > > > > > EndFunc
        > > > > > > > ' =========== Script Stops Here ===========
        >
        > ________________________________________________________________
        > The best thing to hit the internet in years - Juno SpeedBand!
        > Surf the web up to FIVE TIMES FASTER!
        > Only $14.95/ month - visit www.juno.com to sign up today!
      Your message has been successfully submitted and would be delivered to recipients shortly.