Khryus Posted December 31, 2011 Share Posted December 31, 2011 I have made a script to check wheter there's or there's not a "config.ini" file in the directory where the script is, but it only prompts a message box when it's missing. Why? ;look for the config.ini file Local $configFile = FileFindFirstFile("config.ini") If $configFile = -1 Then MsgBox(48, "Error", "Error: unable to find config.ini file.") Exit Else MsgBox(64, "Info", "Found config. file") Exit EndIf "The story of a blade is linked in Blood." ―Yasuo Link to comment Share on other sites More sharing options...
BigDod Posted December 31, 2011 Share Posted December 31, 2011 (edited) I have made a script to check wheter there's or there's not a "config.ini" file in the directory where the script is, but it only prompts a message box when it's missing. Why? ;look for the config.ini file Local $configFile = FileFindFirstFile("config.ini") If $configFile = -1 Then MsgBox(48, "Error", "Error: unable to find config.ini file.") Exit Else MsgBox(64, "Info", "Found config. file") Exit EndIf Remove the Exit after the first MsgBox Edit - loose both Exits, they are not needed Edited December 31, 2011 by BigDod Time you enjoyed wasting is not wasted time ......T.S. Elliot Suspense is worse than disappointment................Robert Burns God help the man who won't help himself, because no-one else will...........My Grandmother Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted December 31, 2011 Moderators Share Posted December 31, 2011 megablox,Do not use FileFindFirstFile (which returns a search handle) for this - use FileExists (which returns 0/1): ;look for the config.ini file If FileExists("config.ini") = 0 Then MsgBox(48, "Error", "Error: unable to find config.ini file.") Exit Else MsgBox(64, "Info", "Found config. file") Exit EndIfFileFindFirstFile is only used when you are going to search for many files with FileFindNextFile which needs that handle as a parameter. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Khryus Posted December 31, 2011 Author Share Posted December 31, 2011 Thanks both, but the second msgbox doesnt appear with each solution : "The story of a blade is linked in Blood." ―Yasuo Link to comment Share on other sites More sharing options...
bogQ Posted December 31, 2011 Share Posted December 31, 2011 (edited) maby Local $configFile = FileFindFirstFile("config.ini") If @error Then MsgBox(48, "Error", "Error: unable to find config.ini file.") Else MsgBox(64, "Info", "Found config. file") EndIf Edited December 31, 2011 by bogQ TCP server and client - Learning about TCP servers and clients connectionAu3 oIrrlicht - Irrlicht projectAu3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related) There are those that believe that the perfect heist lies in the preparation.Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost. Link to comment Share on other sites More sharing options...
Khryus Posted December 31, 2011 Author Share Posted December 31, 2011 bogQ, doesn't work, tried this: ;look for the config.ini file Local $configFile = FileExists("config.ini") If Not @error Then MsgBox(64, "info", "Found config.ini file") ElseIf @error Then MsgBox(48, "info", "Error: Unable to find config.ini file.") EndIf with the config file, it runs and does nothing. without, it prompts the msgbox. "The story of a blade is linked in Blood." ―Yasuo Link to comment Share on other sites More sharing options...
bogQ Posted December 31, 2011 Share Posted December 31, 2011 (edited) where i wroted If Not @errorim preaty shure i wroted If @error Thenand probably FileExsist is better solution for you Edited December 31, 2011 by bogQ TCP server and client - Learning about TCP servers and clients connectionAu3 oIrrlicht - Irrlicht projectAu3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related) There are those that believe that the perfect heist lies in the preparation.Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost. Link to comment Share on other sites More sharing options...
Khryus Posted December 31, 2011 Author Share Posted December 31, 2011 Still the same thing. "The story of a blade is linked in Blood." ―Yasuo Link to comment Share on other sites More sharing options...
somdcomputerguy Posted December 31, 2011 Share Posted December 31, 2011 (edited) Try it like this,Local $configFile = FileExists("config.ini") If $configFile Then MsgBox(64, "info", "Found config.ini file") Else MsgBox(48, "info", "Error: Unable to find config.ini file.") EndIfedit: I forgot to say this - If you don't need the $configFile variable, delete the first two lines and replace with If FileExists("config.ini") Then.another edit: Oops, this code is pretty much the same as M23's.. Edited December 31, 2011 by somdcomputerguy - Bruce /*somdcomputerguy */ If you change the way you look at things, the things you look at change. Link to comment Share on other sites More sharing options...
BigDod Posted December 31, 2011 Share Posted December 31, 2011 Thanks both, but the second msgbox doesnt appear with each solution :Both options work here. Time you enjoyed wasting is not wasted time ......T.S. Elliot Suspense is worse than disappointment................Robert Burns God help the man who won't help himself, because no-one else will...........My Grandmother Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted December 31, 2011 Moderators Share Posted December 31, 2011 megablox, My version works for me - or I would not have posted it. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
bogQ Posted December 31, 2011 Share Posted December 31, 2011 (edited) and for me all 3 of them #RequireAdmin #Include <Array.au3> #Include <File.au3> ConsoleWrite(@ScriptDir&@CRLF) $arr = _FileListToArray(@ScriptDir) $tmp = False For $x = 1 To $arr[0] If $arr[$x] ='config.ini' Then MsgBox(64,'_FileListToArray',$arr[$x]) $tmp = True ExitLoop 1 EndIf Next If $tmp = False Then MsgBox(48,'_FileListToArray','cant finde it in array') $configFile = FileFindFirstFile(@ScriptDir&"config.ini") If $configFile = -1 Or @error Then MsgBox(48, "FileFindFirstFile", "Error: unable to find config.ini file.") Else MsgBox(64, "FileFindFirstFile", "Found config.ini file") EndIf FileClose($configFile) If FileExists(@ScriptDir&"config.ini") Then MsgBox(64, "FileExists", "Found config.ini file") Else MsgBox(48, "FileExists", "Error: Unable to find config.ini file.") EndIf Edited December 31, 2011 by bogQ TCP server and client - Learning about TCP servers and clients connectionAu3 oIrrlicht - Irrlicht projectAu3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related) There are those that believe that the perfect heist lies in the preparation.Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost. Link to comment Share on other sites More sharing options...
FaridAgl Posted December 31, 2011 Share Posted December 31, 2011 No need to put the result to a variable, just use it this way.If FileExists("config.ini") Then MsgBox(0, "config.ini File", "Exists") Else MsgBox(0, "config.ini File", "Does NOT exists") EndIfTested, working.Just remember, it search for the file in script's directory. http://faridaghili.ir Link to comment Share on other sites More sharing options...
Khryus Posted December 31, 2011 Author Share Posted December 31, 2011 It doesn't work for me, what did I do wrong? I posted the whole script "The story of a blade is linked in Blood." ―Yasuo Link to comment Share on other sites More sharing options...
bogQ Posted December 31, 2011 Share Posted December 31, 2011 it means that your creating ini in wrong folder TCP server and client - Learning about TCP servers and clients connectionAu3 oIrrlicht - Irrlicht projectAu3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related) There are those that believe that the perfect heist lies in the preparation.Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost. Link to comment Share on other sites More sharing options...
Khryus Posted December 31, 2011 Author Share Posted December 31, 2011 I have the script located in the same folder where the config.ini file is (they're both in C:Users****DesktopTest Foldersamples). When I run it, and the config.ini file is in the same folder, it doesn't show any message. However, if I move the file to the folder "Test Folder", it prompts the message box saying that the file couldn't be found. "The story of a blade is linked in Blood." ―Yasuo Link to comment Share on other sites More sharing options...
bogQ Posted December 31, 2011 Share Posted December 31, 2011 (edited) restart comp after it try this on desktop folder #RequireAdmin #include <File.au3> If Not _FileCreate("config.ini") Then MsgBox(4096,"Error", " Error Creating:" & @error) If FileExists("config.ini") Then MsgBox(0, "config.ini File", "Exists") FileDelete("config.ini") If Not FileExists("config.ini") Then MsgBox(0, "config.ini File", "Does NOT exists") it shud geave you 2 msgboxes, firstone after creating file with script second one after deliting it Edited December 31, 2011 by bogQ TCP server and client - Learning about TCP servers and clients connectionAu3 oIrrlicht - Irrlicht projectAu3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related) There are those that believe that the perfect heist lies in the preparation.Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost. Link to comment Share on other sites More sharing options...
Khryus Posted December 31, 2011 Author Share Posted December 31, 2011 bogQ, that worked "The story of a blade is linked in Blood." ―Yasuo Link to comment Share on other sites More sharing options...
Khryus Posted December 31, 2011 Author Share Posted December 31, 2011 I feel so stupid now, I had 2 copies of the script, one updated, and one outdated. One was saved on the desktop, and another in the folder. I kept running the outdated one :| Thanks everyone "The story of a blade is linked in Blood." ―Yasuo Link to comment Share on other sites More sharing options...
bogQ Posted December 31, 2011 Share Posted December 31, 2011 (edited) no need to feel that way it happend to everyone, just note, easiest way to run the script is by pressing F5 in scite editor, if you do it like that you'll know what script are you runing Edited December 31, 2011 by bogQ TCP server and client - Learning about TCP servers and clients connectionAu3 oIrrlicht - Irrlicht projectAu3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related) There are those that believe that the perfect heist lies in the preparation.Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost. 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