Page 2 of 2

Re: getkey - content of a whole section?

Posted: 05 Mar 2015 15:43
by admin
Can be done:

Code: Select all

text replace(getkey(, "General"), chr(0), <crlf>);

Re: getkey - content of a whole section?

Posted: 05 Mar 2015 15:54
by bdeshi
touche.

Re: getkey - content of a whole section?

Posted: 05 Mar 2015 16:10
by TheQwerty
Just to clarify....

1) GetKeyValueList() was "removed"/never added?

2) Is this correct?

getsectionlist()
    Returns a list of sections in an INI file or a list of 'key=value' pairs for the specified section.

    Syntax[code]getsectionlist([section], [INIfile], [separator=CRLF])[/code]      section    [optional] The name of the section.
                        If omitted a list of sections is returned.

      INIfile    [optional] The name of the INI file. Expects a filename
                        with extension, and can be absolute or relative to the
                        running script's path.
                        If omitted XYplorer's current INI file is used.

      separator  [optional] Separates the items in the returned list.
                        Defaults to CRLF (line feed).

      return     The list of sections or 'key=value' pairs in the
                        specified section.

    Examples[code]text getsectionlist();[/code]      Displays the list of sections in XYplorer's current INI file.[code]text getsectionlist('General');[/code]      Displays the list of 'key=value' pairs in the 'General' section of
      XYplorer's current INI file.[code]"Show Settings"
    $file = 'C:\Config\Settings.ini';
    $contents = '';
    foreach ($section, getsectionlist(,$file), <crlf>) {
        $contents = $contents . "[$section]<crlf>";
        $contents = $contents . getsectionlist($section, $file) . <crlf 2>;
    }
    text $contents;[/code]      Displays the contents of the 'C:\Config\Settings.ini' file.

Re: getkey - content of a whole section?

Posted: 05 Mar 2015 16:33
by admin
Perfecto! :appl:

FYI, the 2 API used here are:
https://msdn.microsoft.com/en-us/librar ... 85%29.aspx
https://msdn.microsoft.com/en-us/librar ... 85%29.aspx

Note that the API have some limits ("The maximum profile section size is 32,767 characters.") which do not apply to XYplorer's INI file (XY uses its own native much faster methods to read/write INI data), so the function might return cropped data where XYplorer's INI file leaves the range of what Windows considers a legal INI file.

Re: getkey - content of a whole section?

Posted: 05 Mar 2015 16:36
by TheQwerty
admin wrote:Perfecto! :appl:
Even the part about the 3rd argument being separator and also broken?

Currently, it's really more of a removeSeparators flag. :P

Re: getkey - content of a whole section?

Posted: 05 Mar 2015 16:39
by admin
TheQwerty wrote:
admin wrote:Perfecto! :appl:
Even the part about the 3rd argument being separator and also broken?

Currently, it's really more of a removeSeparators flag. :P
Oh :oops: . Blame it on the flu... :whistle: fix comes...

Re: getkey - content of a whole section?

Posted: 06 Mar 2015 08:57
by binocular222
Cannot find in Change log nor Help > Scripting Commands Reference :?
This sas secretly added?

Re: getkey - content of a whole section?

Posted: 06 Mar 2015 09:04
by highend
Had to use it in http://www.xyplorer.com/xyfc/viewtopic.php?f=7&t=13510 :)

Although it uses a regexmatches fallback for those that aren't on the latest release...

Re: getkey - content of a whole section?

Posted: 06 Mar 2015 11:42
by admin
binocular222 wrote:Cannot find in Change log nor Help > Scripting Commands Reference :?
This sas secretly added?
Will be added later. (Thanks to TheQwerty it's just a copy-paste job for me :tup: )

Re: getkey - content of a whole section?

Posted: 12 Mar 2015 17:05
by TheQwerty
admin wrote:
binocular222 wrote:Cannot find in Change log nor Help > Scripting Commands Reference :?
This sas secretly added?
Will be added later. (Thanks to TheQwerty it's just a copy-paste job for me :tup: )
You shouldn't have copied directly from that TheQwerty guy he's making your documentation look bad:
::help 'idh_scripting_comref.htm#idh_sc_getsectionlist'; wrote:INIfile [optional] The name of the INI file. Expects a filename with extension, and can be absolute or relative to the to the running script's path.

Re: getkey - content of a whole section?

Posted: 12 Mar 2015 17:10
by admin
At least I remembered to remove this:
*Broken - currently just removes the separator between
items when set.

Re: getkey - content of a whole section?

Posted: 12 Mar 2015 17:35
by TheQwerty
admin wrote:At least I remembered to remove this:
*Broken - currently just removes the separator between
items when set.
Thanks I updated the forum docs. ;)