Difference between revisions of "LavishScript:Object Queries"
Jump to navigation
Jump to search
Line 1: | Line 1: | ||
{{stub}} | {{stub}} | ||
+ | == Description == | ||
+ | :Object query support has been added. Extensions can use ISXDK 30a (or later) for direct access to this functionality. An object query is a math formula where all variables are relative to a specific object, and results in a boolean value -- the query is either true, or it is false. | ||
+ | :Query math can compare and manipulate text, decimals, or integers (note that bool counts as an integer for this purpose) with standard math operators. Text comparisons are not case sensitive. | ||
+ | :One intended use for object queries is a uniform search mechanism, to find an object or set of objects from a larger set of objects (compare to a SQL SELECT statement, where a LavishScript object query is the WHERE clause). | ||
− | + | == Members == | |
− | + | * [[ObjectType:uint|uint]] '''LavishScript.CreateQuery['''expression''']''': Creates a query with the given expression -- e.g. ${LavishScript.CreateQuery[Name=="Bonkers"]} | |
− | + | * [[ObjectType:string|string]] '''LavishScript.RetrieveQueryExpression['''#''']''': Retrieves the query expression for a previously created query, by ID | |
− | + | * [[ObjectType:bool|bool]] '''LavishScript.QueryEvaluate['''#, object''']''': Determines if the given object matches the given query | |
− | |||
− | |||
− | |||
− | |||
− | |||
+ | == Methods == | ||
+ | * '''LavishScript:FreeQuery['''#''']''': Frees a previously created query, by ID | ||
− | + | == Expression/Operator Notes == | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
* Math operators identical to LS | * Math operators identical to LS | ||
* &&, ||, and () are supported | * &&, ||, and () are supported | ||
Line 25: | Line 20: | ||
:* = Weak compare, value only | :* = Weak compare, value only | ||
:* == Strong compare, value + type | :* == Strong compare, value + type | ||
+ | |||
+ | == Example == | ||
+ | |||
+ | function main() | ||
+ | { | ||
+ | variable int ID | ||
+ | variable int ID1 | ||
+ | |||
+ | ; Example: Compare System.OS | ||
+ | ID:Set[${LavishScript.CreateQuery[OS = "Windows 7 Ultimate"]}] | ||
+ | ID1:Set[${LavishScript.CreateQuery[OS = "Windows 7 Ultimate && MemFree < 500 && MemTotal > 1000"]}] | ||
+ | |||
+ | echo ID ${ID} | ||
+ | echo LavishScript.RetrieveQueryExpression[${ID}] "${LavishScript.RetrieveQueryExpression[${ID}]}" | ||
+ | echo LavishScript.RetrieveQueryExpression[${ID1}] "${LavishScript.RetrieveQueryExpression[${ID1}]}" | ||
+ | |||
+ | echo System.OS ${System.OS} | ||
+ | echo LavishScript.QueryEvaluate[${ID}, System] ${LavishScript.QueryEvaluate[${ID}, System]} | ||
+ | echo LavishScript.QueryEvaluate[${ID1}, System] ${LavishScript.QueryEvaluate[${ID}, System]} | ||
+ | |||
+ | LavishScript.FreeQuery[${ID}] | ||
+ | LavishScript.FreeQuery[${ID1}] | ||
+ | } | ||
+ | |||
+ | ID 7 | ||
+ | LavishScript.RetrieveQueryExpression[7] "OS = "Windows 7 Ultimate"" | ||
+ | LavishScript.RetrieveQueryExpression[8] "OS = "Windows 7 Ultimate && MemFree < 500 && MemTotal > 1000"" | ||
+ | System.OS Windows 7 Ultimate | ||
+ | LavishScript.QueryEvaluate[7, System] TRUE | ||
+ | LavishScript.QueryEvaluate[8, System] FALSE |
Revision as of 19:09, 15 January 2010
Description
- Object query support has been added. Extensions can use ISXDK 30a (or later) for direct access to this functionality. An object query is a math formula where all variables are relative to a specific object, and results in a boolean value -- the query is either true, or it is false.
- Query math can compare and manipulate text, decimals, or integers (note that bool counts as an integer for this purpose) with standard math operators. Text comparisons are not case sensitive.
- One intended use for object queries is a uniform search mechanism, to find an object or set of objects from a larger set of objects (compare to a SQL SELECT statement, where a LavishScript object query is the WHERE clause).
Members
- uint LavishScript.CreateQuery[expression]: Creates a query with the given expression -- e.g. ${LavishScript.CreateQuery[Name=="Bonkers"]}
- string LavishScript.RetrieveQueryExpression[#]: Retrieves the query expression for a previously created query, by ID
- bool LavishScript.QueryEvaluate[#, object]: Determines if the given object matches the given query
Methods
- LavishScript:FreeQuery[#]: Frees a previously created query, by ID
Expression/Operator Notes
- Math operators identical to LS
- &&, ||, and () are supported
- Special Operators:
- =- Substring Name =- "Boobies" is true if Name.Find[Boobies]
- = Weak compare, value only
- == Strong compare, value + type
Example
function main() { variable int ID variable int ID1 ; Example: Compare System.OS ID:Set[${LavishScript.CreateQuery[OS = "Windows 7 Ultimate"]}] ID1:Set[${LavishScript.CreateQuery[OS = "Windows 7 Ultimate && MemFree < 500 && MemTotal > 1000"]}] echo ID ${ID} echo LavishScript.RetrieveQueryExpression[${ID}] "${LavishScript.RetrieveQueryExpression[${ID}]}" echo LavishScript.RetrieveQueryExpression[${ID1}] "${LavishScript.RetrieveQueryExpression[${ID1}]}" echo System.OS ${System.OS} echo LavishScript.QueryEvaluate[${ID}, System] ${LavishScript.QueryEvaluate[${ID}, System]} echo LavishScript.QueryEvaluate[${ID1}, System] ${LavishScript.QueryEvaluate[${ID}, System]} LavishScript.FreeQuery[${ID}] LavishScript.FreeQuery[${ID1}] }
ID 7 LavishScript.RetrieveQueryExpression[7] "OS = "Windows 7 Ultimate"" LavishScript.RetrieveQueryExpression[8] "OS = "Windows 7 Ultimate && MemFree < 500 && MemTotal > 1000"" System.OS Windows 7 Ultimate LavishScript.QueryEvaluate[7, System] TRUE LavishScript.QueryEvaluate[8, System] FALSE