GodlessSinner Posted January 15, 2010 Share Posted January 15, 2010 expandcollapse popupGlobal $inclist[1024] For $i = 1 To 1023 Step 1 $inclist[$i] = -1 Next Global $source, $dest, $destdir $source = FileOpenDialog("Select source *.au3 script", @WindowsDir & "\", "au3 scripts (*.au3)", 1 + 4 ) $splitted = StringSplit($source, "\") $dest = "" For $i = 1 to $splitted[0] - 1 Step 1 $dest &= $splitted[$i] & "\" Next $destdir = $dest $dest &= "inclisted\" & $splitted[$splitted[0]] FileCopy($source, $dest, 1 + 8) SplashTextOn("Wait...", "", 100, 100) While 1 If needtoinc($dest) = 1 Then inc($dest) Else ExitLoop EndIf WEnd SplashOff() MsgBox(64,"Completed!", "") FileClose($destdir & "\inclisted") Exit Func inc($dest) $fileread = FileOpen($dest, 0) $filewrite = FileOpen($destdir & "\inclisted\dest.au3", 2 + 8) While 1 $line = FileReadLine($fileread) If @error = -1 Then ExitLoop $trim = $line $trim = StringReplace($trim, " ", "") $trim = StringReplace($trim, " ", "") If StringInStr($trim, "#include") = 1 And Not StringInStr($line, "#include-once") Then $tempstring = $line $tempstring = StringTrimLeft($tempstring, StringInStr($tempstring, "<")) $tempstring = StringTrimRight($tempstring, (StringLen($tempstring) - StringInStr($tempstring, ">")) + 1) If included($tempstring) = 0 Then $filereadfrominc = FileRead("C:\Program Files\AutoIt3\Include\" & $tempstring) FileWrite($filewrite, $filereadfrominc & @CRLF) EndIf Else FileWriteLine($filewrite, $line) EndIf Wend FileClose($fileread) FileClose($filewrite) FileClose($destdir & "\inclisted") FileMove($destdir & "\inclisted\dest.au3", $dest, 1) EndFunc Func included($tempstring) $included = 0 For $i = 1 To 1023 Step 1 If $inclist[$i] = $tempstring Then $included = 1 ExitLoop EndIf Next If $included = 0 Then For $i = 1 To 1023 Step 1 If $inclist[$i] = -1 Then $inclist[$i] = $tempstring ExitLoop EndIf Next $log = FileOpen("log.txt", 1+8) FileWrite($log, $tempstring & @CRLF) FileClose($log) Return 0 Else Return 1 EndIf EndFunc Func needtoinc($dest) Local $needtoinc = 0 $fileread = FileOpen($dest, 0) While 1 $line = FileReadLine($fileread) If @error = -1 Then ExitLoop $trim = $line $trim = StringReplace($trim, " ", "") $trim = StringReplace($trim, " ", "") If StringInStr($trim, "#include") = 1 And Not StringInStr($line, "#include-once") Then $needtoinc = 1 ExitLoop EndIf WEnd FileClose($fileread) FileClose($destdir & "\inclisted") If $needtoinc = 1 Then Return 1 Else Return 0 EndIf EndFunc Test please on this file: #include <Date.au3> #include <GDIPlus.au3> #include <WinAPI.au3> #include <WindowsConstants.au3> #include <GuiConstantsEx.au3> #include <INet.au3> #include <GDIPlus.au3> #include <ButtonConstants.au3> #include <ComboConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <GuiStatusBar.au3> #include <ProgressConstants.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> Why after this by checking target file i see: WARNING: $tagMEMMAP: possibly used before declaration. WARNING: $tagTOKEN_PRIVILEGES: possibly used before declaration. ? thanks. _____________________________________________________________________________ Link to comment Share on other sites More sharing options...
Developers Jos Posted January 15, 2010 Developers Share Posted January 15, 2010 its for me unclear what is supposed to be the problem. Don't get any errors. Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. 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