I created a database with the following procedure in it to grab all the persistent variables and values out of some databases I’m working on.
Curiously, the “DataValue()” function seems to return an empty string for most values.
Note: The variables _TimeLapseSession
and _ManipulateData_t_History
have their values populated.
Below is the procedure, in full. The line I’m wondering about is:
vValue = str(datavalue(varName))
It doesn’t seem to matter if I encapsulate the datavalue()
function in a str()
function or not.
Additionally, the DataType()
function seems to only return “Text” for text variables, but does not return the type information for other variables.
Note: all of this is really more a curiosity than anything else. Just wondering if anyone else has run into this.
TIA for any thoughts/suggestions.
– Mark
/*
** Grab Variables
**
** Walk through a list of databases (dbList) and grab all file, global, and permanent variables
**
** This should be called from a database that has these (all text) fields, named:
**
** vDB : name of database that the variable was found in
** vScope : scope of variable (file, global, or permanent)
** vName : name of variable
** vValue : value of variable (converted to text)
** vType : type of variable
**
** Note: this could take a long time to complete, if there are a lot of variables in the databases being scanned
*/
local dbList, varScopeList, dbIndex
dbList = "Customers,Inventory,Transactions"
varScopeList = "File,filevariables:Global,fileglobals:Permanent,permanent"
dbIndex = 1
loop
local db, varScopeIndex
db = array(dbList, dbIndex, ",")
varScopeIndex = 1
loop
local varScope, varList, varIndex
// Get the first item of the "varScopeIndex'th" element of the varScopeList
varScope = array(array(varScopeList, varScopeIndex, ":"),1,",")
// Use the second item of the "varScopeIndex'th" element of the varScopeList
varList = arraysort(dbinfo(array(array(varScopeList, varScopeIndex, ":"),2,","),db), ¶)
varIndex = 1
loop
local varName
varName = array(varList, varIndex, ¶)
addrecord
vDB = db
vName = varName
vType = datatype(varName)
vValue = str(datavalue(varName))
vScope = varScope
varIndex = varIndex + 1
while varIndex <= arraysize(varList, ¶)
varScopeIndex = varScopeIndex + 1
while varScopeIndex <= arraysize(varScopeList, ":")
dbIndex = dbIndex + 1
while dbIndex <= arraysize(dbList, ",")