Page 1 of 1

Testing Strings

Posted: 16 Jul 2017, 22:43
by sevenomad
loop, 5
{
WinActivate, ahk_class XLMAIN
Sleep 300
send, {Down}
sleep 300
Send, {LCtrl Down}c{LCtrl Up}
sleep 300
PPhone := clipboard
sleep 500
MsgBox, %PPhone%
sleep 500
If (PPhone = "000-000-0000")
{
MsgBox, Its Zero
}
Else
{
MsgBox, Its A Real Number
}
sleep 500
}

I am looking to test the PPhone variable that should contain a phone number to make sure that I am not going call out on a zero phone number. I have a spreadsheet that contains several phone numbers in xxx-xxx-xxxx format. If there is a real number or a zero number this always tells me that it is a real number. I'd also like to eventually check the PPhone variable to make sure its not 000-000-0000 or 999-999-9999 but I figured Id try to make the first one work first.

Any help would be appreciated. Thank You!

Re: Testing Strings

Posted: 17 Jul 2017, 01:44
by BoBo
If you have a list of numbers you shouldn't grab them doing Send-key events. Loop, Parse that document. If it's an Excel file, and you don't want to extract those numbers using COM, save the document beforehand as CSV format. To deal with different (dial prefix) length and varying (manually added) delimiters check out StringReplace/RegExReplace()/StrSplit()/.... To validate for "real" AKA valid numbers you have to compare against official country code/dial prefix lists eg: https://www.rebtel.com/en/international ... -codes/us/

https://en.wikipedia.org/wiki/North_Ame ... ering_Plan

Good luck :)