how to use javascript split in autohotkey Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
tpitera
Posts: 31
Joined: 27 Oct 2020, 15:56

how to use javascript split in autohotkey

15 Apr 2021, 11:32

I searched through the forums and could not find a topic that matches this exactly so if this is a repeat I apologize
I have a string that is obtained from a webpage that is an address. This address can be in several different states
1. blank
2. street address, city state and zip
3. city state and zip
4. 2 and 3 with no zip
5. have coordinates either above or below that i want disregarded or stored in a separate variable
6. Address can be put in with ---Street address--- city state zip but i have only seen this once
My problem is that I am getting confused with javascript and autohotkey. I know how to do in javascript but then I dont see how i would assign to an autohotkey variable
so without further ado, here is my code, Please help

Code: Select all

ProjLoc := "1585 Tower road <br>Cortland, NY 13045" 
	FoundLoc := RegExMatch(ProjLoc, "<br>")
	if (PanelLoc = "")
	{
		break
	} else {
		if (FoundLoc = 0) ;No <br>, therefore no street address, just city, state and possibly zip
		{
			StreetAdd := "" ;or just dont include it?
			City := ProjLoc.split(,)[0]
			StateAndZip := ProjLoc.split(,)[1]
			;check if zip code included
			FoundSpace := RegExMatch(StateAndZip, " ")
			if (FoundSpace = 0) ;No space " " therefore no zip
			{
				State := StateAndZip
				Zip := "" ;or just dont include it?
			} else {  ;zip included
				State := StateAndZip.split(" ")[0]
				Zip := StateAndZip.split(" ")[1]
			}
		} else{  ;break is there, therefore has street address
			StreetAdd := ProjLoc.split(<br>)[0]
			City := ProjLoc.split(<br>)[1].split(,)[0]
			StateAndZip := ProjLoc.split(<br>)[1].split(,)[1]
			FoundSpace := RegExMatch(StateAndZip, " ")
			if (FoundSpace = 0) ;No space " " therefore no zip
			{
				State := StateAndZip
				Zip := "" ;or just dont include it?
			} else {  ;zip included
				State := StateAndZip.split(" ")[0]
				Zip := StateAndZip.split(" ")[1]
			}
		}
	}
User avatar
boiler
Posts: 17374
Joined: 21 Dec 2014, 02:44

Re: how to use javascript split in autohotkey  Topic is solved

15 Apr 2021, 12:01

An example:

Code: Select all

ProjLoc := "1585 Tower road <br>Cortland, NY 13045"
StreetAddress := StrSplit(ProjLoc, "<br>")[1]
MsgBox, % StreetAddress

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Google [Bot] and 83 guests