|
function | table_get_row_idx (rows, row_id) |
| Get the index for a table row identifier. More...
|
|
function | table_get_row (rows, row_id) |
| Get the row for a table row identifier. More...
|
|
function | table_get_col_idx (cols, col_id) |
| Get the index for a table column identifier. More...
|
|
function | table_get_col (cols, col_id) |
| Get the column for a table column identifier. More...
|
|
function | table_get (rows, cols, row_id, col_id) |
| Get the value for a table row and column identifier. More...
|
|
function | table_get_row_cols (rows, cols, col_id) |
| Form a vector from the specified column of each table row. More...
|
|
function | table_get_row_ids (rows) |
| Form a vector of each table row identifier. More...
|
|
function | table_exists (rows, cols, row_id, col_id) |
| Test the existence of a table row and column identifier. More...
|
|
function | table_size (rows, cols) |
| Get the size of a table. More...
|
|
module | table_check (rows, cols, verbose=false) |
| Perform some basic validation/checks on a table. More...
|
|
module | table_dump (rows, cols, rows_sel, cols_sel, number=true) |
| Dump a table to the console. More...
|
|
function | table_copy (rows, cols, rows_sel, cols_sel) |
| Create a copy of select rows and columns of a table. More...
|
|
function | table_sum (rows, cols, rows_sel, cols_sel) |
| Sum select rows and columns of a table. More...
|
|
Data table encoding and lookup.
use <table.scad>;
table_cols =
[
["id", "row identifier"],
["ht", "head type [r|h|s]"],
["td", "thread diameter"],
["tl", "thread length"],
["hd", "head diameter"],
["hl", "head length"],
["nd", "hex nut flat-to-flat width"],
["nl", "hex nut length"]
];
table_rows =
[
[
"m3r08r",
"r", 3.000, 8.00, 5.50, 3.000, 5.50,
convert_length(1.00,
"in")],
[
"m3r14r",
"r", 3.000, 14.00, 5.50, 3.000, 5.50,
convert_length(1.25,
"in")],
[
"m3r16r",
"r", 3.000, 16.00, 5.50, 3.000, 5.50,
convert_length(1.50,
"in")],
[
"m3r20r",
"r", 3.000, 20.00, 5.50, 3.000, 5.50,
convert_length(1.75,
"in")]
];
m3r16r_tl =
table_get( table_rows, table_cols,
"m3r16r",
"tl" );
echo ( "metric 'nl' available" );
echo ( table_ids=table_ids );
echo ( table_cols_tl=table_cols_tl );
tnew =
table_copy( table_rows, table_cols, cols_sel=[
"tl",
"nl"] );
tsum =
table_sum( table_rows, table_cols, cols_sel=[
"tl",
"nl"] );
echo ( m3r16r_tl=m3r16r_tl );
echo ( tnew=tnew );
echo ( tsum=tsum );
ECHO: "[ INFO ] table_check(); begin table check"
ECHO: "[ INFO ] table_check(); row identifier found at column zero."
ECHO: "[ INFO ] table_check(); checking row column counts."
ECHO: "[ INFO ] table_check(); checking for repeat column identifiers."
ECHO: "[ INFO ] table_check(); checking for repeat row identifiers."
ECHO: "[ INFO ] table_check(); table size: 4 rows by 8 columns."
ECHO: "[ INFO ] table_check(); end table check"
ECHO: ""
ECHO: "row: 0"
ECHO: "[m3r08r] [id] (row identifier) = [m3r08r]"
ECHO: "[m3r08r] [ht] (head type [r|h|s]) = [r]"
ECHO: "[m3r08r] [td] (thread diameter) = [3]"
ECHO: "[m3r08r] [tl] (thread length) = [8]"
ECHO: "[m3r08r] [hd] (head diameter) = [5.5]"
ECHO: "[m3r08r] [hl] (head length) = [3]"
ECHO: "[m3r08r] [nd] (hex nut flat-to-flat width) = [5.5]"
ECHO: "[m3r08r] [nl] (hex nut length) = [25.4]"
ECHO: ""
ECHO: "row: 1"
ECHO: "[m3r14r] [id] (row identifier) = [m3r14r]"
ECHO: "[m3r14r] [ht] (head type [r|h|s]) = [r]"
ECHO: "[m3r14r] [td] (thread diameter) = [3]"
ECHO: "[m3r14r] [tl] (thread length) = [14]"
ECHO: "[m3r14r] [hd] (head diameter) = [5.5]"
ECHO: "[m3r14r] [hl] (head length) = [3]"
ECHO: "[m3r14r] [nd] (hex nut flat-to-flat width) = [5.5]"
ECHO: "[m3r14r] [nl] (hex nut length) = [31.75]"
ECHO: ""
ECHO: "row: 2"
ECHO: "[m3r16r] [id] (row identifier) = [m3r16r]"
ECHO: "[m3r16r] [ht] (head type [r|h|s]) = [r]"
ECHO: "[m3r16r] [td] (thread diameter) = [3]"
ECHO: "[m3r16r] [tl] (thread length) = [16]"
ECHO: "[m3r16r] [hd] (head diameter) = [5.5]"
ECHO: "[m3r16r] [hl] (head length) = [3]"
ECHO: "[m3r16r] [nd] (hex nut flat-to-flat width) = [5.5]"
ECHO: "[m3r16r] [nl] (hex nut length) = [38.1]"
ECHO: ""
ECHO: "row: 3"
ECHO: "[m3r20r] [id] (row identifier) = [m3r20r]"
ECHO: "[m3r20r] [ht] (head type [r|h|s]) = [r]"
ECHO: "[m3r20r] [td] (thread diameter) = [3]"
ECHO: "[m3r20r] [tl] (thread length) = [20]"
ECHO: "[m3r20r] [hd] (head diameter) = [5.5]"
ECHO: "[m3r20r] [hl] (head length) = [3]"
ECHO: "[m3r20r] [nd] (hex nut flat-to-flat width) = [5.5]"
ECHO: "[m3r20r] [nl] (hex nut length) = [44.45]"
ECHO: ""
ECHO: "table size: 4 rows by 8 columns."
ECHO: "metric 'nl' available"
ECHO: table_ids = ["m3r08r", "m3r14r", "m3r16r", "m3r20r"]
ECHO: table_cols_tl = [8, 14, 16, 20]
ECHO: m3r16r_tl = 16
ECHO: tnew = [[8, 25.4], [14, 31.75], [16, 38.1], [20, 44.45]]
ECHO: tsum = [58, 139.7]