Jump to content

Recommended Posts

Posted

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

Posted

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

Posted

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. :mellow:

Posted (edited)

I would leave the text files alone and write the new data to a separate Ini file using the Ini* functions.

Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Posted

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

Posted

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. :mellow:

 

A mean the script has 4000++ lines, not the text file :)

Posted

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?

Posted

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 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Posted

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

Posted

Then moving to Ini files shouldn't be a problem.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Posted

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

Posted (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 by czardas
Posted

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 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

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
  • Recently Browsing   0 members

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