List Item contains Pipe Symbol Vertical bar What should I do ?

Get help with using AutoHotkey and its commands and hotkeys
Jameso_0
Posts: 52
Joined: 14 Oct 2015, 22:37

List Item contains Pipe Symbol Vertical bar What should I do ?

09 Aug 2016, 21:37

Hello Everybody,
I am trying to import data from a text file into a Combo box. But there is a little problem with it.
  1. Combo box doesn't display Vertical bar, and top of that whatever is after that vertical bar , it add those words into new line
Script

Code: Select all

FileRead , item_list , %A_ScriptDir%\list.txt
Loop , parse , item_list , `r,`n
	item .= A_LoopField . "|"

Gui , Add , Combobox, gselected vitem x5 y5 h75 w400 r15 , %item%
GuiControl, Choose, item, 1
Gui , Show
return

GuiClose:
ExitApp

selected:
Gui, submit,nohide
sleep 100
clipboard := item
Msgbox, %clipboard%

Content of the list.txt ( list is quite bigger that this, which includes numerous math symbols , emoji and other Unicode Characters )

|x|
ABC|LXO|Z
∠|°|θ
β
α


Vertical bar is my fav symbol and I like to use it a lot.
How to solve this problem. My list contains numerous vertical symbols. Please help me with this , my scripts never work :( .
User avatar
Masonjar13
Posts: 1514
Joined: 20 Jul 2014, 10:16
GitHub: Masonjar13
Location: Не Россия

Re: List Item contains Pipe Symbol Vertical bar What should I do ?

09 Aug 2016, 22:19

Have you tried escaping them? `|
Alternatively, just use LV_InsertCol().
OS: Windows 10 Pro | Editor: Notepad++
My Personal Function Library | Old Build - New Build
imustbeamoron

Re: List Item contains Pipe Symbol Vertical bar What should I do ?

09 Aug 2016, 22:20

try this.
untested

Code: Select all

FileRead , item_list , %A_ScriptDir%\list.txt
Loop , parse , item_list , `r`n														;get rid of comma between `r and `n
	item .= A_LoopField . "*"														;change your delimiter
 
 gui, +delimeter*																;changes the delimeter
Gui , Add , Combobox, gselected vitem x5 y5 h75 w400 r15 , %item%
GuiControl, Choose, item, 1
Gui , Show
return
 
GuiClose:
ExitApp
 
selected:
Gui, submit,nohide
sleep 100
clipboard := item
Msgbox, %clipboard%
Jameso_0
Posts: 52
Joined: 14 Oct 2015, 22:37

Re: List Item contains Pipe Symbol Vertical bar What should I do ?

09 Aug 2016, 23:21

Wow ! Thanks Two reply .. Awesome ..

Thanks Masonjar and imustbeamoron
I am gonna try both methods Now.
hunter99
Posts: 128
Joined: 20 Jan 2014, 17:57

Re: List Item contains Pipe Symbol Vertical bar What should I do ?

10 Aug 2016, 00:24

Hi, Jameso_0;
While imustbeamoron's post will certainly do the job, be aware that if you have a " * " in your list it will fail.
Your quote
Content of the list.txt ( list is quite bigger that this, which includes numerous math symbols , emoji and other Unicode Characters )
Makes me think you will. Try this list.
Spoiler
I would change the code to this.

Code: Select all

FileRead , item_list , %A_ScriptDir%\list.txt
Loop , parse , item_list		;,`r,`n   Don't need
	item .= A_LoopField			; . "*"	Don't need		; . "|"	 Don't need
Gui, +delimiter`n				;This you need			;* don't need
Gui , Add , Combobox, gselected vitem x5 y5 h75 w400 r15 , %item%
GuiControl, Choose, item, 1
Gui , Show
return
 
GuiClose:
ExitApp
 
selected:
Gui, submit,nohide
sleep 100
clipboard := item
Msgbox, %clipboard%
Note: That the list shown has a multiply symbol and some spaces.
good luck, hunter99
Jameso_0
Posts: 52
Joined: 14 Oct 2015, 22:37

Re: List Item contains Pipe Symbol Vertical bar What should I do ?

23 Aug 2016, 07:04

Code: Select all

+delimiter`n
cool hunter I never thought of this ! Its really Good.
I tested the script it worked.

Thanks for your help everybody , it really helped ! :dance:

Return to “Ask For Help”

Who is online

Users browsing this forum: AHKStudent, anhnha, Bacon19331, Bing [Bot], Google [Bot], littlegandhi1199, Marius I, stiuna, Xeo786 and 45 guests