Sign in to follow this  
Followers 0
mdwerne

A better way to display a line read from a file?

8 posts in this topic

Hello,

I am trying to display the date and revision of Norton Antivirus Definitions:

The file with the info is here: "C:\Program Files\Common Files\Symantec Shared\VirusDefs\definfo.dat"

and contains these three lines only:

[DefDates]

CurDefs=20080811.016

LastDefs=20080810.022

So...what I have so far (which stinks) is this:

Dim $aRecords
If Not _FileReadToArray("C:\Program Files\Common Files\Symantec Shared\VirusDefs\definfo.dat", $aRecords) Then
    MsgBox(4096, "Error", " Error determining date of AntiVirus Definitions" & @error)
    Exit
EndIf
For $x = 1 To $aRecords[0]
Next
$CurDefs = $aRecords[2]

Needless to say when I display it it's just plain ugly.

$AVDefs = GUICtrlCreateInput($CurDefs, 25, 100, 450, 30)

Can anyone suggest how I might better grab the data and format it more logically?

Current Definition File: 08/11/2008
Revision: 016

I tried playing with StringRegExp but could not get the pattern matching correct.

Thanks for any suggestions.

-Mike

Share this post


Link to post
Share on other sites



#include <File.au3>
$PATH = "C:\Program Files\Common Files\Symantec Shared\VirusDefs\definfo.dat"
$FILE = FileOpen($PATH,0)
$DATA = ""
For $INDEX = 1 To _FileCountLines($PATH)
    $DATA &= FileReadLine($FILE,$INDEX) & @CRLF
Next
MsgBox(0,"DEF INFO",$DATA)


When the words fail... music speaks

Share this post


Link to post
Share on other sites

Just use the IniRead() function which should work fine too. :P

Yep, that worked GREAT!! :P

$var = IniRead("C:\Program Files\Common Files\Symantec Shared\VirusDefs\definfo.dat", "DefDates", "CurDefs", "NotFound")
MsgBox(4096, "Result", $var)

Can you now point me toward how I might rearrange the result from: "20080811.016" to "08/11/2008 Rev. 016"?

Thanks Jos, this is one way cool tool!

-Mike

Share this post


Link to post
Share on other sites

Yep, that worked GREAT!! :P

$var = IniRead("C:\Program Files\Common Files\Symantec Shared\VirusDefs\definfo.dat", "DefDates", "CurDefs", "NotFound")
MsgBox(4096, "Result", $var)

Can you now point me toward how I might rearrange the result from: "20080811.016" to "08/11/2008 Rev. 016"?

Thanks Jos, this is one way cool tool!

-Mike

$TIME = "20080811.016"
$REV = StringSplit($TIME,".")
$NEW = StringMid($TIME,5,2) & "/" & StringMid($TIME,7,2) & "/" & StringLeft($TIME,4) & " Rev. " & $REV[2]
MsgBox(0,"",$NEW)

When the words fail... music speaks

Share this post


Link to post
Share on other sites

$TIME = "20080811.016"
$REV = StringSplit($TIME,".")
$NEW = StringMid($TIME,5,2) & "/" & StringMid($TIME,7,2) & "/" & StringLeft($TIME,4) & " Rev. " & $REV[2]
MsgBox(0,"",$NEW)
Shazam!

Exactly what the Dr. ordered! Thanks Andreik for your great suggestion. :P

Putting the suggestions together, I now have this.

$RAWDEFS = IniRead("C:\Program Files\Common Files\Symantec Shared\VirusDefs\definfo.dat", "DefDates", "CurDefs", "NotFound")
$REV = StringSplit($RAWDEFS,".")
$DEFS = StringMid($RAWDEFS,5,2) & "/" & StringMid($RAWDEFS,7,2) & "/" & StringLeft($RAWDEFS,4) & " Rev. " & $REV[2]
MsgBox(0,"",$DEFS)

Mucho apreciado!

-Mike

Share this post


Link to post
Share on other sites

Yep, that worked GREAT!! :P

$var = IniRead("C:\Program Files\Common Files\Symantec Shared\VirusDefs\definfo.dat", "DefDates", "CurDefs", "NotFound")
 MsgBox(4096, "Result", $var)

Can you now point me toward how I might rearrange the result from: "20080811.016" to "08/11/2008 Rev. 016"?

Thanks Jos, this is one way cool tool!

-Mike

;Convert YYYYMMDD.RRR to MM/DD/YYYY Rev. RRR
$original = "20080811.016"
$new = StringRegExpReplace($original, "\A(\d{4})(\d{2})(\d{2})\.(\d{3})","$2/$3/$1 Rev. $4")

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  
Followers 0