DangerousDan Posted January 19, 2009 Share Posted January 19, 2009 (edited) I am using an ini file on a network drive to store customer information. The script I have written polls the ini file occasionally, and I have Tooltips to indicate to the user that a network drive is being used and it will take a second, but the script is real slow sometimes due to other network activity. I have no way to store the ini file locally. I "could" copy it locally each time the program is started, but don't want to if I don't have to. The program is loaded from the network, and anything I need from the network is loaded into memory at that time as well, so startup is expected to take a minute. is there any way to load the ini file to memory and then use the iniread functionality on the file in memory, similar to fileopen? AutoIt n00b, please be gentle Edited January 19, 2009 by DangerousDan Link to comment Share on other sites More sharing options...
furrycow Posted January 19, 2009 Share Posted January 19, 2009 I am using an ini file on a network drive to store customer information. The script I have written polls the ini file occasionally, and I have Tooltips to indicate to the user that a network drive is being used and it will take a second, but the script is real slow sometimes due to other network activity. I have no way to store the ini file locally. I "could" copy it locally each time the program is started, but don't want to if I don't have to. The program is loaded from the network, and anything I need from the network is loaded into memory at that time as well, so startup is expected to take a minute.is there any way to load the ini file to memory and then use the iniread functionality on the file in memory, similar to fileopen?AutoIt n00b, please be gentle Im not completely sure if it would work or not, but could you put all the info in the ini to an array at startup, or whenever you need..i understand if the ini is reallly big then this might not be suitable, but a suggestion! Instant Lockerz Invite - www.instantlockerzinvite.co.uk Link to comment Share on other sites More sharing options...
tannerli Posted January 19, 2009 Share Posted January 19, 2009 If you need to know wheter your inifile has changed or not, there is now other way then to read it from the network again. However if the values in the ini file remain always (or at least until next program start) the same, you could use something like this.. Dim $PROPERTY1 = IniRead("inifile.ini", "section", "value", "defaultval") Dim $PROPERTY2 = IniRead("inifile.ini", "section", "value1", "defaultval") Dim $PROPERTY3 = IniRead("inifile.ini", "section", "value2", "defaultval") Link to comment Share on other sites More sharing options...
DangerousDan Posted January 19, 2009 Author Share Posted January 19, 2009 (edited) The main issue is I want all users to be able to add to the ini file. I suppose an array would work, I had hoped to not modify the script though. easy to do in an array, but more difficult than iniread calls. the variable method would be harder to do, I must be able to search for the key and return the value; also the number of values will be unknown as the user can add keys. I'll most likely leave it on the network drive and use iniread if there is no way to load to memory and use iniread... thanks for your help so far Edited January 19, 2009 by DangerousDan Link to comment Share on other sites More sharing options...
tannerli Posted January 19, 2009 Share Posted January 19, 2009 I know you don't like this solution but if you need the new values (added by the user) only at startup why not add somthing like this at the script-start: Filecopy("My ini.ini", @ScriptDir & "\tmp.ini", 1) do all your stuff here and add that at the end: FileDelete(@ScriptDir & "\tmp.ini") Link to comment Share on other sites More sharing options...
furrycow Posted January 19, 2009 Share Posted January 19, 2009 I know you don't like this solution but if you need the new values (added by the user) only at startup why not add somthing like this at the script-start: Filecopy("My ini.ini", @ScriptDir & "\tmp.ini", 1) do all your stuff here and add that at the end: FileDelete(@ScriptDir & "\tmp.ini") Will that work though? because in the time the user1 has copied the file to their local directory, added the info, then copied it back to the initial location, user2 could have done the same, but faster, so when user1 copys it back, it will write over the info user2 input, as user1 will have the original info in there. Instant Lockerz Invite - www.instantlockerzinvite.co.uk Link to comment Share on other sites More sharing options...
DangerousDan Posted January 19, 2009 Author Share Posted January 19, 2009 it's a "live" system, copying the file locally at startup will only partially solve my problem. any user can add or modify keys (keys are inventory control item codes, the value is the customer part number for cross reference) but no users can delete keys. if I add a key at 10am I need the user who opened the program at 9AM to be able to use this new key. I know I can use the array method with inireadsection to speed up the individual function operations (the program goes very slow when each line on the AS400 emulator causes the ini file to be read with iniread consecutively) but since the code will need moderate changes to run in this method I was looking to see the ini file loaded to memory. does anyone else have another method aside from the two suggested so far? both methods will work, but don't accomplish my goal. thanks again guys. Link to comment Share on other sites More sharing options...
DangerousDan Posted January 19, 2009 Author Share Posted January 19, 2009 (edited) Will that work though? because in the time the user1 has copied the file to their local directory, added the info, then copied it back to the initial location, user2 could have done the same, but faster, so when user1 copys it back, it will write over the info user2 input, as user1 will have the original info in there.opposite of what he suggested. not overwriting original file here, he's suggesting copy file locally and use it, the filedelete is after execution cleanup.main issue here is there are currently ~20 users; could be as many as 1000 users company wide using this file, and all log on at different times (three working shifts; four apps written into program spanning three departments) Edited January 19, 2009 by DangerousDan Link to comment Share on other sites More sharing options...
Danny35d Posted January 19, 2009 Share Posted January 19, 2009 Take a look to this link database replacement for INI functionsYou can modify the code to have sqlite DB loaded into memory. AutoIt Scripts:NetPrinter - Network Printer UtilityRobocopyGUI - GUI interface for M$ robocopy command line Link to comment Share on other sites More sharing options...
DangerousDan Posted January 19, 2009 Author Share Posted January 19, 2009 Take a look to this link database replacement for INI functionsYou can modify the code to have sqlite DB loaded into memory.that is a step in the right direction then. however, I do not currently have the knowledge to use SQL_lite functions. I will have to read more, it would appear, unless someone wants to modify the script in the linked post for me If this method ends up working out I'd like to be able to load the ini to memory when certain functions are called from my program, that way the data is updated before it is used but it doesn't read from the network each time the data is used in the function. The data is only used for short periods at a time, so loading to memory at the beginning of the function is the best way to keep it up to date. It's looking more and more like I'd need to use an array; either way I am going to have to modify some major code. at least with the array method I'll be modifying my code and making sure I don't make the same programming mistake twice thanks for the help everyone, and unless someone has the free time to modify the SQL_lite DB ini code for my use I will call this resolved Link to comment Share on other sites More sharing options...
ResNullius Posted January 19, 2009 Share Posted January 19, 2009 is there any way to load the ini file to memory and then use the iniread functionality on the file in memory, similar to fileopen?You might find this helpfull _IniString Functions - read/write Ini files stored as string variables Link to comment Share on other sites More sharing options...
DangerousDan Posted January 19, 2009 Author Share Posted January 19, 2009 (edited) You might find this helpfull _IniString Functions - read/write Ini files stored as string variables That's fantastic, actually Thanks a ton! I recognize your screen name too, thanks for helping me by helping others. edit: that couldn't have been simpler. it tool me all of two minutes to make the necessary changes to the script, thanks again ResNullius Edited January 20, 2009 by DangerousDan 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