Jump to content

This work just in part, why?


Khryus
 Share

Recommended Posts

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

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 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

  • Moderators

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
EndIf

FileFindFirstFile is only used when you are going to search for many files with FileFindNextFile which needs that handle as a parameter. ;)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

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 by bogQ

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
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

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

where i wroted If Not @error

im preaty shure i wroted If @error Then

and probably FileExsist is better solution for you

Edited by bogQ

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
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

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.")
EndIf

edit: 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 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

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

  • Moderators

megablox,

My version works for me - or I would not have posted it. :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

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 by bogQ

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
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

it means that your creating ini in wrong folder

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
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

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

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 by bogQ

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
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

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

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 by bogQ

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...