pspp-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: var_create_internal


From: Ben Pfaff
Subject: Re: var_create_internal
Date: Wed, 07 Jan 2009 15:36:47 -0800
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.2 (gnu/linux)

Jason Stover <address@hidden> writes:

> Question:
>
> /* Create a variable to be used for internal calculations only */
> struct variable *
> var_create_internal (int case_idx)
> {
>   struct variable *v = var_create ("$internal", 0);
>
>   struct vardict_info vdi;
>
>   vdi.dict = NULL;
>   vdi.dict_index = 0;
>   vdi.case_index = case_idx;
>
>   var_set_vardict (v, &vdi);
>
>   return v;
> }
>
> /* Dictionary data stored in variable. */
> struct vardict_info
>   {
>     int dict_index;     /* Dictionary index containing the variable. */
>     int case_index;     /* Index into case of variable data. */
>     struct dictionary *dict;  /* The dictionary containing the variable */
>   };
>
> What is the "case of variable data"? All the examples I see in
> src/language/stats show a value of either 0, 1 or 2.

Wrong operator precedence here I think: it's an index into a
case, and a case contains variable data.

To elaborate:

A case consists of an array of values.  The index into such an
array is called a case_index (or case_idx).  If you create your
own cases with N values per case, then you assign them case_idx
values from 0 to N-1.
-- 
Ben Pfaff 
http://benpfaff.org




reply via email to

[Prev in Thread] Current Thread [Next in Thread]