getkey - content of a whole section?

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
admin
Site Admin
Posts: 66259
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: getkey - content of a whole section?

Post by admin »

Can be done:

Code: Select all

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

bdeshi
Posts: 4256
Joined: 12 Mar 2014 17:27
Location: Asteroid B-612
Contact:

Re: getkey - content of a whole section?

Post by bdeshi »

touche.
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]

TheQwerty
Posts: 4373
Joined: 03 Aug 2007 22:30

Re: getkey - content of a whole section?

Post 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.

admin
Site Admin
Posts: 66259
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: getkey - content of a whole section?

Post 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.

TheQwerty
Posts: 4373
Joined: 03 Aug 2007 22:30

Re: getkey - content of a whole section?

Post 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

admin
Site Admin
Posts: 66259
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: getkey - content of a whole section?

Post 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...

binocular222
Posts: 1423
Joined: 04 Nov 2008 05:35
Location: Win11, Win10, 100% Scaling

Re: getkey - content of a whole section?

Post by binocular222 »

Cannot find in Change log nor Help > Scripting Commands Reference :?
This sas secretly added?
I'm a casual coder using AHK language. All of my xys scripts:
http://www.xyplorer.com/xyfc/viewtopic. ... 243#p82488

highend
Posts: 14940
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: getkey - content of a whole section?

Post 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...
One of my scripts helped you out? Please donate via Paypal

admin
Site Admin
Posts: 66259
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: getkey - content of a whole section?

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

TheQwerty
Posts: 4373
Joined: 03 Aug 2007 22:30

Re: getkey - content of a whole section?

Post 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.

admin
Site Admin
Posts: 66259
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: getkey - content of a whole section?

Post by admin »

At least I remembered to remove this:
*Broken - currently just removes the separator between
items when set.

TheQwerty
Posts: 4373
Joined: 03 Aug 2007 22:30

Re: getkey - content of a whole section?

Post 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. ;)

Post Reply