diff --git a/CHANGES.txt b/CHANGES.txt index 35ee7935..dd8f74ff 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -13,6 +13,7 @@ Version 0.4.0 (in progress) * Add idempotent one-arg constructor forms for string, datetime, categorical. (But not table.) * Add `istable`, `istimetable`, and `istabular` functions. * Add `NaS`, `NaC`, and `todatetime` functions. +* Have `fieldnames (table)` expose variable and dimension names and Properties, instead of the internal implementation properties. * Rename `+tablicious` package to `+tblish`; merge `+octave` package into `+tblish`. * Move `+table_examples` package to `+tblish/+examples`. * Make internal-use properties on the main classes Access = private, now that the code is a little more mature. diff --git a/inst/table.m b/inst/table.m index 4b847d37..820377ad 100644 --- a/inst/table.m +++ b/inst/table.m @@ -446,6 +446,26 @@ function prettyprint (this) # Structural stuff + function out = fieldnames (this) + # fieldnames is customize to expose the variable and dimension names as fields, and + # hide the real fields inside "Properties". + out = [this.VariableNames'; {'Properties'}; this.DimensionNames']; + endfunction + + function out = properties (this) + # properties, like fieldnames, is customize to expose the variable and dimension + # names as fields, and hide the real fields inside "Properties". + out = fieldnames (this); + if nargout == 0 + fprintf('Properties for class %s:\n\n', class (this)); + for i = 1:numel (out) + fprintf(' %s\n', out{i}); + endfor + fprintf('\n'); + clear out + endif + endfunction + ## -*- texinfo -*- ## @node table.varnames ## @deftypefn {Method} {@var{out} =} varnames (@var{obj})