renehasp Posted June 17, 2008 Share Posted June 17, 2008 Trying to figure out how to make a autoit script to have one input box that I can put "FirstName Lastname" then I hit OK button and it out puts the "LastName FirstName" to another string. Any help would be appreciated with this. I want to reverse the two words in the input box. Thank You Rene Link to comment Share on other sites More sharing options...
weaponx Posted June 17, 2008 Share Posted June 17, 2008 There is no reliable way to split a whole name. What if the persons name is Mary Ann O' Flannigan, or John Jacob Jingleheimer Schmidt? Ask for first, middle and last names seperately. $string = "FirstName Lastname" $reversed = StringRegExpReplace($string,"\A(.*)\h(.*)\Z", "$2 $1") MsgBox(0,"",$reversed) Link to comment Share on other sites More sharing options...
sandin Posted June 17, 2008 Share Posted June 17, 2008 $string1 = InputBox("", "First name and Last name") $string_Split = StringSplit($string1, " ") $string = "" for $i = $string_Split[0] to 1 Step -1 if $string = "" Then $string &= $string_Split[$i] Else $string &= " " & $string_Split[$i] EndIf Next MsgBox(0, "ok", $string) Some cool glass and image menu | WinLIRC remote controler | Happy Holidays to all... | Bounce the sun, a game in which you must save the sun from falling by bouncing it back into the sky | Hook Leadtek WinFast TV Card Remote Control Msges | GDI+ sliding toolbar | MIDI Keyboard (early alpha stage, with lots of bugs to fix) | Alt+Tab replacement | CPU Benchmark with pretty GUI | Ini Editor - Edit/Create your ini files with great ease | Window Manager (take total control of your windows) Pretty GUI! | Pop-Up window from a button | Box slider for toolbar | Display sound volume on desktop | Switch hotkeys with mouse scroll Link to comment Share on other sites More sharing options...
renehasp Posted June 17, 2008 Author Share Posted June 17, 2008 This is perfect! Thank you so much! $string1 = InputBox("", "First name and Last name") $string_Split = StringSplit($string1, " ") $string = "" for $i = $string_Split[0] to 1 Step -1 if $string = "" Then $string &= $string_Split[$i] Else $string &= " " & $string_Split[$i] EndIf Next MsgBox(0, "ok", $string) Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now