anixon Posted March 3, 2007 Share Posted March 3, 2007 I have a script that uses a number of different INI files so when the routine starts I check that they are present. This is the code that I have written CODEGlobal $message = "" ; Check that the INI files still exist ; If Not FileExists(@ScriptDir & "\inifiles\abc.ini") Then plbeep() $message = " ABC.INI FILE NOT AVAIL" DisplayMessage() Exit EndIf If Not FileExists(@ScriptDir & "\inifiles\def.ini") Then plbeep() $message = " DEF.INI NOT AVAIL" DisplayMessage() Exit EndIf ;Message Box Subroutine ; Func DisplayMessage() splashTextOn("PROXLOC", $message , 250, 50, 600, 500, 36, "times new roman", 10, 600) Sleep(2000) splashOff() EndFunc ;Beep Subroutine ; Func plbeep() For $i = 4 to 1 Step -1 Beep(500,50) Sleep(100) Next EndFunc Is there a routine where I can code a list of files and have each file on the list checked that it exists rather than a routine which sequentially checks each inifile as I have written Help is appreciated Ant.. Link to comment Share on other sites More sharing options...
nitekram Posted March 3, 2007 Share Posted March 3, 2007 I have a script that uses a number of different INI files so when the routine starts I check that they are present. This is the code that I have written CODEGlobal $message = "" ; Check that the INI files still exist ; If Not FileExists(@ScriptDir & "\inifiles\abc.ini") Then plbeep() $message = " ABC.INI FILE NOT AVAIL" DisplayMessage() Exit EndIf If Not FileExists(@ScriptDir & "\inifiles\def.ini") Then plbeep() $message = " DEF.INI NOT AVAIL" DisplayMessage() Exit EndIf ;Message Box Subroutine ; Func DisplayMessage() splashTextOn("PROXLOC", $message , 250, 50, 600, 500, 36, "times new roman", 10, 600) Sleep(2000) splashOff() EndFunc ;Beep Subroutine ; Func plbeep() For $i = 4 to 1 Step -1 Beep(500,50) Sleep(100) Next EndFunc Is there a routine where I can code a list of files and have each file on the list checked that it exists rather than a routine which sequentially checks each inifile as I have written Help is appreciated Ant.. Not sure exactly what you want but maybe you can use this and create an Array of the file names and then call the func as many times as needed to check if the file does not exist. Global $file01 = "\inifiles\abc.ini" _runINI($file01) Func _runINI($filename) If Not FileExists(@ScriptDir & $filename) Then plbeep() $message = $filename & " FILE NOT AVAIL" DisplayMessage() Exit EndIf EndFunc NOTE - code not tested 2¢ All by me:"Sometimes you have to go back to where you started, to get to where you want to go." "Everybody catches up with everyone, eventually" "As you teach others, you are really teaching yourself." From my dad "Do not worry about yesterday, as the only thing that you can control is tomorrow." WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2 AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit Docs SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language Programming Tips Excel Changes ControlHover.UDF GDI_Plus Draw_On_Screen GDI Basics GDI_More_Basics GDI Rotate GDI Graph GDI CheckExistingItems GDI Trajectory Replace $ghGDIPDll with $__g_hGDIPDll DLL 101? Array via Object GDI Swimlane GDI Plus French 101 Site GDI Examples UEZ GDI Basic Clock GDI Detection Ternary operator Link to comment Share on other sites More sharing options...
anixon Posted March 3, 2007 Author Share Posted March 3, 2007 Not sure exactly what you want but maybe you can use this and create an Array of the file names and then call the func as many times as needed to check if the file does not exist. Global $file01 = "\inifiles\abc.ini" _runINI($file01) Func _runINI($filename) If Not FileExists(@ScriptDir & $filename) Then plbeep() $message = $filename & " FILE NOT AVAIL" DisplayMessage() Exit EndIf EndFunc I have no experience with an array I can see that this routine will check for abc.ini but what would the code look like if the next file to check is def.ini and then ghi.ini etc etc Ant.. NOTE - code not tested Link to comment Share on other sites More sharing options...
anixon Posted March 3, 2007 Author Share Posted March 3, 2007 (edited) This works but I am not sure that this is smart code CODEGlobal $file01 = "\inifiles\abc.ini" Global $file02 = "\inifiles\def.ini" Global $file03 = "\inifiles\ghi.ini" _runINI($file01) _runINI($file02) _runINI($file03) Func _runINI($filename) If Not FileExists(@ScriptDir & $filename) Then plbeep() $message = $filename & " FILE NOT AVAIL" DisplayMessage() Exit EndIf EndFunc ;Message Box Subroutine ; Func DisplayMessage() splashTextOn("PROXLOC", $message , 250, 50, 600, 500, 36, "times new roman", 10, 600) Sleep(2000) splashOff() EndFunc ;Beep Subroutine ; Func plbeep() $beep = IniRead(@ScriptDir&"\inifiles\proxloc.ini", "stealth", "plmonitorab", "0") If $beep = 1 Then For $i = 4 to 1 Step -1 Beep(500,50) Sleep(100) Next Endif EndFunc What do you think? cheers Ant... Edited March 3, 2007 by anixon Link to comment Share on other sites More sharing options...
nitekram Posted March 4, 2007 Share Posted March 4, 2007 (edited) This works but I am not sure that this is smart code CODEGlobal $file01 = "\inifiles\abc.ini" Global $file02 = "\inifiles\def.ini" Global $file03 = "\inifiles\ghi.ini" _runINI($file01) _runINI($file02) _runINI($file03) Func _runINI($filename) If Not FileExists(@ScriptDir & $filename) Then plbeep() $message = $filename & " FILE NOT AVAIL" DisplayMessage() Exit EndIf EndFunc ;Message Box Subroutine ; Func DisplayMessage() splashTextOn("PROXLOC", $message , 250, 50, 600, 500, 36, "times new roman", 10, 600) Sleep(2000) splashOff() EndFunc ;Beep Subroutine ; Func plbeep() $beep = IniRead(@ScriptDir&"\inifiles\proxloc.ini", "stealth", "plmonitorab", "0") If $beep = 1 Then For $i = 4 to 1 Step -1 Beep(500,50) Sleep(100) Next Endif EndFunc What do you think? cheers Ant... Again code not tested - I also added the parameter needed to display the message - see if this works Global $file[4] = ["\inifiles\abc.ini","\inifiles\def.ini","\inifiles\ghi.ini"] For $i = 1 to UBound($file) - 1 _runINI($file[$i]) Next Func _runINI($filename) If Not FileExists(@ScriptDir & $filename) Then plbeep() $message = $filename & " FILE NOT AVAIL" DisplayMessage($message) Exit EndIf EndFunc ;Message Box Subroutine ; Func DisplayMessage($message) splashTextOn("PROXLOC", $message , 250, 50, 600, 500, 36, "times new roman", 10, 600) Sleep(2000) splashOff() EndFunc ;Beep Subroutine ; Func plbeep() $beep = IniRead(@ScriptDir&"\inifiles\proxloc.ini", "stealth", "plmonitorab", "0") If $beep = 1 Then For $i = 4 to 1 Step -1 Beep(500,50) Sleep(100) Next Endif EndFunc EDIT I think you may want to check the other file proxloc.ini before you use it - just to keep your code from doing unexpected things Edited March 4, 2007 by nitekram 2¢ All by me:"Sometimes you have to go back to where you started, to get to where you want to go." "Everybody catches up with everyone, eventually" "As you teach others, you are really teaching yourself." From my dad "Do not worry about yesterday, as the only thing that you can control is tomorrow." WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2 AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit Docs SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language Programming Tips Excel Changes ControlHover.UDF GDI_Plus Draw_On_Screen GDI Basics GDI_More_Basics GDI Rotate GDI Graph GDI CheckExistingItems GDI Trajectory Replace $ghGDIPDll with $__g_hGDIPDll DLL 101? Array via Object GDI Swimlane GDI Plus French 101 Site GDI Examples UEZ GDI Basic Clock GDI Detection Ternary operator Link to comment Share on other sites More sharing options...
anixon Posted March 4, 2007 Author Share Posted March 4, 2007 Again code not tested - I also added the parameter needed to display the message - see if this works Global $file[4] = ["\inifiles\abc.ini","\inifiles\def.ini","\inifiles\ghi.ini"] For $i = 1 to UBound($file) - 1 _runINI($file[$i]) Next Func _runINI($filename) If Not FileExists(@ScriptDir & $filename) Then plbeep() $message = $filename & " FILE NOT AVAIL" DisplayMessage($message) Exit EndIf EndFunc ;Message Box Subroutine ; Func DisplayMessage($message) splashTextOn("PROXLOC", $message , 250, 50, 600, 500, 36, "times new roman", 10, 600) Sleep(2000) splashOff() EndFunc ;Beep Subroutine ; Func plbeep() $beep = IniRead(@ScriptDir&"\inifiles\proxloc.ini", "stealth", "plmonitorab", "0") If $beep = 1 Then For $i = 4 to 1 Step -1 Beep(500,50) Sleep(100) Next Endif EndFunc EDIT I think you may want to check the other file proxloc.ini before you use it - just to keep your code from doing unexpected things I did the mod to plbeep to get rid of the $beep reference to proxloc but have been unable to make your code work as $filename appears not to be getting a value and I have no Idea how to fix it. Cheers Ant.. Link to comment Share on other sites More sharing options...
anixon Posted March 4, 2007 Author Share Posted March 4, 2007 I have a script that uses a number of different INI files so when the routine starts I check that they are present. This is the code that I have writtenCODEGlobal $message = ""; Check that the INI files still exist;If Not FileExists(@ScriptDir & "\inifiles\abc.ini") Then plbeep() $message = " ABC.INI FILE NOT AVAIL" DisplayMessage() ExitEndIfIf Not FileExists(@ScriptDir & "\inifiles\def.ini") Then plbeep() $message = " DEF.INI NOT AVAIL" DisplayMessage() ExitEndIf;Message Box Subroutine;Func DisplayMessage() splashTextOn("PROXLOC", $message , 250, 50, 600, 500, 36, "times new roman", 10, 600) Sleep(2000) splashOff()EndFunc;Beep Subroutine;Func plbeep() For $i = 4 to 1 Step -1 Beep(500,50) Sleep(100) NextEndFuncIs there a routine where I can code a list of files and have each file on the list checked that it exists rather than a routine which sequentially checks each inifile as I have writtenHelp is appreciatedI have tried your code again and it does work. Dont ask me what I did wrong but simply deleted the file. Created a new file and copied it across compiled it and it ran perfectlyThanks for your help very much appreciatedAnt ........Ant.. Link to comment Share on other sites More sharing options...
anixon Posted March 4, 2007 Author Share Posted March 4, 2007 I have fully tested your code and for some reason it does not check the first item "\inifiles\abc.ini" works fine if def.ini or ghi.ini don't exist. This is the line of code that may be at issue Global $file[4] = ["\inifiles\abc.ini","\inifiles\def.ini","\inifiles\ghi.ini"] Cheers Ant... Link to comment Share on other sites More sharing options...
anixon Posted March 4, 2007 Author Share Posted March 4, 2007 I have fully tested your code and for some reason it does not check the first item "\inifiles\abc.ini" works fine if def.ini or ghi.ini don't exist. This is the line of code that may be at issue Global $file[4] = ["\inifiles\abc.ini","\inifiles\def.ini","\inifiles\ghi.ini"] Cheers Ant... Ahh success to resolve the above in the code statement For $i = 1 to UBound($file) - 1 _runINI($file[$i]) Next $i = 1 should be changed to $i = 0 Cheers Ant.. Link to comment Share on other sites More sharing options...
anixon Posted March 4, 2007 Author Share Posted March 4, 2007 Ahh success to resolve the above in the code statement For $i = 1 to UBound($file) - 1 _runINI($file[$i]) Next $i = 1 should be changed to $i = 0 Cheers Ant.. This is another adaptation of the UBound code which will close running applications CODE;Close any running Progams ; Global $file[4] = ["abc.exe","def.exe","ghi.exe"] For $i = 0 to UBound($file) - 1 _closePROG($file[$i]) Next Func _closePROG($filename) $PID = ProcessExists($filename) If $PID Then ProcessClose($PID) EndFunc Cheers Ant.. 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