Tables Misc Functions

All Tables related functions are mapped on the TB table.

  • TB.Copy(Source, SkipFunc)
  • TB.Count(table)
  • TB.Fill(Source, StartIndex, EndIndex, Value)
  • TB.Interpolate(Source, StartIndex, EndIndex, StartValue, EndValue, mode)
  • TB.Join(table1, table2)
  • TB.Merge(table1, table2, overwrite)
  • TB.PushDown(table, pos)
  • TB.PushUp(table, pos)
  • TB.ReIndex(oldKey, newKey, source)
  • TB.ReplaceChars(table, chars, replacer, recursive, casing)
  • TB.Set(Source, Changes, ReturnsNew)
  • TB.ShiftDown(table)
  • TB.ShiftUp(table)
  • TB.Sort(table, descending, column, associated, type)
  • TB.TrimSpaces(table, recursive)


TB.Copy(Source, SkipFunc)

result = TB.Copy(source, skipFunc)

Use this function to copy tables recursively, you can skip functions setting 'skipFunc' to TRUE.

INPUT

  • source : Source table too copy
  • skipFunc : Set to TRUE to exclude functions from the copy

OUTPUT

  • result : Copied table


TB.Count(table)

count = TB.Count(table)

Return how many entries are stored in 'table'. This function is able to count any type of table with any type of index.

INPUT

  • table : Source table

OUTPUT

  • count : Returns the number of items in the table or -1 if an error was occurred.

Additional information and usage here.



TB.Fill(Source, StartIndex, EndIndex, Value)

source = TB.Fill(Source, StartIndex, EndIndex, Value)

Simple function to fill/initialize a table range with a value.

INPUT

  • source : The table we want to fill with <value>
  • startIndex : Starting table's index
  • endIndex : Ending table's index
  • value : The value used to fill the table <source>

OUTPUT

  • source : The source table modified

NOTE
This function is only for linear tables indexed with numbers.



TB.Interpolate(Source, StartIndex, EndIndex, StartValue, EndValue, mode)

source = TB.Interpolate(Source, StartIndex, EndIndex, StartValue, EndValue, mode)

This function is used to fill the table 'source' with values. The index range is delimited by 'startIndex' and 'endIndex', the values range is delimited by 'startValue' and 'endValue'. 'mode' defines the interpolation mode, for all supported modes have a look at the Easing library.

INPUT

  • source : The table we want to fill with values
  • startIndex : Starting table's index
  • endIndex : Ending table's index
  • startValue : Starting value
  • endValue : Ending value
  • mode : Interpolation mode

OUTPUT

  • source : The source table modified

NOTE
This function is only for tables indexed with numbers. With this function you can easily precalculate paths for your moving objects.

Additional information and usage here.



TB.Join(table1, table2)

table1 = TB.Join(table1, table2)

Join 'table1' and 'table2', 'table1' will be modified directly adding all 'table2' entries.
This function can be used only with numerical-indexed tables.

INPUT

  • table1 : 'table1' to join
  • table2 : 'table2' to join

OUTPUT

  • table1 : 'table1' with all the 'table2' entries added at the end


TB.Merge(table1, table2, overwrite)

table1 = TB.Merge(table1, table2, overwrite)

Adds all 'table2' items to 'table1', note that 'table1'will be directly modified. 'overwrite' is used to specify if any existing 'table1' item should be overwritten by 'table2' items or not.

INPUT

  • table1 : Target table
  • table2 : Table to merge into 'table1'
  • overwrite : Set to TRUE to overwrite existing items

OUTPUT

  • table1 : The modified table (same as 'table1')

NOTE
This function is fully recursive.

Additional information and usage here.



TB.PushDown(table, pos)

TB.PushUp(table, pos)

Move the item at position 'pos' from its current position to the bottom and move all the rest up by one position.

INPUT

  • table : Source table
  • pos : Index of the item to push down

NOTES
This function is only for tables with consecutive numeric indexes starting from 0.

Additional information and usage here.



TB.PushUp(table, pos)

TB.PushUp(table, pos)

Move the item at position 'pos' from its current position to position 0 (to the top of the table) and move all the rest down by one position.

INPUT

  • table : Source table
  • pos : Index of the item to push up

NOTES
This function is only for tables with consecutive numeric indexes starting from 0.

Additional information and usage here.



TB.ReIndex(oldKey, newKey, source)

TB.ReIndex(oldKey, newKey, source)

For the given 'source' table, change the current index with the given column.
A new table will be generated and returned.

INPUT

  • oldKey : Old index name
  • newKey : New index name (column name)
  • source : Source table

OUTPUT

  • reindexed : Reindexed table

Additional information and usage here.



TB.ReplaceChars(table, chars, replacer, recursive, casing)

table = TB.ReplaceChars(table, chars, replacer, recursive)

Scans 'table' for each string entry and replaces any occurrencies of 'chars' with the string 'replacer'. Set 'recursive' to TRUE if you want to scan 'table' recusively.

INPUT

  • table : The table to process
  • chars : String to replace with 'replacer'
  • replacer : String that will replace 'chars'
  • recursive : Set to TRUE to process 'table' recursively
  • casing : True for case sensitive (default false)

OUTPUT

  • table : Processed source 'table'

NOTE
Non-string items will be skipped

Additional information and usage here.



TB.Set(Source, Changes, ReturnsNew)

result = TB.Set(Source, Changes, ReturnsNew)

Sets all fields found in the table 'source' with the corrisponding fields in the table 'changes', returns a new modified table if 'returnsNew' has been set to TRUE otherwise modify 'source' directly.
The process is recursive.

INPUT

  • source : The source table (the one we need to update)
  • changes : The table of changes
  • returnsNew : Set to TRUE to obtain a new table instead of modify directly the 'source' table.

OUTPUT

  • result : Nil in case of error or the new, updated table

Additional information and usage here.



TB.ShiftDown(table)

result = TB.ShiftDown(table)

Shifts all 'table' items down by one position, the last item will be placed at the first position.

INPUT

  • table : Source table

OUTPUT

  • result : Returns TRUE if 'table' was processed correctly

NOTES
This function is for tables with consecutive numeric indexes starting from 0.

Additional information and usage here.



TB.ShiftUp(table)

result = TB.ShiftUp(table)

Shifts all 'table' items up by one position, the first item will be placed at the last position.

INPUT

  • table : Source table

OUTPUT

  • result : Returns TRUE if 'table' was processed correctly

NOTES
This function is for tables with consecutive numeric indexes starting from 0.

Additional information and usage here.



TB.Sort(table, descending, column, associated, type)

sorted = TB.Sort(table, descending, column, associated, type)

Sort the given 'table' basing the sorting on 'columns'. 'table' must be composed by subtables, like records, and indexed with numeric values. 'table' will be directly modified while sorting items.
You can set sorting order setting 'descending' to TRUE or FALSE, 'column' can be a field name or a table width field names we want to use to sort the 'table'.

INPUT

  • table : The table we want to sort
  • descending : To sort in descending order set this flag to TRUE, if you are are sorting the table using multiple column you have to provide a table with one flag for each column.
  • column : Column name or a table of strings with columns names used for the sorting operation.
  • associated : A table holding further tables associated with 'table', the subtable items will follow the sorting order of the master table.
    This argument is optional.
  • type : Sort method, default = combsort Possible sorting algorhythms are:
    → combsort
    → quicksort
    → circlesort (Right now this method must be reviewed) FIXME
    → bubblesort
    → cocktailsort

OUTPUT

  • sorted : The source table after the sorting process

Additional information and usage here.



TB.TrimSpaces(table, recursive)

table = TB.TrimSpaces(table, recursive)

Remove from any string entries in the given 'table' any trailing or leading spaces. The source 'table' will be directly modified.

INPUT

  • table : The table we want to process
  • recursive : Set to TRUE to process the table recursivly

OUTPUT

  • table : Processed source 'table'
hollywoodlibs/tables/misc.txt · Ultima modifica: 2016/10/21 15:47 da admin
CC Attribution-Noncommercial 4.0 International
Driven by DokuWiki Recent changes RSS feed Valid CSS Valid XHTML 1.0