MadBoy Posted January 18, 2006 Share Posted January 18, 2006 Hey, I have little problem with IniRead. I have a file that is called last.txt (with 1 line of text in it). I also have a program that overwrites that file every some minutes and then after the command to create the file with specific info is executed it also executes .au3 script that i wrote. And now when the variable where the last.txt file is done with IniRead au3 script says that there was no file found. But when i exectued it 5 seconds later by hand it has no problem finding it (so i suspect here that .au3 file is trying to get info from that file while it's being created/overwritten). When i use built in variable (2nd code) everything is executed fine and works. So my question here is if IniRead is noticable slower then builtin variable, and/or is there a way to speed it up? Dim $udp_release = IniRead($settings, "INFO", "udp_release", "") [INFO] udp_release = c:\Programs\last.txt When I use it as built in variable everything is fine and script manages to execute on time. $udp_release = "c:\Programs\last.txt" My little company: Evotec (PL version: Evotec) Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted January 18, 2006 Moderators Share Posted January 18, 2006 Debug and see where the problem is... put this code at the before the start of the problem to see if it is in fact the file not being found. Do Sleep(10) Until FileExists('c:\Programs\last.txt') Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Valik Posted January 18, 2006 Share Posted January 18, 2006 Duh, of course a variable is faster. It doesn't involve the overhead of disk I/O. However, you haven't really provided enough context or a reproduce-able script that demonstrates the real problem you are having. However, if I had to guess, I would say it's a caching issue. Ini files must be flushed after they are written to. This can be done immediately or we can wait on Windows to do it. Presumably, this Ini file you are reading is from another program? Maybe it doesn't flush the Ini file immediately so you are at the mercy of waiting for the OS to do it. Link to comment Share on other sites More sharing options...
MadBoy Posted January 18, 2006 Author Share Posted January 18, 2006 (edited) Duh, of course a variable is faster. It doesn't involve the overhead of disk I/O. However, you haven't really provided enough context or a reproduce-able script that demonstrates the real problem you are having. However, if I had to guess, I would say it's a caching issue. Ini files must be flushed after they are written to. This can be done immediately or we can wait on Windows to do it. Presumably, this Ini file you are reading is from another program? Maybe it doesn't flush the Ini file immediately so you are at the mercy of waiting for the OS to do it. I created the INI just for the .au3 program so i can later spread that program and forget it Here's how it looks. Have in mind that it will run fine unless the situation is like i said in previous posts. expandcollapse popup#include <GUIConstants.au3> #NoTrayIcon ;=============Variables============================================== Dim $autor = "MadBoy" Dim $version = "0.2" Dim $settings = "UdpSend.ini" Dim $udp_ip = IniRead($settings, "INFO", "udp_ip", "") Dim $udp_port = IniRead($settings, "INFO", "udp_port", "") Dim $udp_release = IniRead($settings, "INFO", "udp_release", "") ;==================================================================== ;==================================================================== ;==================================================================== ;==============Start The UDP Services================================ UDPStartup() $socket = UDPOpen($udp_ip, $udp_port) If @error <> 0 Then Exit ;==============Coordinates=========================================== $position1 = 5 $position2 = 10 $nr_button1 = 30 $nr_button2 = 50 ;==============Build GUI============================================= GUICreate("UDP Sender " & $autor & " - version " & $version, 400,200) $button_1 = GUICtrlCreateButton ("START", $nr_button1, $nr_button2, 340, 120, $BS_DEFPUSHBUTTON) GUISetState () $Label1= GuiCtrlCreateInput("", $position1, $position2, 390, 20) ;==========Release name from $udp_release============================ $file_1 = FileOpen($udp_release, 0) If $file_1 = -1 Then MsgBox(0, "Error", "Unable to open file " & $udp_release ) Exit EndIf While 1 $release = FileReadLine($file_1, 1) GUICtrlSetData( $Label1, $release) ExitLoop Wend FileClose($file_1) ;=========On EVENT action============================================= While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Exit Case $msg = $button_1 $status = UDPSend($socket, "Some text i want to send: " & $release) Exit EndSelect WEnd Func OnAutoItExit() UDPCloseSocket($socket) UDPShutdown() EndFunc Look of INI file.. [INFO] udp_ip = 127.0.0.1 udp_port = 11111 udp_release = c:\Programs\last.txt Edited January 18, 2006 by MadBoy My little company: Evotec (PL version: Evotec) Link to comment Share on other sites More sharing options...
Valik Posted January 18, 2006 Share Posted January 18, 2006 Ahhh, now I understand. You need to specify the full path to the Ini file. Something like this: Dim $settings = @ScriptDir & "\UdpSend.ini"If the Ini file isn't in the same directory as this script, adjust the path appropriately. What's happening is the Ini file is being searched for in the current working directory (@WorkingDir) but that directory is not equal to @ScriptDir. When you run the script manually, @WorkingDir equals @ScriptDir so it works. Link to comment Share on other sites More sharing options...
MadBoy Posted January 18, 2006 Author Share Posted January 18, 2006 Ahhh, now I understand. You need to specify the full path to the Ini file. Something like this: Dim $settings = @ScriptDir & "\UdpSend.ini"If the Ini file isn't in the same directory as this script, adjust the path appropriately. What's happening is the Ini file is being searched for in the current working directory (@WorkingDir) but that directory is not equal to @ScriptDir. When you run the script manually, @WorkingDir equals @ScriptDir so it works. Tnx, i seen it done like that in PrepSys app here on forum but i thought to myself that it isn't needed. I guess i was wrong. I'll test and hopefully it will work in future However in that application TIME is everything 0.1mili second or 1sec to start app means a lot to me That's why maybe you know better solution to this? Would $cmdline start be better? instead of reading the last.txt file i can make the program send the line as cmdline. Question is if it's faster? Maybe a program that would be loaded into processes and hidden from taskbar would "show_up" itself faster (it would have to monitor for incoming text and when it comes pop-out the box) And another question is.. how to make the that app to timeout after 20secs of not pressing the button? I seen that option for MsgBox but couldn't find anything for use of my program. My little company: Evotec (PL version: Evotec) 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