Jump to content

Search text file, return with partial string


mud409
 Share

Recommended Posts

I'm trying to search for a portion of a string in a file, split that string, returning it for use to search an ini file, so I can retrieve yet another value.

Everything works fine, but if it doesn't find "game name" in mame32.lst, it tries to pass a bunk variable to the IniRead. I tried setting variables $isgame 1 and 0 to determine if it exists in mame32.lst, but then I get all sorts of other problems. Kinda stumped here, so anything to push me along.

$file = FileOpen("mame32.lst", 0)

; Check if file opened for reading OK

If $file = -1 Then

MsgBox(0, "Error", "Unable to open file.")

Exit

EndIf

Dim $array

; Read in lines of text until the EOF is reached

While 1

$line = FileReadLine($file)

If @error = -1 Then

$isgame = 0

ExitLoop

EndIf

If StringInStr($line, "game name") Then

$found = 0

For $x = 0 To UBound($array) - 1

If $line == $array[$x] Then

$found = 1

ExitLoop

EndIf

Next

If Not $found Then

If IsArray($array) Then

ReDim $array[uBound($array) + 1]

Else

Dim $array[1]

EndIf

$array[uBound($array) - 1] = $line

EndIf

EndIf

WEnd

For $x = 0 To UBound($array) - 1

$aarayread = StringSplit($array[$x], @TAB)

$blah = $aarayread[1]

$hasgame = IniRead(@scriptdir & "/ini/games.ini", $aarayread[1], "hasroms", "0")

Next

If $hasgame = "0" Then

MsgBox(0, "", "has file")

Else

MsgBox(0, "", "doesn't have file")

EndIf

FileClose($file)

Edited by mud409
Link to comment
Share on other sites

Your topic seem to be at a borderline between legal and ilegal.

Emulators are generaly related to console games to be run on PCs which is often considered ilegal.

I know, you might own the original game and you might be entitled to do such a thing, that's why I said it is between legal and ilegal.

Ilegal stuff is not tolerated around here.

It would be the best idea to not continue this thread, to let it die.

-friendly advice-

SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script

wannabe "Unbeatable" Tic-Tac-Toe

Paper-Scissor-Rock ... try to beat it anyway :)

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...