Inform - Support - Source

Back to List

Inventory
Complete

Backward
Forward

Plain
Coloured
Gaudy

This code
in plain text

Browsing verblibm.h

WriteListR (lines 277-535)

0277  [ WriteListR o depth stack_pointer  classes_p sizes_p i j k k2 l m n q senc mr;
0278      if (depth > 0 && o == child(parent(o))) {
0279          SortOutList(o);
0280          o = child(parent(o));
0281      }
0282      for (::) {
0283          if (o == 0) rfalse;
0284          if (c_style & WORKFLAG_BIT ~= 0 && depth==0 && o hasnt workflag) {
0285              o = sibling(o);
0286              continue;
0287          }
0288          if (c_style & CONCEAL_BIT ~= 0 && (o has concealed || o has scenery)) {
0289              o = sibling(o);
0290              continue;
0291          }
0292          break;
0293      }
0294      classes_p = match_classes + stack_pointer;
0295      sizes_p   = match_list + stack_pointer;
0296   
0297      for (i=o,j=0 : i~=0 && (j+stack_pointer)<128 : i=NextEntry(i,depth),j++) {
0298          classes_p->j = 0;
0299          if (i.plural ~= 0) k++;
0300      }
0301   
0302      if (c_style & ISARE_BIT ~= 0) {
0303          if (j == 1 && o hasnt pluralname) print (string) IS__TX;
0304          else                              print (string) ARE__TX;
0305          if (c_style & NEWLINE_BIT ~= 0)   print ":^";
0306          else                              print (char) ' ';
0307          c_style = c_style - ISARE_BIT;
0308      }
0309   
0310      stack_pointer = stack_pointer+j+1;
0311   
0312      if (k < 2) jump EconomyVersion;   ! It takes two to plural
0313      n = 1;
0314      for (i=o,k=0 : k<j : i=NextEntry(i,depth),k++)
0315          if (classes_p->k == 0) {
0316              classes_p->k = n; sizes_p->n = 1;
0317              for (l=NextEntry(i,depth),m=k+1 : l~=0 && m<j : l=NextEntry(l,depth),m++)
0318                  if (classes_p->m == 0 && i.plural ~= 0 && l.plural ~= 0) {
0319                      if (ListEqual(i, l) == 1) {
0320                          sizes_p->n = sizes_p->n + 1;
0321                          classes_p->m = n;
0322                      }
0323                  }
0324              n++;
0325          }
0326      n--;
0327   
0328      for (i=1,j=o,k=0 : i<=n : i++,senc++) {
0329          while (((classes_p->k) ~= i) && ((classes_p->k) ~= -i)) {
0330              k++; j=NextEntry(j, depth);
0331          }
0332          m = sizes_p->i;
0333          if (j == 0) mr = 0;
0334          else {
0335              if (j.list_together ~= 0 or lt_value && ZRegion(j.list_together) == 2 or 3 &&
0336                  j.list_together == mr) senc--;
0337              mr = j.list_together;
0338          }
0339      }
0340      senc--;
0341   
0342      for (i=1,j=o,k=0,mr=0 : senc>=0 : i++,senc--) {
0343          while (((classes_p->k) ~= i) && ((classes_p->k) ~= -i)) {
0344              k++; j=NextEntry(j, depth);
0345          }
0346          if (j.list_together ~= 0 or lt_value) {
0347              if (j.list_together == mr) {
0348                  senc++;
0349                  jump Omit_FL2;
0350              }
0351              k2 = NextEntry(j, depth);
0352              if (k2 == 0 || k2.list_together ~= j.list_together) jump Omit_WL2;
0353              k2 = ZRegion(j.list_together);
0354              if (k2 == 2 or 3) {
0355                  q = j; listing_size = 1; l = k; m = i;
0356                  while (m < n && q.list_together == j.list_together) {
0357                      m++;
0358                      while (((classes_p->l) ~= m) && ((classes_p->l) ~= -m)) {
0359                          l++; q = NextEntry(q, depth);
0360                       }
0361                      if (q.list_together == j.list_together) listing_size++;
0362                  }
0363                  ! print " [", listing_size, "] ";
0364                  if (listing_size == 1) jump Omit_WL2;
0365                  if (c_style & INDENT_BIT ~= 0) Print__Spaces(2*(depth+wlf_indent));
0366                  if (k2 == 3) {
0367                      q = 0;
0368                      for (l=0 : l<listing_size : l++) q = q+sizes_p->(l+i);
0369                      EnglishNumber(q); print " ";
0370                      print (string) j.list_together;
0371                      if (c_style & ENGLISH_BIT ~= 0) print " (";
0372                      if (c_style & INDENT_BIT ~= 0)  print ":^";
0373                  }
0374                  q = c_style;
0375                  if (k2 ~= 3) {
0376                      inventory_stage = 1;
0377                      parser_one = j; parser_two = depth+wlf_indent;
0378                      if (RunRoutines(j, list_together) == 1) jump Omit__Sublist2;
0379                  }
0380   
0381                  #Ifdef TARGET_ZCODE;
0382                  @push lt_value; @push listing_together; @push listing_size;
0383                  #Ifnot; ! TARGET_GLULX;
0384                  @copy lt_value sp; @copy listing_together sp; @copy listing_size sp;
0385                  #Endif; ! TARGET_;
0386   
0387                  lt_value = j.list_together; listing_together = j; wlf_indent++;
0388                  WriteListR(j, depth, stack_pointer); wlf_indent--;
0389   
0390                  #Ifdef TARGET_ZCODE;
0391                  @pull listing_size; @pull listing_together; @pull lt_value;
0392                  #Ifnot; ! TARGET_GLULX;
0393                  @copy sp listing_size;
0394                  @copy sp listing_together;
0395                  @copy sp lt_value;
0396                  #Endif; ! TARGET_;
0397   
0398                  if (k2 == 3) {
0399                      if (q & ENGLISH_BIT ~= 0) print ")";
0400                  }
0401                  else {
0402                      inventory_stage = 2;
0403                      parser_one = j; parser_two = depth+wlf_indent;
0404                      RunRoutines(j, list_together);
0405                  }
0406   
0407                .Omit__Sublist2;
0408   
0409                  if (q & NEWLINE_BIT ~= 0 && c_style & NEWLINE_BIT == 0) new_line;
0410                  c_style = q;
0411                  mr = j.list_together;
0412                  jump Omit_EL2;
0413              }
0414          }
0415   
0416        .Omit_WL2;
0417   
0418          if (WriteBeforeEntry(j, depth, -senc) == 1) jump Omit_FL2;
0419          if (sizes_p->i == 1) {
0420              if (c_style & NOARTICLE_BIT ~= 0) print (name) j;
0421              else {
0422                  if (c_style & DEFART_BIT ~= 0) print (the) j; else print (a) j;
0423              }
0424          }
0425          else {
0426              if (c_style & DEFART_BIT ~= 0) PrefaceByArticle(j, 1, sizes_p->i);
0427              print (number) sizes_p->i, " ";
0428              PrintOrRun(j, plural, 1);
0429          }
0430          if (sizes_p->i > 1 && j hasnt pluralname) {
0431              give j pluralname;
0432              WriteAfterEntry(j, depth, stack_pointer);
0433              give j ~pluralname;
0434          }
0435          else WriteAfterEntry(j,depth,stack_pointer);
0436        .Omit_EL2;
0437   
0438          if (c_style & ENGLISH_BIT ~= 0) {
0439              if (senc == 1) print (string) AND__TX;
0440              if (senc > 1) print (string) COMMA__TX;
0441          }
0442       .Omit_FL2;
0443      }
0444      rtrue;
0445   
0446    .EconomyVersion;
0447   
0448      n = j;
0449      for (i=1,j=o : i<=n : j=NextEntry(j,depth),i++,senc++) {
0450          if (j.list_together ~= 0 or lt_value && ZRegion(j.list_together) == 2 or 3 &&
0451              j.list_together==mr) senc--;
0452          mr = j.list_together;
0453      }
0454   
0455      for (i=1,j=o,mr=0 : i<=senc : j=NextEntry(j,depth),i++) {
0456          if (j.list_together ~= 0 or lt_value) {
0457              if (j.list_together == mr) {
0458                  i--;
0459                  jump Omit_FL;
0460              }
0461              k = NextEntry(j, depth);
0462              if (k == 0 || k.list_together ~= j.list_together) jump Omit_WL;
0463              k = ZRegion(j.list_together);
0464              if (k == 2 or 3) {
0465                  if (c_style & INDENT_BIT ~= 0) Print__Spaces(2*(depth+wlf_indent));
0466                  if (k == 3) {
0467                      q = j; l = 0;
0468                      do {
0469                          q = NextEntry(q, depth); l++;
0470                      } until (q == 0 || q.list_together ~= j.list_together);
0471                      EnglishNumber(l); print " ";
0472                      print (string) j.list_together;
0473                      if (c_style & ENGLISH_BIT ~= 0) print " (";
0474                      if (c_style & INDENT_BIT ~= 0) print ":^";
0475                  }
0476                  q = c_style;
0477                  if (k ~= 3) {
0478                      inventory_stage = 1;
0479                      parser_one = j; parser_two = depth+wlf_indent;
0480                      if (RunRoutines(j, list_together) == 1) jump Omit__Sublist;
0481                  }
0482   
0483                  #Ifdef TARGET_ZCODE;
0484                  @push lt_value; @push listing_together; @push listing_size;
0485                  #Ifnot; ! TARGET_GLULX;
0486                  @copy lt_value sp; @copy listing_together sp; @copy listing_size sp;
0487                  #Endif; ! TARGET_;
0488   
0489                  lt_value = j.list_together; listing_together = j; wlf_indent++;
0490                  WriteListR(j, depth, stack_pointer); wlf_indent--;
0491   
0492                  #Ifdef TARGET_ZCODE;
0493                  @pull listing_size; @pull listing_together; @pull lt_value;
0494                  #Ifnot; ! TARGET_GLULX;
0495                  @copy sp listing_size; @copy sp listing_together; @copy sp lt_value;
0496                  #Endif; ! TARGET_;
0497   
0498                  if (k == 3) {
0499                      if (q & ENGLISH_BIT ~= 0) print ")";
0500                  }
0501                  else {
0502                      inventory_stage = 2;
0503                      parser_one = j; parser_two = depth+wlf_indent;
0504                      RunRoutines(j, list_together);
0505                  }
0506   
0507                .Omit__Sublist;
0508   
0509                  if (q & NEWLINE_BIT ~= 0 && c_style & NEWLINE_BIT == 0) new_line;
0510                  c_style = q;
0511                  mr = j.list_together;
0512                  jump Omit_EL;
0513              }
0514          }
0515   
0516        .Omit_WL;
0517   
0518          if (WriteBeforeEntry(j, depth, i-senc) == 1) jump Omit_FL;
0519          if (c_style & NOARTICLE_BIT ~= 0) print (name) j;
0520          else {
0521              if (c_style & DEFART_BIT ~= 0) print (the) j; else print (a) j;
0522          }
0523          WriteAfterEntry(j, depth, stack_pointer);
0524   
0525        .Omit_EL;
0526   
0527          if (c_style & ENGLISH_BIT ~= 0) {
0528              if (i == senc-1) print (string) AND__TX;
0529              if (i < senc-1) print (string) COMMA__TX;
0530          }
0531   
0532    .Omit_FL;
0533   
0534      }
0535  ]; ! end of WriteListR


Last updated 27 February 2004. The librarian in charge of this page is Graham Nelson (graham@gnelson.demon.co.uk) assisted by C Knight. Please email any comments, suggestions or corrections to cedenqs@inform-fiction.org.