Jump to content

FileReadLine all lines...


Recommended Posts

22 hours ago, mikell said:

Sorry. My bad, I didn't provide explanations
What my code does is : from a "test.txt" file containing this

red station - 192.168.1.10
yellow station - 192.168.1.11

It first builds a "test.ini" file which content is

[stations]
red station=192.168.1.10
yellow station=192.168.1.11

Then using the IniReadSection function you can directly get a 2D array to use in the script

#Include <Array.au3>
#include <GUIConstants.au3>

; create the ini (for the example)
$newtext = "[stations]" & @crlf & StringReplace(FileRead("test.txt"), " - ", "=")
FileWrite("test.ini", $newtext)
; read to a 2D array
$res = IniReadSection("test.ini", "stations")
; _ArrayDisplay($res)  ; display

GUICreate("QUAL ESTAÇÃO ?", 350, 50)
Local $idCombo = GUICtrlCreateCombo("", 10, 10, 200, 20)
GUICtrlSetData($idCombo, _ArrayToString($res, "|", 1, -1, "|", 0, 0))
GUISetState()

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $idCombo
        For $i = 1 to $res[0][0]
            If GuiCtrlRead($idCombo) = $res[$i][0] Then Msgbox(0,"", $res[$i][1])
        Next
    EndSwitch
Wend

 

Thanks for the explanation...I think I'll try the init way...Because I separated the info into 2 ou 3 .txt files...And one .init file is more beautiful!

Link to comment
Share on other sites

On 2/2/2020 at 11:45 AM, Subz said:

As @mikell mentioned if you can use ini format then you can use the ini... functions

[Instructions]
Red Station = 192.168.1.10
Blue Station = 192.168.1.11

If you need to use that format then you can use RegExp or a number of other options, for example:

I think I'll try .init! I dont NEED exactly...I just need two info and a separator...

FILStations.au3 926 B · 2 downloads

 

Link to comment
Share on other sites

I agree it screams to be an .ini, but if you never use that section other than to read it to an array, is that dance more efficient than something like...

#include<array.au3>
local $a[0][2]
_ArrayAdd($a , stringstripWS(FileRead("FilStations.txt") , 2) , 0 , "-")
_ArrayDisplay($a)

 

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

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