I think parsing in my problem

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
sbrady
Posts: 105
Joined: 15 Mar 2014, 20:41
Location: Virginia Beach

I think parsing in my problem

26 Mar 2017, 08:12

I tried for a long time before I am posting help. I need to:

1. merge 2 lists
2. sort them alphabetically
3. format a new list as such

any tips would be greatly appreciated.

Code: Select all

;reference template
/*StringReplace, NoComp1, NewStr1, Ayala, , All
StringReplace, NoComp2, NoComp1, Byrnes, , All
StringReplace, NoComp3, NoComp2, Coates, , All
StringReplace, NoComp4, NoComp3, Cornish, , All*/


word1 = StringReplace
word2 = NoComp
word3 = NewStr


old_composers = Adams,Zebra,Smith
new_composers = Charlie,Quigley


Loop, parse, old_composers, `,
{
    theList = %theList%`n%A_LoopField%
}


Loop, parse, new_composers, `,
{
    theList = %theList%`n%A_LoopField%
}

sort, theList
msgbox, %theList%
x=1
y=2


StringReplace, new_theList, theList, <br>,`n, All
Loop, parse, theList, `n       ;Parse the string based on the cent symbol.
{
msgbox, %A_LoopFileName%
}




loop, parse, %theList%, ',
{
if %A_Index% = 1
newlist2 = %word1%, %word2%y, %word3%x, %A_LoopFileName%, , All


if %A_Index% > 1
newlist3 = %newlist2%`n%word1%, %word2%y, %word3%x, %A_LoopFileName%, , All

x++
y++
return
}

;msgbox, %newlist3%


/*
here is the desired result:
StringReplace, NoComp1, NewStr1, Adams, , All
StringReplace, NoComp2, NoComp1, Charlie, , All
StringReplace, NoComp3, NoComp2, Quigley, , All
StringReplace, NoComp4, NoComp3, Smith, , All
StringReplace, NoComp4, NoComp3, Zebra, , All
*/
garry
Posts: 3764
Joined: 22 Dec 2013, 12:50

Re: I think parsing in my problem

26 Mar 2017, 08:30

just short 1,2

Code: Select all

/*
1. merge 2 lists
2. sort them alphabetically
3. format a new list as such
*/

a=Adams,Zebra,Smith
b=Charlie,Quigley
c:=""
Loop, parse,a,`,
  c .= a_loopfield . "`n"
Loop, parse,b,`,
  c .= a_loopfield . "`n"
sort,c
msgbox,%c%
return
sbrady
Posts: 105
Joined: 15 Mar 2014, 20:41
Location: Virginia Beach

Re: I think parsing in my problem

26 Mar 2017, 09:22

thanks, now I have:

name1
name2
name3

how do I parse that
garry
Posts: 3764
Joined: 22 Dec 2013, 12:50

Re: I think parsing in my problem

26 Mar 2017, 10:43

can parse with end of line `n

Code: Select all

a=Adams,Zebra,Smith
b=Charlie,Quigley
c:=""
Loop, parse,a,`,
  c .= a_loopfield . "`n"
Loop, parse,b,`,
  c .= a_loopfield . "`n"
sort,c
;-----------------
Loop, parse,c,`n
  {
  x:=a_loopfield
  if x=
    break
  d .= a_index . "-" .  a_loopfield . "`r`n"  ;- add number as example
  }
msgbox,%d%
return

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Google [Bot], wilkster and 334 guests