INI File Helper

Post your working scripts, libraries and tools
User avatar
Delta Pythagorean
Posts: 416
Joined: 13 Feb 2017, 13:44
GitHub: DelPyth
Location: Equestria

INI File Helper

12 Jul 2017, 00:58

I think some newish people to AHK could use this tool to help write their scripts.
So, some of these new people (Or lazy coders, I'm not judging.) might want to use this.
So here it is!
The INI File Helper!

Here's the code. Make sure to keep the whole code for it to work!

Code: [Select all] [Expand] [Download] (Untitled.ahk)GeSHi © Codebox Plus


I also added a little AHK Icon for you to enjoy ;)
Last edited by Delta Pythagorean on 13 Jul 2017, 22:15, edited 1 time in total.
User avatar
metacognition
Posts: 87
Joined: 22 Oct 2014, 05:57
Location: Alaska

Re: INI File Helper

12 Jul 2017, 02:12

Nice icon :)
User avatar
metacognition
Posts: 87
Joined: 22 Oct 2014, 05:57
Location: Alaska

Re: INI File Helper

12 Jul 2017, 02:16

Dang, this will come in handy!
User avatar
BGM
Posts: 419
Joined: 20 Nov 2013, 20:56
GitHub: bgmCoder
Contact:

Re: INI File Helper

12 Jul 2017, 10:27

neat! Thanks for sharing
A_AhkUser
Posts: 861
Joined: 06 Mar 2017, 16:18
Location: France

Re: INI File Helper

12 Jul 2017, 20:19

One suggestion among others possible:

You could make the catB edit control to be a dropdownlist:

Code: [Select all] [Download] GeSHi © Codebox Plus

Gui, INI:Add, DropDownList, x20 y145 w415 vCatB,


since you can retrieve a linefeed (`n) delimited list of section names, once an ini file is choosen:

Code: [Select all] [Download] GeSHi © Codebox Plus

SelectB:
FileSelectFile, FileB, 8, %A_Desktop%\, Please Create an INI File to Use., Configuration Files (*.ini)
SplitPath, % FileB,,, OutExtension
if (ErrorLevel or (OutExtension <> "ini"))
return
GuiControl, INI:, FileB, % FileB
IniRead, OutputVarSectionNames, % FileB ; retrieves a linefeed (`n) delimited list of section names
GuiControl, INI:, CatB, % "|" . StrReplace(OutputVarSectionNames, "`n", "|") ; fill the drop down list with the section names of the selected ini file
GuiControl, INI:Choose, CatB, 1
Return
User avatar
BGM
Posts: 419
Joined: 20 Nov 2013, 20:56
GitHub: bgmCoder
Contact:

Re: INI File Helper

12 Jul 2017, 21:23

The original was able to handle drag-n-drop onto the script's file icon - I like that better than using the file-browser dialogue.
User avatar
Delta Pythagorean
Posts: 416
Joined: 13 Feb 2017, 13:44
GitHub: DelPyth
Location: Equestria

Re: INI File Helper

13 Jul 2017, 22:14

A_AhkUser wrote:One suggestion among others possible:


Alright, I just added it to the original code for download.
Thanks for the suggestion!
A_AhkUser
Posts: 861
Joined: 06 Mar 2017, 16:18
Location: France

Re: INI File Helper

14 Jul 2017, 09:30

I just noticed running your updated script that, however, this way, it doesn't update the UPRead edit control. Actually, this can be solved by, for example, associating the dropdownlist with the update label as well:

Code: [Select all] [Download] GeSHi © Codebox Plus

Gui, INI:Add, DDL, x20 y145 w415 h200 vCatB gUpdate, Settings||


and by making the param3 parameter of the GuiControl, Choose sub-command actually trigger the g-label associated, using the pipe character:

Code: [Select all] [Download] GeSHi © Codebox Plus

SelectB:
; ...
GuiControl, INI:Choose, CatB, |1
Return
joefiesta
Posts: 153
Joined: 24 Jan 2016, 13:54

Re: INI File Helper

17 Feb 2018, 10:44

what does this code do? Would you expect me to read the source code for Windows to learn how Windows works?

After having written code for over 40 years, I've learned the value of documenting what I write--even when it is only for myself.
Especially when that 40 year old code still works perfectly fine!
User avatar
Delta Pythagorean
Posts: 416
Joined: 13 Feb 2017, 13:44
GitHub: DelPyth
Location: Equestria

Re: INI File Helper

23 Feb 2018, 00:27

joefiesta wrote:what does this code do? Would you expect me to read the source code for Windows to learn how Windows works?

After having written code for over 40 years, I've learned the value of documenting what I write--even when it is only for myself.
Especially when that 40 year old code still works perfectly fine!

I strongly dislike to use comments in my code unless it is to "remove" something from my code, or for a temporary "balance" in my code.
If I ever do add comments to my code, most likely it's for some complicated class/function that needs a bit of explaining to do.

If anything, with 40+ years of coding experience, you should know to read into the code itself and see what commands does what and why the programmer chose the parameters that they did.

This code was meant for the newer people that just simply need a bit of help with some daily commands to use. I personally don't need it as for I use JSON (I prefer not to use XML as for the large file sizes) to do my saving and reading when it comes to user set variables/"save for later" variables.

TL;DR:
I really don't understand what all the fuss is all about, I'm simply allowing users to use my code for which I have made. If they want to look into the source code, they may want to see how it works, but AHK already allows to see what commands are being executed, line by line, using this command: ListLines.
User avatar
gregster
Posts: 1378
Joined: 30 Sep 2013, 06:48

Re: INI File Helper

23 Feb 2018, 00:43

I think Joe's point might rather be that your original post doesn't state what your script actually does. A "helper" can be a lot of things. At least, this is what I thought when I first read this thread. Is it a library, a class, functions, a GUI of some kind, can I read and/or write ini files? What are the features?

I still don't know what your script does, partly because I don't feel a personal need for a "helper". But I might be wrong - a INI library would be useful, even if there are already others.
I would probably be able to understand the script by reading the source code - but then again, a beginner might not be. Therefore, I would welcome a little description of the actual goal of this script and what it does - because it could make this forum better.

edited
kunkel321
Posts: 162
Joined: 30 Nov 2015, 21:19
Facebook: https://www.facebook.com/kunkel321
Google: kunkel321

Re: INI File Helper

24 Feb 2018, 19:00

Cool thanks! I will likely use this!

Return to “Scripts and Functions”

Who is online

Users browsing this forum: pro100andrik94 and 17 guests