Jump to content
Sign in to follow this  
tor34

Find last text

Recommended Posts

tor34

Hello

First I would like to thank you for this amazing tool. I just started scripting and it's going pritty good but now I have a problem. I hope you can help.

I have a text file with full of text and I need to get the name of the last one trading with me. In this case it would be Daddyd. I know how to find "Trading with..." line but i just need the last one, so how do i do this? Sorry for my bad english.

Log.txt looks like this:

["#0000000040000003#","Tell Messages","Daddyd",1179706171]zup?

["#0000000040000001#","System","",1179706227]Trading with Tinga.

["#0000000040000001#","System","",1179706246]Trading with Daddyd.

["#0000000040000003#","Tell Messages","Daddyd",1179706268]hello mate!

["#0000000040000001#","System","",1179706306]Trading with Daddyd.

["#0000000040000001#","System","",1179706956]Trading with Halli.

["#0000000040000001#","System","",1179707003]Trading with Tinga.

["#0000000040000001#","System","",1179707053]Trading with Baddi3.

["#0000000040000001#","System","",1179707115]Trading with Daddyd.

["#0000000040000001#","System","",1179707173]Trading with Daddyd.

["#0000000040000001#","System","",1179709014]Kritic vanished.

["#0000000040000001#","System","",1179709015]Kritic became visible...

["#0000000040000001#","System","",1179709207]Kritic vanished.

Share this post


Link to post
Share on other sites
November

Hello

First I would like to thank you for this amazing tool. I just started scripting and it's going pritty good but now I have a problem. I hope you can help.

I have a text file with full of text and I need to get the name of the last one trading with me. In this case it would be Daddyd. I know how to find "Trading with..." line but i just need the last one, so how do i do this? Sorry for my bad english.

Log.txt looks like this:

["#0000000040000003#","Tell Messages","Daddyd",1179706171]zup?

["#0000000040000001#","System","",1179706227]Trading with Tinga.

["#0000000040000001#","System","",1179706246]Trading with Daddyd.

["#0000000040000003#","Tell Messages","Daddyd",1179706268]hello mate!

["#0000000040000001#","System","",1179706306]Trading with Daddyd.

["#0000000040000001#","System","",1179706956]Trading with Halli.

["#0000000040000001#","System","",1179707003]Trading with Tinga.

["#0000000040000001#","System","",1179707053]Trading with Baddi3.

["#0000000040000001#","System","",1179707115]Trading with Daddyd.

["#0000000040000001#","System","",1179707173]Trading with Daddyd.

["#0000000040000001#","System","",1179709014]Kritic vanished.

["#0000000040000001#","System","",1179709015]Kritic became visible...

["#0000000040000001#","System","",1179709207]Kritic vanished.

Hi there and welcome :)

Its really easy :

#include <File.au3>

Dim $allfiles

$path = "c:\test.txt" ; your file
_FileReadToArray($path,$allfiles ); puts the file context in an array
$lastline = Ubound($allfiles) -1 ;gives you the all the records in ubound, the last one is the last line
$result = FileReadLine($path, $lastline);reads the last line
MsgBox(0, "test", $result)

Cheers


Old Scriptology

Visual Ping 1.8 - Mass Ping Program with export to txt delimited.

Desktop 2 RGB and YMCK - Pick a color in the desktop and get the RGB and YMCK code.

Desktop 2 RGB - Pick a color in the desktop and get the RGB code.

ShootIT 1.0 - Screen Capture full and partial screen

[font="'Arial Black';"]Remember Remember The Fifth of November.[/font]

Share this post


Link to post
Share on other sites
tor34

wow that was fast, thank you! :)

How do I get only the name of the one who traded me last? like in a textbox or someting

Share this post


Link to post
Share on other sites
November

wow that was fast, thank you! :)

How do I get only the name of the one who traded me last? like in a textbox or someting

Hi again,

Do you mean having a GUI and send the result to a editbox?

#include <File.au3>
#include <GuiConstants.au3>
Dim $allfiles

$path = "c:\test.txt" ; your file
_FileReadToArray($path,$allfiles ); puts the file context in an array
$lastline = Ubound($allfiles) -1 ;gives you the all the records in ubound, the last one is the last line
$result = FileReadLine($path, $lastline);reads the last line
;MsgBox(0, "test", $result)

GUICreate("test", 200, 100)
$edit = GUICtrlCreateEdit("" , 10, 10, 100, 20, $ES_READONLY, -1)
$update = GUICtrlCreateButton("Update", 70, 40, 70, 40)
GUISetState()

while 1
    $msg = GUIGetMsg()
        select 
            case $msg = $GUI_EVENT_CLOSE 
                Exit
            case $msg = $update
                GUICtrlSetData($edit,$result)
        EndSelect
    Sleep(10)
WEnd

Cheers


Old Scriptology

Visual Ping 1.8 - Mass Ping Program with export to txt delimited.

Desktop 2 RGB and YMCK - Pick a color in the desktop and get the RGB and YMCK code.

Desktop 2 RGB - Pick a color in the desktop and get the RGB code.

ShootIT 1.0 - Screen Capture full and partial screen

[font="'Arial Black';"]Remember Remember The Fifth of November.[/font]

Share this post


Link to post
Share on other sites
tor34

Hi, thanks again. No thats not it. I just need a scripts that looks in the text file for the last one who traded me. I know how to find text in a file but if i try to look for "Trading..." I get everyones names, i just want the last one.

So i need a script thats looks thru the log file like the one in my first post. So the result would be Daddyd.

Hard to explain but thanks for trying!

Share this post


Link to post
Share on other sites
November

Hi, thanks again. No thats not it. I just need a scripts that looks in the text file for the last one who traded me. I know how to find text in a file but if i try to look for "Trading..." I get everyones names, i just want the last one.

So i need a script thats looks thru the log file like the one in my first post. So the result would be Daddyd.

Hard to explain but thanks for trying!

Hi again,

I think i understand whats your need...

You'll have to "play" with strings.

with some code its better :)

If you need help just say!


Old Scriptology

Visual Ping 1.8 - Mass Ping Program with export to txt delimited.

Desktop 2 RGB and YMCK - Pick a color in the desktop and get the RGB and YMCK code.

Desktop 2 RGB - Pick a color in the desktop and get the RGB code.

ShootIT 1.0 - Screen Capture full and partial screen

[font="'Arial Black';"]Remember Remember The Fifth of November.[/font]

Share this post


Link to post
Share on other sites
Davo

Hi, the way to do it is:

#include<File.au3>
$fileHandle = FileOpen("C:\test.txt",0)
$numberOfLines = _filecountlines("C:\test.txt")
For $i = $numberOfLines To 1 Step -1
$text = StringTrimLeft(FileReadLine($fileHandle,$i),45)
If StringLeft($text,13) == "Trading with " Then
$tradingWith = StringTrimRight(StringTrimLeft($text,13),1)
MsgBox(0,"",$TradingWith)
ExitLoop
EndIf
Next
FileClose($fileHandle)
Exit

Edit: Initial code didn't work, but its working now :)

Enjoy

Dave.

Edited by Davo

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------"I don't need to know everything, I just need to know where to find it when I need it"....EinsteinAnd in our case... That's the AutoIT helpfile ;) Please read before posting!!!

Share this post


Link to post
Share on other sites
Xenobiologist

Hi,

$found = StringRegExp(FileRead(FileOpen(@ScriptDir & '\log.txt', 0)), '(?<=Trading with )\w{1,}', 3)
If IsArray($found) Then MsgBox(64, 'Found', $found[UBound($found) - 1 ])

So long,

Mega


Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×