Sign in to follow this  
Followers 0
melf

Loading sections by "section" & $i

5 posts in this topic

Hi

SmOke_N ( thx man ) gave me the solution to the problem i had to list files in a folder with this script

#Include <File.au3>
#include <GuiConstants.au3>

Global $autobus[21]
Global $FileList=_FileListToArray("C:\Imladris Database\Autobus\")
$main = GuiCreate("Liste Autobus", 800, 600,-1, -1 )
$label1 = GUICtrlCreateLabel("Number", 10, 32)
$nombres = GUICtrlCreateInput("", 96, 32, 30, 20)
For $i = 1 To UBound($FileList) - 1
    If $i > 20 Then ExitLoop; If the file has more than 20 files, it will only list the first 20
    $autobus[$i] = GUICtrlCreateInput("", 96, 32 + ($i * 20), 130, 20)
    GUICtrlSetData($autobus[$i], $FileList[$i])
Next
GUICtrlSetData($nombres, $FileList[0])

GuiSetState()
While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    Case Else
   ;;;
    EndSelect
WEnd

I modified it so it writes down all the shown info in a .ini file with different sections for each

#Include <File.au3>
#include <GuiConstants.au3>
Global $FileList=_FileListToArray("C:\Imladris Database\Autobus\")
For $i = 1 To UBound($FileList) - 1
    $var1 = "section" & $i
    IniWrite("C:\myfile.ini", $var1, "info", $FileList[$i])
Next

The problem im having now is to load back the info of each section per file..what i mean by that is the each file name is saved to a different section number , example :

[section1]

info=test1.txt

[section2]

info=test2.txt

[section3]

info=test3.txt

And what i want to GUI to do is load the section info from each different file in an edit box without having to write down 800 lines for 40 boxes..for the moment i have to build something like this with what i understood

GuiCreate("ListeAutobus", 640, 480,-1, -1 , BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS))
$joueur1 = GUICtrlCreateInput("", 96, 52, 130, 20) 
$joueur2 = GUICtrlCreateInput("", 96, 72, 130, 20) 
$joueur3 = GUICtrlCreateInput("", 96, 92, 130, 20) 
;and then load the info of the different .ini into the appropriate edit box
$joueurshow1 =  IniRead("C:\myfile.ini", "section1", "info", "") 
GUICtrlSetData($joueur1, $joueurshow1) 
$joueurshow2 =  IniRead("C:\myfile.ini", "section2", "info", "") 
GUICtrlSetData($joueur2, $joueurshow2) 
$joueurshow3 =  IniRead("C:\myfile.ini", "section3", "info", "") 
GUICtrlSetData($joueur3, $joueurshow3)

In other words i think theres a way to add something along the lines of

$joueurload = $joueurshow & $i
    $var1 = "section" & $i
    $joueurload = IniReadSection("C:\myfile.ini", $var1, "info", "")

Obviously this dosent work..but i hope it helps explaining what my problem is..i have to load the file names in one collumn to see the player name so the script loads the telephone number in the second row by the name of the cases in the first one..in other words its something like this

$joueur1 = GUICtrlCreateInput("", 96, 52, 130, 20) 
$joueur2 = GUICtrlCreateInput("", 96, 72, 130, 20) 
$joueur3 = GUICtrlCreateInput("", 96, 92, 130, 20) 
$telephone1 = GUICtrlCreateInput("", 296, 52, 130, 20) 
$telephone2 = GUICtrlCreateInput("", 296, 72, 130, 20) 
$telephone3 = GUICtrlCreateInput("", 296, 92, 130, 20) 
$joueurshow1 =  IniRead("C:\myfile.ini", "section1", "info", "") 
GUICtrlSetData($joueur1, $joueurshow1) 
$joueurshow2 =  IniRead("C:\myfile.ini", "section2", "info", "") 
GUICtrlSetData($joueur2, $joueurshow2) 
$joueurshow3 =  IniRead("C:\myfile.ini", "section3", "info", "") 
GUICtrlSetData($joueur3, $joueurshow3) 
$telephoneshow1 =  IniRead("$joueur1", "telephone", "info", "") 
GUICtrlSetData($telephone1, $telephoneshow1) 
$telephoneshow2 =  IniRead("$joueur2", "telephone", "info", "") 
GUICtrlSetData($telephone2, $telephoneshow2) 
$telephoneshow3 =  IniRead("$joueur3", "telephone", "info", "") 
GUICtrlSetData($telephone3, $telephoneshow3)

has you can see..in this way id have to code a *&%*% load of lines to do this..and im pretty sure there's a much easier way to show 4 collumns of 20 edit boxes each..

Any help would be appreciated

Share this post


Link to post
Share on other sites



I wonder, why do they all have to be in different sections in the first place? Why not put all the files into one section? Why not one section and info1, info2, etc. ?

Anyway, in a loop:

$joueurload = IniRead("C:\myfile.ini", $var1, "info", "")

would work.

-mu

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

If I understand what you're doing and where you want to go, I'd recommend a Database. A Database can house all of your reads and writes realtime and not have to read, re-write, and save over a number of existing files in a folder.

Edited by PerryRaptor

Share this post


Link to post
Share on other sites

im having troubles with loops

could you give me an example im more visual then intellectual it seems.. :">

Database?is there an example somewhere?

Share this post


Link to post
Share on other sites

SmOke gave you a loop to work with...

out of that you created your own "write to ini" loop

just do the same for "ini read" and for Guictrlsetdata

8)


NEWHeader1.png

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  
Followers 0