From: Ian Jackson Date: Tue, 9 Jun 2009 13:19:25 +0000 (+0100) Subject: Fix to make example2 work X-Git-Tag: 1.9.2~126 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~yarrgweb/git?p=ypp-sc-tools.web-live.git;a=commitdiff_plain;h=840cdd8228582260d8e67430618e829251a94081 Fix to make example2 work --- diff --git a/pctb/yppsc-decode-marketdata b/pctb/yppsc-decode-marketdata index 787790c..e8f0ef0 100755 --- a/pctb/yppsc-decode-marketdata +++ b/pctb/yppsc-decode-marketdata @@ -45,7 +45,7 @@ sub inmap($\@$) { my ($what,$ary,$ix) = @_; my $got= $ary->[$ix]; return $got if defined $got; - warn "$what $ix ?"; + die "$what $ix ?"; } @@ -67,9 +67,10 @@ unshift @stalls, undef; $|=1; foreach $bs qw(Buy Sell) { - $ncommods= getint("Buy ncommods"); - for ($commodnum=0; $commodnum<$ncommods; $commodnum++) { - $commodix= getint("Buy $commodnum commodix"); + $alloffers_want= getint("Buy ncommods"); + $alloffers_done=0; + while ($alloffers_done < $alloffers_want) { + $commodix= getint("Buy $alloffers_done/$alloffers_want commodix"); $offers= getint("Buy $commodnum offers"); for ($offernum=0; $offernum<$offers; $offernum++) { $stallix= getint("Buy $commodnum $offernum stallix"); @@ -83,6 +84,8 @@ foreach $bs qw(Buy Sell) { printf("\t%d\t%d", $price, $qty) or die $!; if ($bs eq 'Buy') { print "\t\t" or die $!; } print "\n" or die $!; + $alloffers_done++; + die if $alloffers_done > $alloffers_want; } } }