Tables Items Related Functions

All Table's items related functions are mapped on the TB.Item table. These functions are used to performs various actions on the table entries.

  • TB.Item.Compare(record1, record2, greater, columns)
  • TB.Item.Exists(table, index)
  • TB.Item.Find(table, value, caseSensitive, exactString)
  • TB.Item.IsNil(table, index)


TB.Item.Compare(record1, record2, greater, columns)

result = TB.Item.Compare(record1, record2, greater, columns)

This routine is used to compare two records (tables). The comparison is based on one or more fields (indexes), this fields must be specified in the 'columns' table. 'greater' is a table with booleans and specify what kind of comparisons must be performed: if TRUE means that the following check will be made:

record1.field is greater then record2.field ?

This routine supports multilevel comparisons, just supply the field names in the 'columns' table and in the right order.

INPUT

  • record1 : First record to compare
  • record2 : Second record to compare
  • greater : One or more comparison specification(s)
  • columns : One or more field name(s)

OUTPUT

  • result : Returns TRUE if the comparison is satisfied.


TB.Item.Exists(table, index)

result = TB.Item.Exists(table, index)

Returns TRUE if 'index' is not NIL within 'table' otherwise returns FALSE.
This function is usefull to test if there are defined items within tables.

INPUT

  • table : The table you need to check for 'index' key
  • index : The index to check

OUTPUT

  • result : True if 'index' is defined within 'table'


TB.Item.Find(table, value, caseSensitive, exactString)

found, index = TB.Item.Find(table, value, caseSensitive, exactString)

Search in 'table' an item with the value equal to 'value'. The search will be performed only on the first table level (subtables will not be scanned).
'value' can be of any type.

INPUT

  • table : Source table
  • value : Value to find
  • caseSensitive : Set to TRUE for case sensitive searches (strings)
  • exactString : Set to TRUE to match for the exact value, in this case casing will be ignored.

OUTPUT

  • found : TRUE if a result have been found
  • index : Index of the founded item

NOTE
Only the first occurence will be returned. For string values you can use pattern matching conventions as follow:

* : Matches all characters.
? : Matches just a single character.
# : Matches all numbers.
[] : Matches one or several characters or a range of characters

Additional information and usage here.



TB.Item.IsNil(table, index)

result = TB.Item.IsNil(table, index)

Returns TRUE if 'index' doesn't exists in 'table' otherwise returns FALSE.
This function is usefull to test if there are undefined items within tables.

INPUT

  • table : The table you need to check for the <index> key
  • index : The index/key to check

OUTPUT

  • result : TRUE if 'index' is not defined in 'table', otherwise FALSE.
    FALSE will be returned also if 'table' is NIL.
hollywoodlibs/tables/items.txt · Ultima modifica: 2016/10/21 00:24 da admin
CC Attribution-Noncommercial 4.0 International
Driven by DokuWiki Recent changes RSS feed Valid CSS Valid XHTML 1.0