home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Source Code / Add-Ons / BBEdit / MacBob 1.0ß2 / Examples / HelloGoodbye.bob < prev    next >
Encoding:
Text File  |  1995-12-07  |  394 b   |  25 lines  |  [TEXT/R*ch]

  1. main ()
  2. {
  3.     hello = "hello";
  4.     goodbye = "goodbye";
  5.     for (i = 0; i < 3000; ++i) {
  6.     x = hello + ' ' + goodbye;
  7.     hello = substr(x, 0, 5);
  8.     goodbye = substr(x, 6, 7);
  9.     }
  10.     print(x,"\n");
  11. }
  12.  
  13.  
  14. substr (s, f, l ; len, r, i)
  15. {
  16.     len = sizeof(s) - f;
  17.     if (l > len)
  18.     l = len;
  19.     if (l <= 0) return "";
  20.     r = newstring(l);
  21.     for (i = 0; --l >= 0; )
  22.     r[i++] = s[f++];
  23.     return r;
  24. }
  25.