RETVAL
-SV *
+void
get_next_case (sfr)
struct sysreader_info *sfr;
-CODE:
+PPCODE:
struct ccase *c;
- if (! (c = casereader_read (sfr->reader)))
- {
- RETVAL = 0;
- }
- else
+ if (c = casereader_read (sfr->reader))
{
int v;
- AV *av_case = (AV *) sv_2mortal ((SV *) newAV());
+ EXTEND (SP, dict_get_var_cnt (sfr->dict));
for (v = 0; v < dict_get_var_cnt (sfr->dict); ++v )
{
const struct variable *var = dict_get_var (sfr->dict, v);
const union value *val = case_data (c, var);
- av_push (av_case, value_to_scalar (val, var));
+ PUSHs (sv_2mortal (value_to_scalar (val, var)));
}
case_unref (c);
- RETVAL = newRV ((SV *) av_case);
}
-OUTPUT:
- RETVAL
-
the data in the system file.
The first call to C<get_next_case> after C<open> has been called retrieves
the first case in the system file. Each subsequent call retrieves the next
-case. If there are no more cases to be read, the function returns undef.
+case. If there are no more cases to be read, the function returns an empty
+list.
If the case contains system missing values, these values are set to the
empty string.
print MYFILE "$_ => $vl->{$_}\n" for keys %$vl;
}
- while (my $c = $sf->get_next_case () )
+ while (my @c = $sf->get_next_case () )
{
for ($v = 0; $v < $dict->get_var_cnt(); $v++)
{
- print MYFILE "val$v: \"@$c[$v]\"\n";
+ print MYFILE "val$v: \"$c[$v]\"\n";
}
print MYFILE "\n";
}
my $output = PSPP::Sysfile->new ("$tempdir/out.sav", $dict);
- while (my $c = $input->get_next_case () )
+ while (my (@c) = $input->get_next_case () )
{
- $output->append_case ($c);
+ $output->append_case (\@c);
}
$output->close ();
my $dict = $sf->get_dict ();
- my $c = $sf->get_next_case ();
+ my (@c) = $sf->get_next_case ();
my $var = $dict->get_var (0);
- my $val = @$c[0];
+ my $val = $c[0];
my $formatted = PSPP::format_value ($val, $var);
my $str = gmtime ($val - PSPP::PERL_EPOCH);
print "Formatted string is \"$formatted\"\n";
my $dict = $sf->get_dict ();
- my $c = $sf->get_next_case ();
+ my (@c) = $sf->get_next_case ();
my $stringvar = $dict->get_var (0);
my $numericvar = $dict->get_var (2);
- my $val = @$c[0];
+ my $val = $c[0];
ok ( !PSPP::value_is_missing ($val, $stringvar), "Missing Value Negative String");
- $val = @$c[2];
+ $val = $c[2];
ok ( !PSPP::value_is_missing ($val, $numericvar), "Missing Value Negative Num");
- $c = $sf->get_next_case ();
- $c = $sf->get_next_case ();
+ @c = $sf->get_next_case ();
+ @c = $sf->get_next_case ();
- $val = @$c[0];
+ $val = $c[0];
ok ( PSPP::value_is_missing ($val, $stringvar), "Missing Value Positive");
- $c = $sf->get_next_case ();
- $val = @$c[2];
+ @c = $sf->get_next_case ();
+ $val = $c[2];
ok ( PSPP::value_is_missing ($val, $numericvar), "Missing Value Positive SYS");
- $c = $sf->get_next_case ();
- $val = @$c[2];
+ @c = $sf->get_next_case ();
+ $val = $c[2];
ok ( PSPP::value_is_missing ($val, $numericvar), "Missing Value Positive Num");
}