OMG lisbox making me crazy. Help please. Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
AutohotkeyLover
Posts: 4
Joined: 24 Jan 2017, 15:30

OMG lisbox making me crazy. Help please.

09 Nov 2017, 23:01

Hello,

I'm trying to update a listbox from a text file.
I read the text file then try to guicontrol the listbox. The problem is the carriage returns aren't being registered when populating the listbox. It's showing as one line in the listbox.

gui, 3:add, listbox, r20 w200 vattenlist
fileread, readallatten, %userprofile%\managertools\attendance\allatten.txt ;(this file is in a list format)
sort, readallatten, N R
guicontrol, 3:, attenlist, %readallatten%

Any help is appreciated? Probably something simple I'm overlooking.
User avatar
divanebaba
Posts: 805
Joined: 20 Dec 2016, 03:53
Location: Diaspora

Re: OMG lisbox making me crazy. Help please.

10 Nov 2017, 01:03

Hi.
Maybe it is an encoding problem. Try to save allatten.txt in UTF-8 format.
The help says:
*t: Replaces any/all occurrences of carriage return & linefeed (`r`n) with linefeed (`n)
So try the *t parameter like:

Code: Select all

fileread, readallatten, *t %userprofile%\managertools\attendance\allatten.txt
Einfach nur ein toller Typ. :mrgreen:
User avatar
Xeo786
Posts: 760
Joined: 09 Nov 2015, 02:43
Location: Karachi, Pakistan

Re: OMG lisbox making me crazy. Help please.  Topic is solved

10 Nov 2017, 01:31

List element/items have to be seprated with "|"

if aallatten.txt looks like following

Code: Select all

Item1
Item2
Item3
Item4
Item5
Item6
Item7
Item8
Item9
then this can be done via loop parse

Code: Select all

fileread, readallatten, %userprofile%\managertools\attendance\allatten.txt ;(this file is in a list format)
Loop, parse, readallatten, `n, `r
	readallatten_List := readallatten_List "|" A_LoopField

Gui add, listbox, r20 w200 vattenlist, %readallatten_List%
Gui Show
return
or
stringreplace

Code: Select all

fileread, readallatten, %userprofile%\managertools\attendance\allatten.txt ;(this file is in a list format)
StringReplace, readallatten_List, readallatten, `n, |, all

Gui add, listbox, r20 w200 vattenlist, %readallatten_List%
Gui Show
"When there is no gravity, there is absolute vacuum and light travel with no time" -Game changer theory
AutohotkeyLover
Posts: 4
Joined: 24 Jan 2017, 15:30

Re: OMG lisbox making me crazy. Help please.

10 Nov 2017, 09:16

Thank you both! :bravo: :dance: :superhappy: :beer: I ended up with the following

sort, readallatten, N R
Loop, parse, readallatten, `n, `r
readallatten_List := readallatten_List "|" A_LoopField

guicontrol, 3:, attenlist, %readallatten_List%

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Bing [Bot], Bruno, Descolada, JnLlnd, Rohwedder, rubeusmalfoy, Spawnova, taddypole and 189 guests