[ic] Strange behavior with [value-extended] tag

Kevin Walsh kevin at cursor.biz
Tue Aug 29 00:40:51 EDT 2006


Marty Tennison <marty at sediva.com> wrote:
> Kevin Walsh wrote:
> > Your variable stacking is incorrect.  Try this instead:
> > 
> > ActionMap best-sellers <<EOA
> > sub {
> >     $CGI->{mv_todo} = 'search';
> >     $CGI->{mv_searchtype} = 'db';
> >     $CGI->{mv_nextpage} = 'results';
> >     $CGI->{mv_max_matches} = '99';
> >     $CGI->{mv_matchlimit} = '8';
> >     $CGI->{mv_coordinate} = 1;
> >     $CGI->{mv_sort_field} = 'sales_rank';
> >     $CGI->{mv_sort_option} = 'n';
> >     $CGI->{mv_search_file} = 'products';
> >     $CGI->{mv_search_field} = "sales_rank\0inactive";
> >     $CGI->{mv_searchspec} = "0\01";
> >     $CGI->{mv_column_op} = ">\0!=";
> >     $CGI->{mv_numeric} = "1\01";
> >     $Tag->update('process');
> >     return 1;
> > }
> > EOA
> > 
> That was it.  It took me a while to get it to work.  It seems that if a 
> value is a 1 you need to separate the value and the delimiter with a 
> space. ie: $CGI->{mv_numeric} = "1\0 1";  But once I did that, all was well.
>
That's my mistake in the example.  Oops.  "\01" is octal 1 (i.e. an
ASCII SOH character), instead of "an ASCII NUL followed by 1".  The
space may or may not mess things up.  Judging by your success report,
it seems that it doesn't, but perhaps the following would be safer:

    $CGI->{mv_numeric} = "0\0" . '1';

or (not as efficient):

    $CGI->{mv_numeric} = join("\0",'0','1');

> 
> I'm wondering... Is the \0 a PERL thing or an Interchange thing?  I 
> searched my perl documentation for anything relating to \0 as a 
> delimiter but found nothing so I am assuming it is unique to
> interchange? 
> 
"\0" is an ASCII NUL character in various languages, including Perl.
Interchange "Stacks" identically-named form values into a single
%$CGI::values hash key by separating the values from one another with
a single ASCII NUL (\0) character.

Interchange also pushes each of the values into an arrayref attached
to the %$CGI::values_array hash.

The Interchange search engine uses %$CGI::values instead of
%$CGI::values_array, which is why you need to use a scalar with
NUL-separated values instead of an array.  The [value-extended] tag
makes use of the arrayref attached to the named %$CGI::values_array
hash key.

I bet that's all as clear as mud. :-)

-- 
   _/   _/  _/_/_/_/  _/    _/  _/_/_/  _/    _/
  _/_/_/   _/_/      _/    _/    _/    _/_/  _/   K e v i n   W a l s h
 _/ _/    _/          _/ _/     _/    _/  _/_/    kevin at cursor.biz
_/   _/  _/_/_/_/      _/    _/_/_/  _/    _/


More information about the interchange-users mailing list