Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
Keywords: WinItemNameId WinItemizeEx Pipe Parse @TAB Format
Usually you separate items with @tab . That would have been just perfect: extracting the internal id from the window name with any number of vertical bars would have been just extracting the last item from a @tab-separated list item.
I guess you do not have any easy work-around for this, do you?
#DefineFunction UDFReformat_List (list) newlist = "" count = ItemCount( list,"|") count = count/2 For x = 1 To count By 2 newlist = StrCat(newlist, ItemExtract(x,list,"|"),"|", ItemExtract(x+1,list,"|"),@TAB) Next Return StrTrim(newlist) #EndFunction winlist = WinItemNameId( ) list = UDFReformat_List (winlist) AskItemlist("Windows and ID's", list, @TAB, @UNSORTED,@SINGLE, @FALSE)
However, the window name containing a PIPE symbol definitely does introduce a problem. Note : WinItemNameId also returns a similarly formatted result.
Here is my attempt at a workaround:
#DefineFunction UDFReformat_ListFix (list) newlist = "" count = ItemCount( list,"|") ret = count mod 2 If ret == 0 ; even number of items in list count = count/2 For x = 1 To count By 2 newlist = StrCat(newlist, ItemExtract(x,list,"|"),"|", ItemExtract(x+1,list,"|"),@TAB) Next Else ; One of the window names contains a Pipe character !!!! ; Every even item must contain #WINID$ For x = 1 To count By 2 windowname = ItemExtract(x,list,"|") windowid = ItemExtract(x+1,list,"|") If !StrIndexNC( windowid, '#WINID$', 1, @FWDSCAN ) windowname = ItemExtract(x,list,"|"):"|":ItemExtract(x+1,list,"|") windowid = ItemExtract(x+2,list,"|") x = x+1 EndIf newlist = StrCat(newlist, windowname,"|", windowid,@TAB) Next EndIf Return StrTrim(newlist) #EndFunction ;winlist = 'name1|#WINID$0001|name2|#WINID$0002|namewith|pipe|#WINID$0003|name4|#WINID$0004' ;winlist = 'namewith|pipe|#WINID$0001|name2|#WINID$0002|name3|#WINID$0003|name4|#WINID$0004' winlist = 'name1|#WINID$0001|name2|#WINID$0002|name3|#WINID$0003|namewith|pipe|#WINID$0004' list = UDFReformat_ListFix (winlist) AskItemlist("Windows and ID's", list, @TAB, @UNSORTED,@SINGLE, @FALSE) ExitI hope this answers your question.
Article ID: W17902
Filename: WinItemNameId and WinItemizeEx.txt
File Created: 2011:01:07:11:17:26
Last Updated: 2011:01:07:11:17:26