Jump to content

reading from a txt file


Recommended Posts

I nedd to be able to have my script go through a text that has a setup like this

server1

server2

server3

and plug in each one in the box i tell it to using the

Send()

command or a simliar command and then log what happens after each one. How would i got about doing this.

any help is greatly appreciated.

Edited by doomkiller
Link to comment
Share on other sites

I would start with FileRead() and FileReadLine()

<{POST_SNAPBACK}>

I'd actually read the file into an array first then manipulate, It's much faster if you do it this way. Here is an example of how I would do it. I didn't add any error checking, but you would want to.

I didn't understand your send question for the server though.

; ----------------------------------------------------------------------------
;
; AutoIt Version: 3.1.0
; Author:         Kerberuz
;
; Script Function:
;    Read from file, create combobox
;
; ----------------------------------------------------------------------------

; Script Start - Add your code below here
#include <File.au3>
#include <GUIConstants.au3>
Dim $aFile
$i = 1
_FileReadToArray ( "Filetoread.txt", $aFile )

GUICreate("Read from file, then create a combobox"); will create a dialog box that when displayed is centered

GUICtrlCreateCombo (StringReplace($aFile[1], @CR, ""), 10,10); create first item
Do
    $aFile[$i] = StringReplace($aFile[$i], @CR, "")
    GUICtrlSetData(-1, $aFile[$i]); add new items that were read from file
   $i = $i + 1
Until $i = $aFile[0] + 1

GUISetState ()

; Run the GUI until the dialog is closed
While 1
    $msg = GUIGetMsg()
    
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
Wend

Filetoread.txt

Edited by Kerberuz

Kerby

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