AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

expressions with a semicolon ; [Solved]

 
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
Firewolf91



Joined: 19 Oct 2007
Posts: 134
Location: PA

PostPosted: Tue Mar 04, 2008 8:20 pm    Post subject: expressions with a semicolon ; [Solved] Reply with quote

I'm trying to search a string for a semicolon and the syntax i'm using obviously doesn't work.
here's the INCORRECT code:
Code:
IfInString, emailadd,;
{
epos := InStr(emailadd,`;,CaseSensitive = false, StartingPos = 1)
eLength := StrLen(emailadd) - epos
StringTrimRight, emailadd, emailadd, %eLength%
MsgBox, It got thru! %epos% is epos. eLength is %eLength% and %emailadd% is not trimmed again. arrr
}

using epos := InStr(... gives me an error that the "leftmost character is illegal in an expression." (speaking of the semicolon)
if i remove the : (i.e. epos = InStr), the expression returns the exact text as such an expression should (without the ":").

the text i'm trying to cut down will appear something like this:
Code:
email123@home.com; email456@home.com

it should use the semicolon as the delimiter by finding it's position, then trimming the right side off, leaving just the first email address.

what syntax am i doing wrong...or better yet, how am i supposed to correctly search for a semicolon so i can split the email addresses?


Last edited by Firewolf91 on Thu Mar 06, 2008 1:56 pm; edited 1 time in total
Back to top
View user's profile Send private message
Kellianjaxon



Joined: 04 Jan 2008
Posts: 102

PostPosted: Tue Mar 04, 2008 8:38 pm    Post subject: Reply with quote

You were missing quotes from around semicolon in InStr. Using literal strings in expressions always requires quotes. I also modified the last parameter of StringTrimRight to remove the semicolon as well.

Code:
emailadd = email123@home.com; email456@home.com

IfInString, emailadd,;
{
epos := InStr(emailadd,";",CaseSensitive = false, StartingPos = 1)
eLength := StrLen(emailadd) - epos
StringTrimRight, emailadd, emailadd, % eLength + 1
MsgBox, It got thru! %epos% is epos. eLength is %eLength% and %emailadd% is not trimmed again. arrr
}
Back to top
View user's profile Send private message
SKAN



Joined: 26 Dec 2005
Posts: 8688

PostPosted: Tue Mar 04, 2008 8:40 pm    Post subject: Reply with quote

Code:
Str := "email123@home.com; email456@home.com"
If ( ePos := InStr( Str, ";" ) )
   NewStr := SubStr(Str,1, ePos-1 )
MsgBox, % NewStr


Smile

Edit:

Code:
Str := "email123@home.com; email456@home.com"

NewStr :=  ( ePos := InStr( Str, ";" ) ) ? SubStr(Str,1, ePos-1 ) : ""
MsgBox, % NewStr
Back to top
View user's profile Send private message Send e-mail
Firewolf91



Joined: 19 Oct 2007
Posts: 134
Location: PA

PostPosted: Tue Mar 04, 2008 8:59 pm    Post subject: Reply with quote

thanks both of you...brain is fried from 3 people in my office asking me to do random stuff non-stop, so i've had like 1 min(at the most) at any given time to "think" or at least collect my thoughts before someone else spoke up. >,<

what day is it? tue? arrrrrr this week is so long! Sad

but really, i should have remembered the quotes Very Happy
and thanks kell with removing the ; itself from the result. i figured i was probably going to be one place off.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group