Jump to content
Sign in to follow this  
fatalcoder

Array

Recommended Posts

fatalcoder

Func load()
Local $PATH, $FILE, $INDEX, $LINE, $DATA
 $PATH = FileOpenDialog("Load ", @DesktopDir & "\", "List  Format(*.txt)", 1)
        GUICtrlSetData($Input2,_FileCountLines($PATH))
If Not @error Then
    $FILE = FileOpen($PATH,0)
    $INDEX = 1
    While True

        $LINE = FileReadLine($FILE,$INDEX)
        If @error Then ExitLoop
        $DATA = StringSplit($LINE,":")
        If IsArray($DATA) Then
            If $DATA[0] = 2 Then
                GUICtrlCreateListViewItem($DATA[1] & "|" & $DATA[2],$ListView1)

EndIf
EndIf
        
        $INDEX += 1

    WEnd
    FileClose($FILE)
EndIf
EndFunc

and tried to read each issue of $data[1] array, but fail to be grateful if you help me,after first reading will be read the second

Share this post


Link to post
Share on other sites
BrettF
fatalcoder

Sample text please.

I like to fisier.txt username: password and I log in I want everybody after he logged in a row to log the two (Sorry but no English version of Google Translate)

Share this post


Link to post
Share on other sites
BrettF
fatalcoder

Just create something I can test with. Otherwise I have no idea what your script is even trying to do.

Cheers,

Brett

So I want to connect to a server with username and password with all the row,I just want to tell me how I can login to each take turns with its array turns

Share this post


Link to post
Share on other sites
XKahn

Make sure you are using;

#include <Array.au3>

and

Local $PATH, $FILE, $INDEX, $LINE, $DATA[3]

Hope that helps your array.

However I think this could be done without the array at all using;

if StringInStr($line, ":") <> 0 Then
    $n = StringInStr($line, ":")
    $data = StringLeft($line, $n-1)  
EndIf
Edited by XKahn

Share this post


Link to post
Share on other sites
fatalcoder

Make sure you are using;

#include <Array.au3>

and

Local $PATH, $FILE, $INDEX, $LINE, $DATA[3]

Hope that helps your array.

logs only the last read

Edited by fatalcoder

Share this post


Link to post
Share on other sites
XKahn

logs only the last read

Is it my understanding that your text file is in this format?

USER_ID:USER_PASSWORD

USER_ID:USER_PASSWORD

USER_ID:USER_PASSWORD

USER_ID:USER_PASSWORD

BrettF and I are just guessing at what you have given us. We really need the file format you are feeding this function.

Share this post


Link to post
Share on other sites
fatalcoder

yes is this USER_ID:USER_PASSWORD

Func loadbots()
$PATH = FileOpenDialog("Load Bots list", @DesktopDir & "\", "Bots List bot:pass Format(*.txt)", 1)
        GUICtrlSetData($Input2,_FileCountLines($PATH))
If Not @error Then
    $FILE = FileOpen($PATH,0)
    $INDEX = 1
    While True

        $LINE = FileReadLine($FILE,$INDEX)

if StringInStr($line, ":") <> 0 Then
    $n = StringInStr($line, ":")
    $DATA = StringLeft($line, $n-1)
EndIf
        If IsArray($DATA) Then
            If $DATA[0] = 2 Then
                GUICtrlCreateListViewItem($DATA[1] & "|" & $DATA[2],$ListView1)



$ALIAS=$DATA[1]
$PASSWORD=$DATA[2]



EndIf
        EndIf
        $INDEX += 1

    WEnd
    FileClose($FILE)
EndIf
EndFunc
Edited by fatalcoder

Share this post


Link to post
Share on other sites
MvGulik

[OffTopic]Mmm. Might get interesting. (Seems to aiming for two out of two.)

yes is this USER_ID:USER_PASSWORD

Func loadbots()
$PATH = FileOpenDialog("Load Bots list", @DesktopDir & "\", "Bots List bot:pass Format(*.txt)", 1)
        GUICtrlSetData($Input2,_FileCountLines($PATH))
If Not @error Then
    $FILE = FileOpen($PATH,0)
    $INDEX = 1
    While True

        $LINE = FileReadLine($FILE,$INDEX)

if StringInStr($line, ":") <> 0 Then
    $n = StringInStr($line, ":")
    $DATA = StringLeft($line, $n-1)
EndIf
        If IsArray($DATA) Then
            If $DATA[0] = 2 Then
                GUICtrlCreateListViewItem($DATA[1] & "|" & $DATA[2],$ListView1)



$ALIAS=$DATA[1]
$PASSWORD=$DATA[2]



EndIf
        EndIf
        $INDEX += 1

    WEnd
    FileClose($FILE)
EndIf
EndFunc

[/OffTopic]


"Straight_and_Crooked_Thinking" : A "classic guide to ferreting out untruths, half-truths, and other distortions of facts in political and social discussions."
"The Secrets of Quantum Physics" : New and excellent 2 part documentary on Quantum Physics by Jim Al-Khalili. (Dec 2014)

"Believing what you know ain't so" ...

Knock Knock ...
 

Share this post


Link to post
Share on other sites
BrewManNH

yes is this USER_ID:USER_PASSWORD

Func loadbots()

$PATH = FileOpenDialog("Load Bots list", @DesktopDir & "\", "Bots List bot:pass Format(*.txt)", 1)

GUICtrlSetData($Input2,_FileCountLines($PATH))

Bots list?

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites
XKahn

Then this code might work for you. It will look for temp.txt inside the working directory.

#include <GuiConstantsEx.au3>
#include <GuiListView.au3>

Global $hListView

If FileExists ("temp.txt") Then
    GUICreate("ListView Add Item", 400, 300)
    $hListView = GUICtrlCreateListView("", 50, 15, 300, 270)
    _GUICtrlListView_SetUnicodeFormat($hListView, False)
    _GUICtrlListView_InsertColumn($hListView, 0, "User ID", 145)
    _GUICtrlListView_InsertColumn($hListView, 1, "Password", 145)
    Load_Settings ()
    GuiSetState()
    $msg = GUIGetMsg()
    
    While $msg <> $GUI_EVENT_CLOSE
        $msg = GUIGetMsg()
    WEnd
Else
    MsgBox (0,"ERROR!", "File Not Found")
EndIf

Func Load_Settings ()
    $setup = FileOpen ("temp.txt",0)
    $line = FileReadLine($setup)
    $index = 0
    While Not @error = -1
        if StringInStr($line, ":") <> 0 Then
            $n = StringInStr($line, ":")
            $uid = StringLeft($line, $n-1)
            $pass = StringRight($line,StringLen($line)-$n)
            _GUICtrlListView_AddItem($hListView, $uid, $index)
            _GUICtrlListView_AddSubItem($hListView, $index, $pass, 1)
        EndIf
        $index += 1
        $line = FileReadLine($setup)
    WEnd
    FileClose($setup)
EndFunc

Share this post


Link to post
Share on other sites
fatalcoder

Func loadbots()
    $setup = FileOpen ("botlist.txt",0)
    $line = FileReadLine($setup)
    $index = 0
    While Not @error = -1
        if StringInStr($line, ":") <> 0 Then
            $n = StringInStr($line, ":")
            $uid = StringLeft($line, $n-1)
            $pass = StringRight($line,StringLen($line)-$n)
            _GUICtrlListView_AddItem($ListView1, $uid, $index)
            _GUICtrlListView_AddSubItem($ListView1, $index, $pass, 1)
    $ALIAS=$uid 
    $PASSWORD=$pass 
        EndIf
        $index += 1
        $line = FileReadLine($setup)
    WEnd
    FileClose($setup)
EndFunc

read all the latest log in

Share this post


Link to post
Share on other sites
XKahn

read all the latest log in

Here is an example of my temp.txt with the exact same code I gave to you above.

MACHO:123456    
MACINTOSH:password
MACKEREL:12345678
MACMILLAN:1234  
MADMAX:7777777  
MADAMEBUTTERFLY:12345   
MADURO:dragon   
MAESTRO:qwerty  
MAFIOSO:696969  
MAGGIE:mustang
MAGIC:letmein
MAGNA:baseball
MAGNET:master   
MAGNOLIA:michael
MAGNUM:football
MAGPIE:shadow   
MAHIMAHI:monkey 
MAHOGANY:abc123 
MAITAI:pass 
MAILMAN:apple

At the very bottom it reads "MAILMAN:apple"

post-56127-1282480556101_thumb.jpg

post-56127-12824805656694_thumb.jpg

Share this post


Link to post
Share on other sites
BrettF

Fatalcoder, if you can't accurately describe what your problem is, we can't help. No one here is mind readers. I mean we've done pretty well so far to working out what you want, but if you can't tell us what your final outcome is, we can't help you achieve that.

Next time you post I do expect a better explaination of what you want help with. That does mean typing it all out (using google translate if you need to ;)), showing any examples of code, files. Basically so we can replicate what you need.

#include <GuiConstantsEx.au3>
#include <GuiListView.au3>

Global $hListView

If FileExists("botlist.txt") Then
    GUICreate("ListView Add Item", 400, 300)
    $hListView = GUICtrlCreateListView("", 50, 15, 300, 270)
    _GUICtrlListView_SetUnicodeFormat($hListView, False)
    _GUICtrlListView_InsertColumn($hListView, 0, "User ID", 145)
    _GUICtrlListView_InsertColumn($hListView, 1, "Password", 145)
    loadbots()
    GUISetState()
    $msg = GUIGetMsg()

    While $msg <> $GUI_EVENT_CLOSE
        $msg = GUIGetMsg()
    WEnd
Else
    MsgBox(0, "ERROR!", "File Not Found")
EndIf

Func loadbots()
    $delim = Opt("GUIDataSeparatorChar", ":")
    $sFile = FileRead("botlist.txt")
    $aList = StringSplit($sFile, @CRLF, 1)
    For $iX = 1 To $aList[0]
        If StringInStr($aList[$iX], ":") Then
            GUICtrlCreateListViewItem($aList[$iX], $hListView)
        EndIf
    Next
    Opt("GUIDataSeparatorChar", $delim)
EndFunc   ;==>loadbots

Cheers,

Brett

Edited by BrettF

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  

×

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.