 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
bmcclure
Joined: 24 Nov 2007 Posts: 774
|
Posted: Tue Mar 03, 2009 8:59 pm Post subject: |
|
|
Version 0.6.0 posted with all the changes we discussed. Most of them are included in the IniFile_test.ahk example now as well.
Let me know what you think, or if you see any errors I missed
New attributes:
headerComments under IniFile
New functions:
-IniFile_getComment
-IniFile_setComment
-IniFile_getHeaderComment
-IniFile_setHeaderComment
-IniFile_addHeaderComment
-IniFile_removeHeaderComment
-IniFile_loadFromVar
-IniFile_reload
-IniFile_reloadFromVar
Some functions have been overloaded with additional functionality. They should work exactly like before if you don't do anything differently, however.
Note that you can avoid calling the SortOptions parameter in every function by specifying you always want the file sorted:
| Code: | IniFile_setAutoSort(File, true)
IniFile_setSortOptions(File, "U") ; or whatever you want to use |
You can do the same to set ignoreComments, ignoreBlankLines, splitComments (split them to their own lines), quoteValues, etc. and it is handled automatically where appropriate. You can always (usually) override these defaults by using extra parameters in the function calls, where they are appropriate. _________________ Ben
My Trac projects
My Wiki
[Broken] - My music |
|
| Back to top |
|
 |
animeaime
Joined: 04 Nov 2008 Posts: 1045
|
Posted: Wed Mar 04, 2009 3:45 am Post subject: |
|
|
Looks good. Nice additions, can't wait to try them out.
I always use null ("") to mean an error (like removing an item from an empty Vector). I use 0 when zero (like an index) is returned. Also, I use 0 to mean the function was not successful (but not due to an error). For example, when destroying an object, it returns false (0) to indicate the object still exists (i.e. not ready to delete); whereas it returns null if the object is NULL (0 or blank), to indicate the error. _________________ As always, if you have any further questions, don't hesitate to ask.
Add OOP to your scripts via the Class Library. Check out my scripts. |
|
| Back to top |
|
 |
animeaime
Joined: 04 Nov 2008 Posts: 1045
|
Posted: Wed Mar 04, 2009 4:07 am Post subject: |
|
|
Observation: I see a value for duplicate keys, but it doesn't look like it is ever used.
Edit:
Not sure if it would cause problems, but for IniFile_loadFromVar (and IniFile_reLoadFromVar), you might want <data> to be ByRef. Since loadFromVar should be passing a variable, it means that large amounts of data don't need to be copied first, because the value is ByRef. However, this only is possible if data will ALWAYS be a variable.
Edit2:
Bug report. In IniFile_clear, you should be clearing the sections - you currently set it to zero (destroying the sections Vector)
This fixes it:
| Code: | IniFile_clear(IniFileObject) {
IniFile_setData(IniFileObject, "")
if sections := IniFile_getSections(IniFileObject)
Vector_clear(sections)
IniFIle_setLoaded(IniFileObject, 0)
return true
} |
_________________ As always, if you have any further questions, don't hesitate to ask.
Add OOP to your scripts via the Class Library. Check out my scripts. |
|
| Back to top |
|
 |
bmcclure
Joined: 24 Nov 2007 Posts: 774
|
Posted: Wed Mar 04, 2009 6:17 am Post subject: |
|
|
Still working on duplicate keys, I sort of forgot to include that in the release and have been busy with the DOM library.
I'll try to get that in place tomorrow.
In the meantime, I've changed data (and its reference in the reloadFromVar function) to ByRef, removed the extra call you messaged me about, and changed IniFile_clear() to clear the vector to fix the bug you found.
Thanks as usual!
Edit New version uploaded with the fixes. _________________ Ben
My Trac projects
My Wiki
[Broken] - My music |
|
| Back to top |
|
 |
animeaime
Joined: 04 Nov 2008 Posts: 1045
|
Posted: Wed Mar 04, 2009 6:18 am Post subject: |
|
|
No rush, thanks for your great work. _________________ As always, if you have any further questions, don't hesitate to ask.
Add OOP to your scripts via the Class Library. Check out my scripts. |
|
| Back to top |
|
 |
bmcclure
Joined: 24 Nov 2007 Posts: 774
|
Posted: Sat Mar 07, 2009 11:40 pm Post subject: |
|
|
New version (0.6.5) posted. Updating first topic.
1. Implemented changes in OOP Library V2, meaning:
- IniFiles, IniSections, and IniFields are all cloneable
- IniFiles, IniSections, and IniFields are all comparable
2. Fixed HeaderComment code to account for a change to the Vector class.
3. When a function has a problem, it now returns "" (null) instead of 0 (false) _________________ Ben
My Trac projects
My Wiki
[Broken] - My music |
|
| Back to top |
|
 |
bmcclure
Joined: 24 Nov 2007 Posts: 774
|
Posted: Sun Mar 08, 2009 4:09 pm Post subject: |
|
|
re-uploaded a new, very minor release, 0.6.6.
I had previously only used 4-bits per byte when setting bit flags, meaning I was using twice the amount of space I needed to for storing boolean values. (thanks, animeaime!)
I have now shortened IniFile objects from 23 bytes to 22  _________________ Ben
My Trac projects
My Wiki
[Broken] - My music |
|
| Back to top |
|
 |
bmcclure
Joined: 24 Nov 2007 Posts: 774
|
Posted: Sun Mar 08, 2009 5:19 pm Post subject: |
|
|
I also fixed the Clone function to utilize a feature I was unaware of in the Class library to clean up the Settings-only IniFile clone operation.
It's such a minor change that I didn't update the version number, but feel free to grab the new release from the first post if you plan to utilize IniFile cloning. _________________ Ben
My Trac projects
My Wiki
[Broken] - My music |
|
| Back to top |
|
 |
bmcclure
Joined: 24 Nov 2007 Posts: 774
|
Posted: Thu May 28, 2009 7:15 am Post subject: |
|
|
I'm starting to create an IniFileI interface to define what an IniFile class should be. Before I get too far, I want to check with anyone who has used this library, or any of the available Ini libraries:
Do you like the current function names in this library? Do you use the provided aliases to match Titan's functions, or do you access my functions directly?
if I'm going to make a change to the methods, I'd like to do it before releasing the interface if possible. _________________ Ben
My Trac projects
My Wiki
[Broken] - My music |
|
| Back to top |
|
 |
Mystiq
Joined: 08 Jan 2007 Posts: 83
|
Posted: Thu Jun 11, 2009 11:39 am Post subject: |
|
|
Am i correct that in the current release none of the duplicate keys removal options work? If so, any news on when it might get added?
Also i'd like to say thanks  |
|
| Back to top |
|
 |
bmcclure
Joined: 24 Nov 2007 Posts: 774
|
Posted: Thu Jun 11, 2009 2:40 pm Post subject: |
|
|
There are options (duplicateSections and duplicateKeys) you can set on the IniFile object to choose whether or not you want to allow duplicates in your IniFile.
After you create your IniFile object, use the following:
| Code: | IniFile_setDuplicateSections(IniFileObject, true)
IniFile_setDuplicateKeys(IniFileObject, true) |
This will allow both types of duplicates. By default duplicates are not allowed.
If it isn't working properly, I can take a look at it today.
Thanks. _________________ Ben
My Trac projects
My Wiki
[Broken] - My music |
|
| Back to top |
|
 |
ghee22
Joined: 04 Jul 2009 Posts: 36
|
Posted: Sun Oct 11, 2009 8:06 pm Post subject: |
|
|
When a value contains a ';' (semicolon), IniFile_read stops reading the value after the semicolon. Even suffixing a break ("`") before the semicolon fails to allow IniFile_read to read the complete line.
Here's my data:
task_notes=Execute following via Tivoli on all servers in environment:`ncd /var/spool/cron/crontabs`;for file in *`; do if [ -f $file ]`; then lines=`grep -v '^#'`n$file | grep -v '^$'|wc -l | sed 's/ //g'``;if [ "$lines" = "0" ]`; then crontab -r $file`;fi`;f`ni`;done`n
Here's my code:
| Code: | task_notes := IniFile_read(File, "crq", "task_notes")
MsgBox,,read from file,%task_notes% |
This is what MsgBox shows:
| Code: | | Execute following via Tivoli on all servers in environment:`ncd /var/spool/cron/crontabs` |
Is there a workaround? |
|
| Back to top |
|
 |
bmcclure
Joined: 24 Nov 2007 Posts: 774
|
Posted: Mon Oct 12, 2009 2:20 am Post subject: |
|
|
This was built surrounding the recognized INI file "standards" (basically non-existent) stating that a semicolon indicates the start of a comment and everything after it should be ignored (see http://en.wikipedia.org/wiki/INI_file).
However you're right, some sort of escape sequence should be supported so that semicolons can be used within actual content.
I've been heavily focused on my C# apps and libraries lately, but will make it a point to touch up this INI library and allow escape sequences for characters with meanings. _________________ Ben
My Trac projects
My Wiki
[Broken] - My music |
|
| Back to top |
|
 |
ghee22
Joined: 04 Jul 2009 Posts: 36
|
Posted: Mon Oct 12, 2009 1:48 pm Post subject: |
|
|
| bmcclure wrote: | This was built surrounding the recognized INI file "standards" (basically non-existent) stating that a semicolon indicates the start of a comment and everything after it should be ignored (see http://en.wikipedia.org/wiki/INI_file).
However you're right, some sort of escape sequence should be supported so that semicolons can be used within actual content.
I've been heavily focused on my C# apps and libraries lately, but will make it a point to touch up this INI library and allow escape sequences for characters with meanings. |
Thanks for underlying reason. What I did was use accent characters as a replacement for semicolons. Since the code I wrote will never be localized, I was not restricted by them. However, I do not recommend this solution if one plans to localize their code in the future.
Here's my code:
| Code: | String_multiline_to_save(ByRef target)
{
global
StringReplace, target, target, `n ,``n, All
StringReplace, target, target, `;, ¿ , All
Return
}
String_multiline_to_load(ByRef target, var_name)
{
global
target := IniFile_read(File, "crq", var_name)
;MsgBox,,read from file,%target%
StringReplace, target, target, ``n, `n , All
;MsgBox,,replaced newlines,%target%
StringReplace, target, target, ¿, `; , All
;MsgBox,,replaced semicolons,%target%
Return
}
|
|
|
| Back to top |
|
 |
kenn
Joined: 11 Oct 2010 Posts: 288
|
Posted: Tue Jan 11, 2011 8:20 pm Post subject: |
|
|
download link is dead  |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|