X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Flanguage%2Fdictionary%2Fweight.c;fp=src%2Flanguage%2Fdictionary%2Fweight.c;h=b6d63c972c33348861635fc27ceedeb2a3f257f7;hb=dcf9b154cbcaa35c3d8459a201b77eec8bcb30bd;hp=0000000000000000000000000000000000000000;hpb=c514f5f05cc4f060959c392a0eb3e9f046e919d2;p=pspp-builds.git diff --git a/src/language/dictionary/weight.c b/src/language/dictionary/weight.c new file mode 100644 index 00000000..b6d63c97 --- /dev/null +++ b/src/language/dictionary/weight.c @@ -0,0 +1,61 @@ +/* PSPP - computes sample statistics. + Copyright (C) 1997-9, 2000 Free Software Foundation, Inc. + Written by Ben Pfaff . + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. */ + +#include +#include "message.h" +#include +#include "command.h" +#include "dictionary.h" +#include "message.h" +#include "lexer.h" +#include "str.h" +#include "variable.h" + +#include "gettext.h" +#define _(msgid) gettext (msgid) + +int +cmd_weight (void) +{ + if (lex_match_id ("OFF")) + dict_set_weight (default_dict, NULL); + else + { + struct variable *v; + + lex_match (T_BY); + v = parse_variable (); + if (!v) + return CMD_CASCADING_FAILURE; + if (v->type == ALPHA) + { + msg (SE, _("The weighting variable must be numeric.")); + return CMD_CASCADING_FAILURE; + } + if (dict_class_from_id (v->name) == DC_SCRATCH) + { + msg (SE, _("The weighting variable may not be scratch.")); + return CMD_CASCADING_FAILURE; + } + + dict_set_weight (default_dict, v); + } + + return lex_end_of_command (); +}