-/* Cases are read from proc_source,
- pass through permanent_trns_chain (which transforms them into
- the format described by permanent_dict),
- are written to proc_sink,
- pass through temporary_trns_chain (which transforms them into
- the format described by default_dict),
- and are finally passed to the procedure. */
-static struct case_source *proc_source;
-static struct trns_chain *permanent_trns_chain;
-static struct dictionary *permanent_dict;
-static struct case_sink *proc_sink;
-static struct trns_chain *temporary_trns_chain;
-struct dictionary *default_dict;
-
-/* The transformation chain that the next transformation will be
- added to. */
-static struct trns_chain *cur_trns_chain;
-
-/* The compactor used to compact a case, if necessary;
- otherwise a null pointer. */
-static struct dict_compactor *compactor;
-
-/* Time at which proc was last invoked. */
-static time_t last_proc_invocation;
-
-/* Lag queue. */
-int n_lag; /* Number of cases to lag. */
-static int lag_count; /* Number of cases in lag_queue so far. */
-static int lag_head; /* Index where next case will be added. */
-static struct ccase *lag_queue; /* Array of n_lag ccase * elements. */
-
-static void add_case_limit_trns (void);
-static void add_filter_trns (void);
-
-static bool internal_procedure (bool (*case_func) (const struct ccase *,
- void *),
+struct dataset {
+ /* Cases are read from proc_source,
+ pass through permanent_trns_chain (which transforms them into
+ the format described by permanent_dict),
+ are written to proc_sink,
+ pass through temporary_trns_chain (which transforms them into
+ the format described by dict),
+ and are finally passed to the procedure. */
+ struct case_source *proc_source;
+ struct trns_chain *permanent_trns_chain;
+ struct dictionary *permanent_dict;
+ struct case_sink *proc_sink;
+ struct trns_chain *temporary_trns_chain;
+ struct dictionary *dict;
+
+ /* The transformation chain that the next transformation will be
+ added to. */
+ struct trns_chain *cur_trns_chain;
+
+ /* The compactor used to compact a case, if necessary;
+ otherwise a null pointer. */
+ struct dict_compactor *compactor;
+
+ /* Time at which proc was last invoked. */
+ time_t last_proc_invocation;
+
+ /* Lag queue. */
+ int n_lag; /* Number of cases to lag. */
+ int lag_count; /* Number of cases in lag_queue so far. */
+ int lag_head; /* Index where next case will be added. */
+ struct ccase *lag_queue; /* Array of n_lag ccase * elements. */
+
+}; /* struct dataset */
+
+
+struct dataset *current_dataset;
+
+static void add_case_limit_trns (struct dataset *ds);
+static void add_filter_trns (struct dataset *ds);
+
+static bool internal_procedure (struct dataset *ds, case_func_t,