Page 1 of 1

ini file - function to get all key-value for a section

PostPosted: Thu Nov 10, 2022 10:50 am
by hua
What is the function to retrieve all pair of keys and values under a specific section?
Is it this? https://learn.microsoft.com/en-us/windo ... ilesection

TIA

Re: ini file - function to get all key-value for a section

PostPosted: Thu Nov 10, 2022 1:56 pm
by Enrico Maria Giordano
This returns all the keys of a section:

Code: Select all  Expand view
FUNCTION GETPVPROFSECTION( cSection, cIniFile )

    LOCAL cKeys := STRTRAN( GETPVPROFSTRING( cSection, , "", cIniFile ), CHR( 0 ), CRLF )

    LOCAL aKeys := {}

    LOCAL i

    FOR i = 1 TO MLCOUNT( cKeys )
        AADD( aKeys, RTRIM( MEMOLINE( cKeys, , i ) ) )
    NEXT

    RETURN aKeys

Re: ini file - function to get all key-value for a section

PostPosted: Fri Nov 11, 2022 1:58 am
by hua
Thank you very much Enrico