Vicks Posted August 7, 2006 Share Posted August 7, 2006 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] Link to comment Share on other sites More sharing options...
Xenobiologist Posted August 7, 2006 Share Posted August 7, 2006 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 fasterHI,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 Link to comment Share on other sites More sharing options...
Vicks Posted August 7, 2006 Author Share Posted August 7, 2006 HI,what do you mean by add to my script? Read ini ? Check ini? So long,Megaread ini please [s]Autoit[/s] Link to comment Share on other sites More sharing options...
Xenobiologist Posted August 7, 2006 Share Posted August 7, 2006 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 Link to comment Share on other sites More sharing options...
Vicks Posted August 7, 2006 Author Share Posted August 7, 2006 What is wrong with IniRead? Is it too slow? So long,Megano 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] Link to comment Share on other sites More sharing options...
Golbez Posted August 7, 2006 Share Posted August 7, 2006 if u wanna make ti write the ini... y not iniwrite? Link to comment Share on other sites More sharing options...
Xenobiologist Posted August 7, 2006 Share Posted August 7, 2006 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 Link to comment Share on other sites More sharing options...
Golbez Posted August 7, 2006 Share Posted August 7, 2006 i think he wants a a way to make it easyer and faster for him to make his ini.. but i might be wroung. Link to comment Share on other sites More sharing options...
Vicks Posted August 7, 2006 Author Share Posted August 7, 2006 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 onemyini.txt [s]Autoit[/s] Link to comment Share on other sites More sharing options...
Golbez Posted August 7, 2006 Share Posted August 7, 2006 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 Link to comment Share on other sites More sharing options...
Vicks Posted August 7, 2006 Author Share Posted August 7, 2006 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 [s]Autoit[/s] Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted August 7, 2006 Moderators Share Posted August 7, 2006 thanks but what if i had words instead of numbers IniReadSection() in the help file (beta). 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. Link to comment Share on other sites More sharing options...
Golbez Posted August 7, 2006 Share Posted August 7, 2006 thanks but what if i had words instead of numbers 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? Link to comment Share on other sites More sharing options...
bluebearr Posted August 8, 2006 Share Posted August 8, 2006 (edited) Is this what you mean? expandcollapse popupConst $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:b¢{=Ü Hope this helps. Edited August 8, 2006 by bluebearr BlueBearrOddly enough, this is what I do for fun. Link to comment Share on other sites More sharing options...
Vicks Posted August 8, 2006 Author Share Posted August 8, 2006 Is this what you mean? expandcollapse popupConst $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:b¢{=Ü Hope this helps. perfect thanks [s]Autoit[/s] Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now