All pastes #386503 Raw Edit

Miscellany

public text v1 · immutable
·published 2007-03-08 17:45 UTC
rendered paste body
#include <a_samp>
#include <dini>

main()Test();

new file[] = "bla.txt";

Test()
{
    print("\n");
    if(dini_Exists(file)) dini_Remove(file); // if the file exist, remove it

    dini_Create(file); // and create it
    dini_Set(file,"a","b"); // set a key named "a" as a string, with the value "b"

    if(dini_Isset(file,"a")) // if the key named "a" exists
    {
        dini_IntSet(file,"int",5); // set a key "int" as an integer with value 5
        dini_FloatSet(file,"float",1.2); // set a key "float" as a float with value 1.2
        dini_BoolSet(file,"bool",true); // set a key "bool" as a boolean with value true

        printf("a = %s",dini_Get(file,"a")); // get the value of the key "a" and print it
        printf("int = %d",dini_Int(file,"int")); // get the value of the key "int" and print it
        printf("float = %f",dini_Float(file,"float")); // get the value of the key "float" and print it
        printf("bool = %d",dini_Bool(file,"bool")); // get the value of the key "bool" and print it

/*      dini_Unset(file,"a"); // remove the key "a"
        dini_Unset(file,"int"); // remove the key "int"
        dini_Unset(file,"float"); // remove the key "float"
        dini_Unset(file,"bool"); // remove the key "bool"
        dini_Remove(file); // remove the whole file
*/
    }
    return 1;
}