THIS SOFTWARE IS PROVIDED BY MICHAEL BAILEY ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. of conditions and the following disclaimer in the documentation and/or other materials Redistributions in binary form must reproduce the above copyright notice, this list conditions and the following disclaimer. Redistributions of source code must retain the above copyright notice, this list of permitted provided that the following conditions are met: Redistribution and use in source and binary forms, with or without modification, are Copyright 2012 Michael Bailey (Marcus Llewellyn). It returns the LSL constant TRUE if it does, or FALSE if it does not. This function can be used simply to check whether or not a key from a given section exists. integer KeyExists(list ini, string inisection, string inikey) A list containing the updated INI data is returned in its entirety. It expects a list containing INI data, the name of the section that contains the key, and the name of the key to be removed. list DeleteINIKey(list ini, string inisection, string inikey)ĭeleteINIKey deletes a key from a section. It removes all key/value pairs associated with the section as well. This function will remove an entire section from the INI data passed to it, and return a list containing the resulting INI data in its entirety. list DeleteINISection(list ini, string inisection) GetINIKeyList likewise returns a list of all the keys within a specified section from the INI date passed to it. list GetINIKeyList(list ini, string inisection) GetINISectionList simply returns a list which contains all sections within the INI data passed to it. Any leading or trailing spaces are trimmed from the key. This function returns a list that contains the newly updated INI data in its entirety. If it does exist, the value will be updated with the one you provide. If the section or key do not yet exist, they will be created. You can use SetINIKey in a few different ways. This function is passed a list containing INI data, the name of a section, name of a key, and a value assigned to the key. list SetINIKey(list ini, string inisection, string inikey, string inivalue) If no value is found, it simply returns an empty string. It expects a list containing INI data, the name of a section, and the name of the key. GetINIKey returns the value of a section’s key. string GetINIKey(list ini, string inisection, string inikey) The notecard must, of course, reside in the contents of the same prim as the script using this function. You’ll probably want this list to be assigned to a global variable, as many of the other functions require this list to be passed to it, and return it. This state simply takes a notecard with INI formatted data, reads it, and returns a list that contains the INI data. A description of this state and each function follows. A state for reading the notecard is also provided. The following functions are provided: GetINIKey, SetINIKey, GetINISectionList, GetINIKeyList, DeleteINISection, DeleteINIKey, and KeyExists. I have used modified versions there, so they’re usable on Aurora-Sim if you’re up to tracking down the different ways scripts function there. As written, these functions also will not function properly on Aurora-Sim. In addition, SL imposes limits on lists that XEngine does not. These may work over in SL, but have not been tested there. These functions were written and tested with OpenSimulator’s XEngine in mind. Unless you go nuts, this should still be sufficient for most uses. This is important because a notecard line is limited to 255 characters, so you must keep in mind that any values you store share those 255 characters with the name of the section, the key, and two null characters. Each list element is composed of a section, key, and value delimited by a null character. Within a script, the INI data is stored in a single list. They do not store them, and comments will not be preserved when the notecard is written. They cannot be appended to the end a key/value pair. Comments must start with a semicolon and occupy a notecard line of their own. These functions have some limited support for INI style comments within the notecard. I want to provide a full description of the functions available, but if you’re in a hurry to simply grab them, scroll down to the bottom of this page for the full code. Another version of these functions that uses OSSL functions is available, and has to ability to write data to a notecard. This page contains code from a script that enables a scripter to read and manipulate notecards that contain data in the INI File format.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |