michaelslamet Posted November 14, 2013 Share Posted November 14, 2013 Hello, World Back to 2010, when I first hear and learn about AutoIT, I created some scripts that I still developing until today. I use text files a lot. At that time, I never heard about INI files (and the related functions like IniRead, IniReadSection, etc), so I create my own function to read (and write) the text files using FileReadLine, FileOpen and sort of them. Those functions works very well, but they are very fragile because it's very line-dependent, means $varA has to be at line 11, $varB has to be at line 15, etc, so when I need to add some line into the text file, I need to change many part of the scripts. This is problem because the scripts consist of 3000~4000 ++ lines and "connected" to each others. I am thinking to add a section to those text files so I can use INI function to read them, this way I dont need to worry if I need to add lines, although thinking this make my head spinning hard. Any advices for me? Thank you Link to comment Share on other sites More sharing options...
Xenobiologist Posted November 14, 2013 Share Posted November 14, 2013 What kind of information to you store in that files? Maybe a database would be nice. Otherwise switching to ini should be easy. Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times Link to comment Share on other sites More sharing options...
czardas Posted November 14, 2013 Share Posted November 14, 2013 ini files are generally used to store program settings. What you probably need is some sort of database to access information I guess. Programs don't generally have 4000 settings. I see I'm a bit slow in answering. operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
water Posted November 14, 2013 Share Posted November 14, 2013 (edited) I would leave the text files alone and write the new data to a separate Ini file using the Ini* functions. Edited November 14, 2013 by water My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
michaelslamet Posted November 14, 2013 Author Share Posted November 14, 2013 What kind of information to you store in that files? Maybe a database would be nice. Otherwise switching to ini should be easy. Mega, Thanks for taking time to reply Those text files store variable/field like size, price, color. Yes, a database would be nice but this is already wrong from the first time, and changing all those scripts to database model is not a good idea for now Link to comment Share on other sites More sharing options...
michaelslamet Posted November 14, 2013 Author Share Posted November 14, 2013 ini files are generally used to store program settings. What you probably need is some sort of database to access information I guess. Programs don't generally have 4000 settings. I see I'm a bit slow in answering. A mean the script has 4000++ lines, not the text file Link to comment Share on other sites More sharing options...
michaelslamet Posted November 14, 2013 Author Share Posted November 14, 2013 I would leave the text files alone and write the new data to a saparate Ini file using the Ini* functions. Aha! So you suggest I should keep two version, one the old version and one the new (INI) version, until the INI version tested and ready, I should use the old version, is that? Link to comment Share on other sites More sharing options...
water Posted November 14, 2013 Share Posted November 14, 2013 Correct. How much data in the Ini files are we talkign about? There seems to be a limit of 32K. Be it the total size of the Ini file or the size of a section. My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
czardas Posted November 14, 2013 Share Posted November 14, 2013 A mean the script has 4000++ lines, not the text file Ah, okay my mistake. operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
michaelslamet Posted November 14, 2013 Author Share Posted November 14, 2013 Correct. How much data in the Ini files are we talkign about? There seems to be a limit of 32K. Be it the total size of the Ini file or the size of a section. Not much, each text file only consist of no more than 50 lines so it wont break the 32K limit Link to comment Share on other sites More sharing options...
water Posted November 14, 2013 Share Posted November 14, 2013 Then moving to Ini files shouldn't be a problem. My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
michaelslamet Posted November 14, 2013 Author Share Posted November 14, 2013 Is there any trick to let the INI* function read the text file without add a section ([sectionName]) to the text file? That way I dont need to add [sectionName] to the top of the text files and current function will work because there is no lines change in the text file Link to comment Share on other sites More sharing options...
czardas Posted November 14, 2013 Share Posted November 14, 2013 (edited) There's no way to determine section, key or its value without using some sort of reference. You can easily prefix numbered keys to every line in the file using AutoIt (or my >editor ... 3 operations ==> prefix '=' ... enumerate selection ... prefix 'key' - see demo gif). Results in ==> key1=data1 key2=data2 key3=data3 You will have to change the code to access the information in your main script if you use ini functions. Edited November 14, 2013 by czardas operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
water Posted November 14, 2013 Share Posted November 14, 2013 That's why I suggested to leave the text file alone and start with an additional Ini file. Change your script(s) variable for variable. Means: Modify all statements where you read/write $varA so they point to the new Ini file. $varB still points to the text file. If $varA works then modify $varB etc. etc. My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki 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