Jump to content
Sign in to follow this  
BrettF

GetTheText in a File

Recommended Posts

BrettF

Say i have the following text (the file is one line with other enterys...) in a file:

SerialNumber: xxxxxxxxxxx

The serial number is for my ipod... how can i get the xxxxxxxxxxx? Im not sure how?

Thanxs

Share this post


Link to post
Share on other sites
hearurscream

Search the Help File for FileOpen() and FileReadLine().


Infinity is a floorless room without walls or ceiling.Anyone who cannot cope with mathematics is not fully human. At best he is a tolerable subhuman who has learned to wear shoes, bathe, and not make messes in the house.

Share this post


Link to post
Share on other sites
BrettF
BrettF
hearurscream

FileOpen ( "filename", mode )

Parameters

filename Filename of the text file to open.

mode Mode (read or write) to open the file in.

Can be a combination of the following:

0 = Read mode

1 = Write mode (append to end of file)

2 = Write mode (erase previous contents)

4 = Read raw mode

8 = Create directory structure if it doesn't exist (See Remarks).

Both write modes will create the file if it does not already exist. The folder path must already exist (except using mode '8' - See Remarks).

And then use FileReadLine() to read whichever line of the document the serial is.


Infinity is a floorless room without walls or ceiling.Anyone who cannot cope with mathematics is not fully human. At best he is a tolerable subhuman who has learned to wear shoes, bathe, and not make messes in the house.

Share this post


Link to post
Share on other sites
BrettF
BrettF

Or not...

_StringBetween didnt work... :whistle:

The Code I Tried:

Func _GetIpods ($listview)
    $DriveGet = DriveGetDrive("REMOVABLE")
    For $i = 1 to $DriveGet[0]
    If FileExists ($DriveGet[$i] & "\iPod_Control\Device\SysInfo") Then ;SysInfo is just a file with no extention... 
        Msgbox(0,"","It is infact the ipod drive")
        $file = FileOpen ($DriveGet[$i] & "\iPod_Control\Device\SysInfo", 0)
        If $file = -1 Then
            Msgbox(0,"","Error Opening File")
        EndIf
        $line = FileRead ($File, 1)
        $Serial = _StringBetween ($line, "SerialNumber:", "ModelNumStr:")
        IF $Serial = 1 or $serial = 0 Then
            Msgbox(0,"","Error Getting Serial")
        Else
    MsgBox (9, "", "The Serial Number is:" & $Serial)
    EndIf
    EndIf
Next
EndFunc

Edit: Missed a bit...

Edited by bert

Share this post


Link to post
Share on other sites
hearurscream

Umm.. well you put the msgbox() command after the Else statement. Put it outside the 2nd EndIf.. that should fix your problem, unless there is a different problem with StringBetween()


Infinity is a floorless room without walls or ceiling.Anyone who cannot cope with mathematics is not fully human. At best he is a tolerable subhuman who has learned to wear shoes, bathe, and not make messes in the house.

Share this post


Link to post
Share on other sites
BrettF
hearurscream

And also, you have to #include <String.au3> :whistle:


Infinity is a floorless room without walls or ceiling.Anyone who cannot cope with mathematics is not fully human. At best he is a tolerable subhuman who has learned to wear shoes, bathe, and not make messes in the house.

Share this post


Link to post
Share on other sites
Thatsgreat2345

and or you can try stringregexp

Share this post


Link to post
Share on other sites
BrettF

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.