Jump to content

Quick Help


Vowles
 Share

Recommended Posts

Basicly I have a text file, Heres a preview of the start.

[X1]Ben[X]

[X2]Ted[X]

[X3]Fred[X]

Basicily I wanted to make a loop that Gets the "Ben","Ted" and "Fred". I came up with this.

$x = _InetGetSource("www.vowlesy.com/Xfire.txt")
        $A = 100
        $e = 0
        While $A >= 0
            
            $e = $e + 1
            
            $C = _StringBetween($x,"[X"& $e &"]","["& $e &"]")
            MsgBox(0,"we",$WE)
            MsgBox(0,"",$C)         
            if $C = "" Then
                MsgBox(0,"Xfire 5punk Adder","No more people")
                $A = 1
                exit
            endif




Func _StringBetween($s,$from,$to)

$x=StringInStr($s,$from)+StringLen($from)
$y=StringInStr(StringTrimLeft($s,$x),$to)

Return StringMid($s,$x,$y)
EndFunc
Link to comment
Share on other sites

maybe like this

$get_source = "[X1]Ben[X]"
$Callsign = _StringBetween($get_source, ']', '[X]')
MsgBox(0, "", "Callsign: " &$Callsign)

Func _StringBetween($s,$from,$to)
$x=StringInStr($s,$from)+StringLen($from)
$y=StringInStr(StringTrimLeft($s,$x),$to)
Return StringMid($s,$x,$y)
EndFunc

8)

NEWHeader1.png

Link to comment
Share on other sites

maybe this

#include <File.au3>

$sloc = "C:\Temp\Xfire.txt"

$slen = _FileCountLines($sloc)

$sFile = FileOpen($sloc, 0)

For $sx = 1 to $slen
    if @error = -1 then ExitLoop
    $get_source = FileReadLine($sFile)
    $Callsign = _StringBetween($get_source, ']', '[X]')
    MsgBox(0, "", "Callsign: " &$Callsign)
Next



Func _StringBetween($s,$from,$to)
$x=StringInStr($s,$from)+StringLen($from)
$y=StringInStr(StringTrimLeft($s,$x),$to)
Return StringMid($s,$x,$y)
EndFunc

8)

NEWHeader1.png

Link to comment
Share on other sites

$LocalFileName = "C:\Xfire.txt"

InetGet("http://www.vowlesy.com/Xfire.txt", $LocalFileName)

$file = FileOpen($LocalFileName, 0)

; Check if file opened for reading OK
If $file = -1 Then
    MsgBox(0, "Error", "Unable to open file.")
    Exit
EndIf

; Read in lines of text until the EOF is reached
While 1
    $line = FileReadLine($file)
    If @error = -1 Then ExitLoop
    MsgBox(0, "Line read:", $line)
    MsgBox(0, "Line read:", _StringBetween($line, "]", "["))
WEnd

FileClose($file)


Func _StringBetween($s, $from, $to)
    
    $x = StringInStr($s, $from) + StringLen($from)
    $y = StringInStr(StringTrimLeft($s, $x), $to)
    
    Return StringMid($s, $x, $y)
EndFunc  ;==>_StringBetween

Link to comment
Share on other sites

how about this ?

Func _INetGetSource($s_URL, $s_Header = '')
    Local $h_DLL = DllOpen("wininet.dll"), $ai_IO, $ai_IOU, $ai_ICH, $ai_IRF[5] = [0, 0, '', 0, 1], $s_Buf = ''
    $ai_IO = DllCall($h_DLL, 'int', 'InternetOpen', 'str', "AutoIt v3", 'int', 0, 'str', '', 'str', '', 'int', 0)
    If @error Or $ai_IO[0] = 0 Then
        DllClose($h_DLL)
        SetError(1)
        Return 0
    EndIf
    $ai_IOU = DllCall($h_DLL, 'int', 'InternetOpenUrl', 'int', $ai_IO[0], 'str', $s_URL, 'str', $s_Header, 'int', StringLen($s_Header), 'int', 0x80000000, 'int', 0)
    If @error Or $ai_IOU[0] = 0 Then
        DllCall($h_DLL, 'int', 'InternetCloseHandle', 'int', $ai_IO[0])
        DllClose($h_DLL)
        SetError(1)
        Return 0
    EndIf
    Local $v_Struct = DllStructCreate('udword')
    While $ai_IRF[4] <> 0
        $s_Buf &= StringMid($ai_IRF[2], 1, $ai_IRF[4])
        $ai_IRF = DllCall($h_DLL, 'int', 'InternetReadFile', 'int', $ai_IOU[0], 'str', "", 'int', 256, 'ptr', DllStructGetPtr($v_Struct, 1))
        $ai_IRF[4] = DllStructGetData($v_Struct, 1)
    WEnd
    DllStructDelete($v_Struct)
    DllCall($h_DLL, 'int', 'InternetCloseHandle', 'int', $ai_IOU[0])
    DllCall($h_DLL, 'int', 'InternetCloseHandle', 'int', $ai_IO[0])
    DllClose($h_DLL)
    Return $s_Buf
EndFunc ;==>_INetGetSource

$as_parsed = StringRegExp(_INetGetSource('http://www.vowlesy.com/Xfire.txt'), '\[X\d*\](.*?)\[X\]', 3)

;this is ofcourse optionaly, the real script is the 1 line above;)
#include <Array.au3>
_ArrayDisplay($as_parsed, '')
Edited by w0uter

My UDF's:;mem stuff_Mem;ftp stuff_FTP ( OLD );inet stuff_INetGetSource ( OLD )_INetGetImage _INetBrowse ( Collection )_EncodeUrl_NetStat_Google;random stuff_iPixelSearch_DiceRoll

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