Difference between revisions of "XML: Storing Strings"
Revision as of 09:43, 25 August 2014
XML: Storing Strings
The need to store strings is an issue sometimes faced when coding in XML, particularly when designing a gauge that utilizes the gps module (for example, when making an FMS). Options to store string data include:
1. Use of XML String Operators ord chr and scat to store and retrieve the ascii code equivalent of individual string characters in L:Vars. This has been the standard approach.
2. Macros that make use of the String Operators and enable more than one string character (up to 6) to be stored into a single L:Var. For example, Roman Stoviak has written a very clever set of macros that use String and Numerical Operators to store up to 4 string characters into L:Vars. http://forum.avsim.net/topic/299204-...g-string-data/
3. The internal registers, e.g., s0 … s49, with the limitation that these registers are wiped clean every update cycle.
4. String to memory dll module. Doug Dawson’s bottomless bag of cool tricks includes a prototype (September 2011) module that will allow strings to be stored into memory. Tested in FSX. Requires the loading of the dll module but you won't need the macros from 2. See this FSDeveloper link: 
5. XMLVars. FS9 and FSX. Developed by Tom Aguilo, XMLVars is a powerful module that enables the use of custom variables, a kind of L:Var, for storing and retrieving data to/from memory while Flight Simulator is active. Like L:Vars, XMLVars can be read by any gauge in an aircraft panel, can have any name, can hold numeric values of any kind and, unlike L:Vars, can also handle string values. Additionally, because of XMLVars flexibility of naming variables, it can handle standard multidimensional array-style manipulation of data, a powerful tool that is not possible to work with through the native L:Vars unless a complex group of macros is suited for the task. Requires the loading of the dll module but you won't need the macros from 2. See this FSDeveloper link: http://fsdeveloper.com/forum/showthread.php?t=207518
6. XML read/write to hard disk. Robbie McElrath has released 'Logger', a dll module that enables very easy file read/write capability: XML--> HDD--> XML. Accommodates strings and numbers, works with all text and .csv file formats, FS9 and FSX. Logger can be freely downloaded from http://robbiemcelrath.com/blackbox/?logger
7. A variation on 2), Robbie has scripted XML macros that utilize String and Bit Operators to manipulate strings and store the result into L:Vars. Please see this FSDeveloper link:  Features of these macros:
a) Strings of up to 64 ascii characters, including spaces, long can be stored in a single L:Var. All ascii special characters: !, @, #, $, % etc. etc. except & , / , \ , < , and ' (single quote) are accommodated in addition to all of the alphanumerics.
b) The L:Var can have any name and there can be any number of such 'string' L:Vars in a gauge. The 'string' L:Vars can be read by any XML gauge in your panel set, similar to normal L:Vars.
c) Functional Backspace and Clear (delete)
d) FS9 and FSX.
The macros and further discussion of storing strings are in this FSDeveloper thread: