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 

StringGetPos to find 1st incidence of "/" in a dat

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
Steve-oh
Guest





PostPosted: Mon Aug 16, 2004 11:44 pm    Post subject: StringGetPos to find 1st incidence of "/" in a dat Reply with quote

I'm trying to make the following work...

Read a date from an excel spreadsheet. The format = m/dd/yy

The format to run the script has to be in mm/dd/yy.

Using stringgetpos, I want to know the position of the first "/". If it's not 2, then the date format is wrong.

Here's the command in the script:

Send, {right}^c
Sleep, 200
effdate = %clipboard%
StringTrimRight, effdate, effdate, 2
StringGetPos, spos, %effdate%, /
If spos <> 3
{
...

effdate = "8/16/04"
It bombs at "StringGetPos, spos, %effdate%, /"

I tried using it in a variable, no go! I guess I could use StringMid to see if the third character = / but I'd like to use StringGetPos.

Help!

TIA
Back to top
Guest






PostPosted: Mon Aug 16, 2004 11:46 pm    Post subject: Reply with quote

Sorry, "If it's not 2" should read "If it's not 3" !
Back to top
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10464

PostPosted: Tue Aug 17, 2004 2:08 am    Post subject: Reply with quote

Putting percent signs around an input variable is a common mistake. Here is a quote from StringGetPos: "Do not enclose the [InputVar] name in percent signs unless you want the contents of the variable to be used as the name."

So use the following instead:
StringGetPos, spos, effdate, /

Note that StringSplit might also be helpful to validate a date in this case.
Back to top
View user's profile Send private message Send e-mail
Guest






PostPosted: Tue Aug 17, 2004 9:53 pm    Post subject: Reply with quote

Please accept my appologies for wasting your time.

If I had read it right the first time, I would have never posted...

It worked like a charm!

Rolling Eyes
Back to top
Display posts from previous:   
Post new topic   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