#
Declare an options variable
options o;
# Set the token separator for the options
o.SetToken(":");
# Set the comment indicator for the options
# Anthing in the file after # will be ignored
# (although, does nothing here)
o.SetComment("#");
# Display the options (0 Keys)
disp(o);
# Add some option key/value sets
o.AddOption("Name", "Phantom");
o.AddOption("Occupation", "Automation");
o.AddOption("Age", "Timeless");
# Display the numnber of keys
disp("Key Count: " + string(o.GetCount()));
# List the values in the options
disp("The Values are: ");
disp(o.List());
# Save the options
o.Save("test_options.txt");
# Clear the options
o.Clear();
# Display the options, verifying that
# the keys have been cleared
disp(o);
# Reload the options from the file
o.Load("test_options.txt");
# Set the 'Age' option to a new value
o.SetOption("Age", "Timeless + 1");
# Display the loaded and changed option
# count and values
disp("Key Count: " + string(o.GetCount()));
disp("The Values are: ");
disp(o.List());
# Get only the 'Name' option
disp("Name only: ");
disp(o.GetOption("Name"));
# Get the 3rd key in the option set
disp("The 3rd key (index 0) is: ");
disp(o.GetKey(2));
# Get the value associated with the
# third key in the option set
disp("The 3rd value (index 0) is: ");
disp(o.GetOption(o.GetKey(2)));
# Look for the
key 'Age'
if(o.HasKey("Age")){
disp("Option 'Age': " + o.GetOption("Age"));
}
|