Guest Posted December 25, 2013 Share Posted December 25, 2013 (edited) Following script does exactly what I want to do.There is no need to explain .. Only use it or read it and you will understand.(I'm better with Autoit language than with the English language...) expandcollapse popup#include <Array.au3> $ScriptFile = "script.au3" ; < =========== Insert here any script path .. $Final = Tool1($ScriptFile) ConsoleWrite($Final&@CRLF) Func Tool1($ScriptFile) Local $Output = "" , $a $mScript = FileRead($ScriptFile) $aScript = StringSplit($mScript,@CRLF,1) Do $a = $a+1 If LineIsActive($aScript[$a]) Then _ArrayInsert($aScript,$a+1,'ConsoleWrite("[Tool1] "&"'&$aScript[$a]&'"&@CRLF)') $aScript[0] = $aScript[0]+1 $a = $a+1 _ArrayDisplay($aScript,"Still processing...") ; this line is only to show you how long it takes. EndIf Until $a >= $aScript[0] _ArrayDisplay($aScript,"Stage 1 Completed") For $a = 1 To $aScript[0] $Output = $Output&$aScript[$a] If $a < $aScript[0] Then $Output = $Output&@CRLF Next Return $Output EndFunc ; Test 1 ;$Line = "xxxx;xx" ;If LineIsActive($Line) Then ; ConsoleWrite("Active"&@CRLF) ;Else ; ConsoleWrite("Not Active"&@CRLF) ;EndIf Func LineIsActive($Line) Local $Output = False If Not StringIsSpace($Line) Then Local $var = StringSplit($Line,"",1) For $a = 1 To $var[0] If Not StringIsSpace($var[$a]) Then If $var[$a] <> ";" Then $Output = True EndIf ExitLoop EndIf Next EndIf Return $Output EndFunc the problem is that the script do the job very very slow... what can i do to make is faster? thanks for helpers! Edited December 25, 2013 by Guest Link to comment Share on other sites More sharing options...
BrewManNH Posted December 25, 2013 Share Posted December 25, 2013 _ArrayInsert is a very time consuming task if you're adding a lot of lines to the array, perhaps you should look at the thread I posted in Example Scripts for a faster arrayadd function. It really only works with strings, but seeing as how that's what you're doing it might work better for you. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
Guest Posted December 25, 2013 Share Posted December 25, 2013 (edited) _ArrayInsert is a very time consuming task if you're adding a lot of lines to the array, perhaps you should look at the thread I posted in Example Scripts for a faster arrayadd function. It really only works with strings, but seeing as how that's what you're doing it might work better for you. Thank you.But I thought about a better way ..There is no need to use _ArrayInsert or _ArrayAdd this is the new code: expandcollapse popup;#include <Array.au3> $ScriptFile = "Script.au3" ; < =========== Insert here any script path .. $Final = Tool1($ScriptFile) ConsoleWrite($Final&@CRLF) Func Tool1($ScriptFile) Local $Output = "" ; , $a $mScript = FileRead($ScriptFile) $aScript = StringSplit($mScript,@CRLF,1) ;Do For $a = 1 To $aScript[0] ;$a = $a+1 $Output = $Output&$aScript[$a]&@CRLF If LineIsActive($aScript[$a]) Then ;_ArrayInsert($aScript,$a+1,'ConsoleWrite("[Tool1] "&"'&$aScript[$a]&'"&@CRLF)') $Output = $Output&'ConsoleWrite("[Tool1] "&"'&$aScript[$a]&'"&@CRLF)' ;$aScript[0] = $aScript[0]+1 ;$a = $a+1 ;_ArrayDisplay($aScript,"Still processing...") ; this line is only to show you how long it takes. If $a < $aScript[0] Then $Output = $Output&@CRLF EndIf Next ;Until $a >= $aScript[0] ;_ArrayDisplay($aScript,"Stage 1 Completed") ;For $a = 1 To $aScript[0] ; $Output = $Output&$aScript[$a] ; If $a < $aScript[0] Then $Output = $Output&@CRLF ;Next Return $Output EndFunc ; Test 1 ;$Line = "xxxx;xx" ;If LineIsActive($Line) Then ; ConsoleWrite("Active"&@CRLF) ;Else ; ConsoleWrite("Not Active"&@CRLF) ;EndIf Func LineIsActive($Line) Local $Output = False If Not StringIsSpace($Line) Then Local $var = StringSplit($Line,"",1) For $a = 1 To $var[0] If Not StringIsSpace($var[$a]) Then If $var[$a] <> ";" Then $Output = True EndIf ExitLoop EndIf Next EndIf Return $Output EndFunc this is much faster .. Edited December 25, 2013 by Guest Link to comment Share on other sites More sharing options...
Gianni Posted December 25, 2013 Share Posted December 25, 2013 (I'm better with Autoit language than with the English language...) ... you say?.... what is the purpose of that script? Chimp small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt.... Link to comment Share on other sites More sharing options...
Guest Posted December 25, 2013 Share Posted December 25, 2013 ... you say?.... what is the purpose of that script? Try to get this result: By a complex technique ...Anyway, I decided there was no reason to do this because I found another solution. 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