 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
Steve-oh Guest
|
Posted: Mon Aug 16, 2004 11:44 pm Post subject: StringGetPos to find 1st incidence of "/" in a dat |
|
|
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
|
Posted: Mon Aug 16, 2004 11:46 pm Post subject: |
|
|
| 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
|
Posted: Tue Aug 17, 2004 2:08 am Post subject: |
|
|
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 |
|
 |
Guest
|
Posted: Tue Aug 17, 2004 9:53 pm Post subject: |
|
|
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!
 |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|