[ic] acces global inside Common Adust

Murray Gibbins interchange-users@lists.akopia.com
Tue May 22 05:28:00 2001


Murray Gibbins wrote:
> 
> in a comon Adjust line how do I call a Global funcion. I.e. I has a global
> function defined in interchange.cfg call do_stuff();
> 
> and I want to do some thing like
> 
> CommonAdjust    &do_stuff()
> 

yep I've found this to be almost imposible so I've set my Common Adjust line to
this....

CommonAdjust	[sw_look_up]

and added this to /usr/lib/interchange/lib/Vend/Data.pm at the top of 
chain_cost....

sub chain_cost {
	my ($item, $raw) = @_;
	
	#new stuff
	if($raw =~ /\[sw_look_up\]/){
	    use DBI;
	    my $dbi = DBI->connect("dbi:Pg:dbname=minivend","interch","");
	    my $str = "SELECT ca_string from ca_scotweb where code = 'a_shop'";
	    my $sth = $dbi->prepare($str);
	    my $rv = $sth->execute;
	    my ($val) = $sth->fetchrow_array;
	    $sth->finish;
	    $dbi->disconnect;
	    $raw = $val;

	}
	#end of new stuff.
	#::logError("item $item; and raw $raw");
	return $raw if $raw =~ /^[\d.]*$/;
	my $price;
	my $final = 0;
	my $its = 0;
	my @p;
	$raw =~ s/^\s+//;
	$raw =~ s/\s+$//;
	if($raw =~ /^\[\B/ and $raw =~ /\]$/) {

I'm sure there are more effieent ways , may be some hooks into the db interch
code. I'll look into it later.

-- 
  ____
  \__/    Murray Gibbins             murray@scotweb.ltd.uk
  /  \    Programmer
_ \__/ _  ================================================
\\ || //  Scotweb Limited,             info@scotweb.ltd.uk
 \\||//   13a Albert Terrace,    http://www.scotweb.ltd.uk
  \||/    Edinburgh EH10 5EA   Tel: +44 (0)  131 270 82 33
   ||     Scotland. Europe.    Fax: +44 (0) 7020  93 49 04