Jump to content

GetTheText in a File


BrettF
 Share

Recommended Posts

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

Link to comment
Share on other sites

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...