Sign in to follow this  
Followers 0
Vicks

ini

15 posts in this topic

hi i have a hugh ini how can add all of it in my script fast, you see my ini has like 200 lines and i need to add them in my script but i don't want to write for hours. any scripts or anything to help me this faster


[s]Autoit[/s]

Share this post


Link to post
Share on other sites



hi i have a hugh ini how can add all of it in my script fast, you see my ini has like 200 lines and i need to add them in my script but i don't want to write for hours. any scripts or anything to help me this faster

HI,

what do you mean by add to my script? Read ini ? Check ini?

So long,

Mega


Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites

HI,

what do you mean by add to my script? Read ini ? Check ini?

So long,

Mega

read ini please

[s]Autoit[/s]

Share this post


Link to post
Share on other sites

What is wrong with IniRead? Is it too slow?

So long,

Mega


Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites

What is wrong with IniRead? Is it too slow?

So long,

Mega

no i mean, adding the ini read in my script would be to slow, and i wonder if there something can could do it for me or if theres a quick way of ding this


[s]Autoit[/s]

Share this post


Link to post
Share on other sites

if u wanna make ti write the ini... y not iniwrite?

Share this post


Link to post
Share on other sites

Sorry man,

I don't get what you want. :">

So long,

Mega


Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites

i think he wants a a way to make it easyer and faster for him to make his ini.. but i might be wroung.

Share this post


Link to post
Share on other sites

ok i upload a ini that has 10 numbers in it, now image that i have 200 that can take me a long time to include in my script, so is there a easyer way to add all of them into my script, i think there isn't and i have to do add them manually to my script. but what would you do with a ini that has atleast 200 lines in it how would you add all of the ini reads in your script?

edited won't let me upload an ini so pretend my notepad file is one

myini.txt


[s]Autoit[/s]

Share this post


Link to post
Share on other sites

well first of all thats not how an ini looks but i get what u mean..

$max = 200
for $x = 1 to $max
    IniWrite("myini.ini", "numbers", $x, "")
next

Share this post


Link to post
Share on other sites

well first of all thats not how an ini looks but i get what u mean..

$max = 200
for $x = 1 to $max
    IniWrite("myini.ini", "numbers", $x, "")
next
thanks but what if i had words instead of numbers :whistle:

[s]Autoit[/s]

Share this post


Link to post
Share on other sites

thanks but what if i had words instead of numbers :whistle:

IniReadSection() in the help file (beta).

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

thanks but what if i had words instead of numbers :whistle:

well arnt u going to have to read all the inis?

y not just make it iniwrite then when its wrote.. use the find/replace and make the iniwrite into iniread?

Share this post


Link to post
Share on other sites

#14 ·  Posted (edited)

Is this what you mean?

Const $FileRead = 0, $FileAppend = 1, $FileWrite = 2
Dim $Section = ''
$inifile = @ScriptDir & "\sample.ini"   ; INI file you want to read values from
$inifileH = fileopen($inifile, $FileRead)
$AU3OutH = FileOpen(@ScriptDir & "\sample.au3", $FileWrite) ; Generated AutoIt3 code fragment
$OptionsCount = 0
While 1
    $line = FileReadLine($inifileH)
    If @error = -1 Then ExitLoop
    $line = _TrimSpaces($line)
    If StringLeft($line, 1) = '[' And StringRight($line, 1) = ']' Then
        $Section = StringMid($line, 2, StringLen($line) - 2)    ; Current section name.
    ElseIf StringLeft($line, 1) <> ';' And $Section <> '' And StringInStr($line, '=') Then
        ; This is a value that we want to capture
        $OptionsCount = $OptionsCount + 1
        $Key = _TrimSpaces(StringLeft($line, StringInStr($line, '=') - 1))
        ; Comment out one of the next two lines of code!
        ; This line reads each value into a variable
        FileWriteLine($AU3OutH, '$' & $Section & '_' & $Key & ' = IniRead($inifileH, "' & $Section & '", "' & $Key & '", "")')
        ; This line reads each value into an element of an array
        ;FileWriteLine($AU3OutH, '$OptionsArray[' & $OptionsCount &  '] = IniRead($inifileH, "' & $Section & '", "' & $Key & '", "")')
    EndIf
WEnd


Func _TrimSpaces($text)
    ; Remove leading and trailing spaces from text
    Dim $rec = 0, $newText = ''
    ; Trim leading spaces
    $textA = StringSplit($text, '')
    For $i = 1 to $textA[0]
        If Not ($rec) Then
            If $textA[$i] <> ' ' Then 
                $rec = 1
            EndIf
        EndIf
        If $rec Then 
            $newText = $newText & $textA[$i]
        EndIf
    Next
    ; Trim trailing spaces
    $textA = StringSplit($newtext, '')
    $rec = 0
    $newtext = ''
    For $i = $textA[0] to 1 Step -1
        If Not ($rec) Then
            If $textA[$i] <> ' ' Then 
                $rec = 1
            EndIf
        EndIf
        If $rec Then 
            $newText = $textA[$i] & $newText
        EndIf
    Next
    Return $newText
EndFuncoÝ÷ Øw«z+±©©â
!ø¥yÊxÌ4âïu:{=Ü

Hope this helps.

Edited by bluebearr

BlueBearrOddly enough, this is what I do for fun.

Share this post


Link to post
Share on other sites

Is this what you mean?

Const $FileRead = 0, $FileAppend = 1, $FileWrite = 2
Dim $Section = ''
$inifile = @ScriptDir & "\sample.ini"   ; INI file you want to read values from
$inifileH = fileopen($inifile, $FileRead)
$AU3OutH = FileOpen(@ScriptDir & "\sample.au3", $FileWrite) ; Generated AutoIt3 code fragment
$OptionsCount = 0
While 1
    $line = FileReadLine($inifileH)
    If @error = -1 Then ExitLoop
    $line = _TrimSpaces($line)
    If StringLeft($line, 1) = '[' And StringRight($line, 1) = ']' Then
        $Section = StringMid($line, 2, StringLen($line) - 2)    ; Current section name.
    ElseIf StringLeft($line, 1) <> ';' And $Section <> '' And StringInStr($line, '=') Then
        ; This is a value that we want to capture
        $OptionsCount = $OptionsCount + 1
        $Key = _TrimSpaces(StringLeft($line, StringInStr($line, '=') - 1))
        ; Comment out one of the next two lines of code!
        ; This line reads each value into a variable
        FileWriteLine($AU3OutH, '$' & $Section & '_' & $Key & ' = IniRead($inifileH, "' & $Section & '", "' & $Key & '", "")')
        ; This line reads each value into an element of an array
        ;FileWriteLine($AU3OutH, '$OptionsArray[' & $OptionsCount &  '] = IniRead($inifileH, "' & $Section & '", "' & $Key & '", "")')
    EndIf
WEnd
Func _TrimSpaces($text)
    ; Remove leading and trailing spaces from text
    Dim $rec = 0, $newText = ''
    ; Trim leading spaces
    $textA = StringSplit($text, '')
    For $i = 1 to $textA[0]
        If Not ($rec) Then
            If $textA[$i] <> ' ' Then 
                $rec = 1
            EndIf
        EndIf
        If $rec Then 
            $newText = $newText & $textA[$i]
        EndIf
    Next
    ; Trim trailing spaces
    $textA = StringSplit($newtext, '')
    $rec = 0
    $newtext = ''
    For $i = $textA[0] to 1 Step -1
        If Not ($rec) Then
            If $textA[$i] <> ' ' Then 
                $rec = 1
            EndIf
        EndIf
        If $rec Then 
            $newText = $textA[$i] & $newText
        EndIf
    Next
    Return $newText
EndFuncoÝ÷ Øw«z+±©©â
!ø¥yÊxÌ4âïu:{=Ü

Hope this helps.

perfect thanks


[s]Autoit[/s]

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