How to change the order of a name? Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
magicinmath
Posts: 162
Joined: 12 Apr 2017, 23:03

How to change the order of a name?

22 Apr 2017, 17:49

The idea is to change a name that is: smith, john to: john smith

I found this page and tried this:
https://autohotkey.com/docs/commands/StringSplit.htm

Code: Select all

	inputname = smith, john

	StringSplit, outputname, inputname, ","

	Send % outputname[2]
	Send % outputname[1]
I've read this but don't see any options that do this specifically.
https://autohotkey.com/docs/commands/Sort.htm

Please enlighten me.

Thank you.
kon
Posts: 1756
Joined: 29 Sep 2013, 17:11

Re: How to change the order of a name?  Topic is solved

22 Apr 2017, 20:09

You were fairly close to getting something that works, but you were mixing the two types of StringSplit / StrSplit.

Code: Select all

inputname = smith, john

StringSplit, outputname, inputname, `,
MsgBox, % outputname2
MsgBox, % outputname1

outputname := StrSplit(inputname, ",", " ")
MsgBox, % outputname[2]
MsgBox, % outputname[1]
Hope this helps :)

Edit: It's also possible to do this with InStr and SubStr together. Find the position of the comma with InStr. Then get everything before the comma with SubStr. And use SubStr again to get everything after the comma.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Anput, Fredrik F, garry, maxkill, RandomBoy, ShatterCoder and 418 guests