How to display text file in tabular format?

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
asghar5676
Posts: 18
Joined: 22 Aug 2017, 01:24

How to display text file in tabular format?

22 Aug 2017, 01:30

Hi all,

I am very new to AHK. So please pardon me if I am asking basic questions here. I have text file containing several lines like below:

Code: Select all

user1@APD-198Checked out license at 22/08/2017 11:38 AM Hours used: 3:33 
user2@APD-127Checked out license at 22/08/2017 3:07 PM Hours used: 0:04 
user3@APD-200Checked out license at 22/08/2017 3:03 PM Hours used: 0:08 
user4@APD-151Checked out license at 22/08/2017 1:33 PM Hours used: 1:38
I would like to display a MsgBox in format below:

Code: Select all

user1	Hours used: 3:33 
user2	Hours used: 0:04 
user3	Hours used: 0:08 
user4	Hours used: 1:38
I am using code below but obviously I am getting errors:

Code: Select all

user = 
times =
output =  
loop, read, AutohotkeyTemp3.txt
{
	currentLine = %A_LoopReadLine%
	user =  SubStr(currentLine,1,InStr(currentLine,"@",0)-1)
	times = SubStr(currentLine,1,InStr(currentLine,"Hours Used: ",0)-1)
	output .=  %user%.%A_tab%.%times%. "`n"
}
MsgBox %output%
Can someone help me with my medieval code? :?:
wolf_II
Posts: 2688
Joined: 08 Feb 2015, 20:55

Re: How to display text file in tabular format?

22 Aug 2017, 03:33

Try this:

Code: Select all

loop, read, AutohotkeyTemp3.txt
{
	user :=  SubStr(A_LoopReadLine, 1, InStr(A_LoopReadLine, "@") -1)
	times := SubStr(A_LoopReadLine, InStr(A_LoopReadLine, "Hours used: ") -1)
	output .= user "`t" times "`n"
}
MsgBox, %output%
I hope that helps.
asghar5676
Posts: 18
Joined: 22 Aug 2017, 01:24

Re: How to display text file in tabular format?

22 Aug 2017, 04:13

Thanks wolf_II.

It did the trick.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Aqualest, gabelynn1, Spawnova and 174 guests