This subcommand reports the number of cases in the active dataset.
[MXERRS]
[MXLOOPS]
[MXWARNS]
+ [N]
[SCOMPRESSION]
[TEMPDIR]
[UNDEFINED]
Shows the current working directory.
@item @subcmd{ENVIRONMENT}
Shows the operating system details.
+@item @subcmd{N}
+Reports the number of cases in the active dataset. The reported number is not
+weighted. If no dataset is defined, then @samp{Unknown} will be reported.
@item @subcmd{TEMPDIR}
Shows the path of the directory where temporary files will be stored.
@item @subcmd{VERSION}
#include <time.h>
#include <unistd.h>
+#include "gl/vasnprintf.h"
+
+#include "data/casereader.h"
#include "data/data-in.h"
#include "data/data-out.h"
#include "data/dataset.h"
return strdup (host_system);
}
+static char *
+show_n (const struct dataset *ds)
+{
+ casenumber n;
+ size_t l;
+
+ const struct casereader *reader = dataset_source (ds);
+
+ if (reader == NULL)
+ return strdup (_("Unknown"));
+
+ n = casereader_count_cases (reader);
+
+ return asnprintf (NULL, &l, "%ld", n);
+}
+
+
struct show_sbc
{
const char *name;
{"MXERRS", show_mxerrs},
{"MXLOOPS", show_mxloops},
{"MXWARNS", show_mxwarns},
+ {"N", show_n},
{"PRINTBACk", show_printback},
{"RESULTS", show_results},
{"RIB", show_rib},
tests/language/utilities/insert.at \
tests/language/utilities/permissions.at \
tests/language/utilities/set.at \
+ tests/language/utilities/show.at \
tests/language/utilities/title.at \
tests/language/xforms/compute.at \
tests/language/xforms/count.at \
--- /dev/null
+AT_BANNER([SHOW])
+
+AT_SETUP([SHOW N])
+
+AT_DATA([show.sps], [dnl
+DATA LIST LIST NOTABLE /x.
+BEGIN DATA.
+1
+2
+3
+END DATA.
+
+SHOW N.
+])
+
+AT_CHECK([pspp -O format=csv show.sps], [0], [dnl
+show.sps:8: note: SHOW: N is 3.
+])
+
+AT_CLEANUP
+
+
+AT_SETUP([SHOW N empty])
+
+AT_DATA([shown-empty.sps], [dnl
+SHOW N.
+])
+
+AT_CHECK([pspp -O format=csv shown-empty.sps], [0], [dnl
+shown-empty.sps:1: note: SHOW: N is Unknown.
+])
+
+AT_CLEANUP
+