xdivn


The xdivn function divides a general lua table into a number. The table may contain non-numeric values, named keys, and sub-tables. Only numeric values found in the table are used in the calculation. To divide the table by a number, use divn. The related div function a 1-dimensional array or CImage by a number. Since an array is a specific type of table that contains only numbers or sub-tables, this function can also be used for arrays.

Syntax

new_table = xdivn( tbl, value )

bullet.gif    where tbl is a general lua table.

bullet.gif    value is a number.

bullet.gif    new_table is returned as a new table. If the table value is zero, tbl is replaced with 0.0.

Examples

The following script divides a 1-dimensional array into 3200.5.

t = xdivn( array, 3200.5 )

-- divide the array by the value

  

The next script divides the numeric members of a more complex table into 3200.5. Only the 4 numeric values are divided.

tbl = { 15, a=5.5, z={"c", 20}, -12 }

 

t = xdivn( tbl, 3200.5 )

-- divide the table by the value

Related Topics

Table and Array Functions, divn, muln, div


Mira Pro x64 Script User's Guide, Copyright Ⓒ 2024 Mirametrics, Inc. All Rights Reserved.