AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Snippets and Tutorials (https://forums.alliedmods.net/forumdisplay.php?f=112)
-   -   KeyValue key behaves differently between \ and / slashes (https://forums.alliedmods.net/showthread.php?t=244787)

Bacardi 07-23-2014 16:22

KeyValue key behaves differently between \ and / slashes
 
...did you know ?

PHP Code:

new String:example_one[][] = {
    
"folder00/folder01/folder02",
    
"folder10/folder11/folder12",
    
"folder20/folder21/folder22"
}

new 
String:example_two[][] = {
    
"folder30\\folder31\\folder32",
    
"folder40\\folder41\\folder42",
    
"folder50\\folder51\\folder52"
}

public 
OnPluginStart()
{
    new 
Handle:kv CreateKeyValues("testing");

    
KvJumpToKey(kv"example_one"true);
    for(new 
0sizeof(example_one); a++)
    {
        
KvSetString(kvexample_one[a], "value");
    }
    
KvRewind(kv);


    
KvJumpToKey(kv"example_two"true);
    for(new 
0sizeof(example_two); a++)
    {
        
KvSetString(kvexample_two[a], "value");
    }
    
KvRewind(kv);


    
KeyValuesToFile(kv"output.txt");
    
CloseHandle(kv);


Code:

"testing"
{
        "example_one"
        {
                "folder00"
                {
                        "folder01"
                        {
                                "folder02"                "value"
                        }
                }
                "folder10"
                {
                        "folder11"
                        {
                                "folder12"                "value"
                        }
                }
                "folder20"
                {
                        "folder21"
                        {
                                "folder22"                "value"
                        }
                }
        }

        "example_two"
        {
                "folder30\folder31\folder32"                "value"
                "folder40\folder41\folder42"                "value"
                "folder50\folder51\folder52"                "value"
        }

}


WildCard65 07-23-2014 16:32

Re: KeyValue key behaves differently between \ and / slashes
 
That is interesting O_O

VoiDeD 07-23-2014 20:27

Re: KeyValue key behaves differently between \ and / slashes
 
'\' is an escape character in KV.
The '/' subkey feature has existed for a while: https://mxr.alliedmods.net/hl2sdk-sd...Values.cpp#923

Powerlord 07-25-2014 18:40

Re: KeyValue key behaves differently between \ and / slashes
 
Quote:

Originally Posted by VoiDeD (Post 2172727)
'\' is an escape character in KV.
The '/' subkey feature has existed for a while: https://mxr.alliedmods.net/hl2sdk-sd...Values.cpp#923

Last I checked, escape characters are turned off on KV unless you explicitly turn them on. In SourcePawn, this is done with the KvSetEscapeSequences command.

Edit: Incidentally, the / "feature" explains a bug I've seen before when trying to check if a key exists and the key itself is a filepath.


All times are GMT -4. The time now is 18:28.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.