home *** CD-ROM | disk | FTP | other *** search
/ Computerworld 1996 March / Computerworld_1996-03_cd.bin / idg_cd3 / aplikace / komunika / telixwin / tfw.5 / STRSTUFF.SLT < prev    next >
Text File  |  1995-07-28  |  3KB  |  63 lines

  1. /****************************************************************/
  2. /*                                                              */
  3. /*  Demo of how to use the various string-handling commands in  */
  4. /*  the SALT scripting language.                                */
  5. /*                                                              */
  6. /*                   Copyright 1995 deltaComm Development, Inc. */
  7. /*                                                              */
  8. /****************************************************************/
  9.  
  10. main()
  11. {
  12. str s1[64], s2[64], s3[64], s4[64];       // define 4 strings
  13.  
  14. if (!is_loaded("scrnwip.slc"))            // if this script isn't loaded
  15.   load_scr("scrnwip.slc");                // then load it into memory
  16. call("scrnwip.slc");                      // run this script that clears screen
  17.  
  18. if ((getx()!=10) or (gety()!=10))         // if the cursor isn't already at
  19.   gotoxy(10, 10);                         // position (10,10), then move there
  20.  
  21. gets(s1, 20);                             // Get an input string from the user
  22. s2=s1;                                    // and copy it to another string
  23.  
  24. while ((strcmpi(s1, s2)==0)               // compare the two strings, and force
  25.  or strpos(s1, s2, 0)                     // the user to enter a new, unique
  26.  or strpos(s2, s1, 0))                    // string, asking over and over until
  27.  getsxy(s2, 20, 10, 12, 2);               // the strings do NOT match at all.
  28.  
  29. copychrs(s1, s2, strlen(s1), strlen(s2)); // Copy chars from s2 into s1 (ALL!)
  30. copystr(s1, s2, strlen(s2), 5);           // Copy up to 5 chars from s1 to S2
  31. gotoxy(10, 14);                           // reposition the cursor
  32. pstra(s1, 3);                             // Print s1 in color at cursor pos.
  33. pstraxy(s2, 10, 16, 3);                   // print s2 in color at (10,40)
  34. substr(s1, 2, 3, s3);                     // Copy 3 chars from s1 to s3
  35. subchrs(s2, 2, 3, s4);                    // Copy 3 chars from s2 to s4
  36. s3 = s3 + subchr(s1, 1);                  // Add 1st char of s1 to end of s3
  37.  
  38. itos(stoi(s4), s4);                       // Convert S4 to an int if possible,
  39.                                           // and then convert it right back to
  40.                                           // a string again...
  41.  
  42. strcat(s3, s4);                           // Add s4 to the end of s3
  43. strupper(s2);                             // Convert s2 to upper case
  44.  
  45. if (strchr(s3, 2, "A"))                   // Convert S3 to lower case ONLY if
  46.   strlower(s3);                           //   S3 contains a capital "A"
  47.  
  48. inschrs(s3, s1, 4, (strmaxlen(s1)-strlen(s1)));     // Fill s1 w/chars from S4
  49.  
  50. delchrs(s1, 15, 5);                       // Delete chars from s1, start @ 15th
  51. delay(50);                                // pause 5 seconds to view this chaos
  52. calld("scrnwip.slc");                     // Call the screen wipe from disk
  53. unload_scr("scrnwip.slc");                // Unload screen wipe from memory
  54.  
  55. prints("");                               // Show the results of this carnage
  56.  
  57. prints(s1);
  58. prints(s2);
  59. prints(s3);
  60. prints(s4);
  61.  
  62. }
  63.