chiark / gitweb /
Fix to make example2 work
[ypp-sc-tools.main.git] / pctb / yppsc-decode-marketdata
index 787790c4a1349bfccd98898481d70975f870bb3c..e8f0ef0b3df447ba306e2ca90871a317f7914936 100755 (executable)
@@ -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;
        }
     }
 }