home *** CD-ROM | disk | FTP | other *** search
- /****************************************************************/
- /* */
- /* Demo of how to use the various string-handling commands in */
- /* the SALT scripting language. */
- /* */
- /* Copyright 1995 deltaComm Development, Inc. */
- /* */
- /****************************************************************/
-
- main()
- {
- str s1[64], s2[64], s3[64], s4[64]; // define 4 strings
-
- if (!is_loaded("scrnwip.slc")) // if this script isn't loaded
- load_scr("scrnwip.slc"); // then load it into memory
- call("scrnwip.slc"); // run this script that clears screen
-
- if ((getx()!=10) or (gety()!=10)) // if the cursor isn't already at
- gotoxy(10, 10); // position (10,10), then move there
-
- gets(s1, 20); // Get an input string from the user
- s2=s1; // and copy it to another string
-
- while ((strcmpi(s1, s2)==0) // compare the two strings, and force
- or strpos(s1, s2, 0) // the user to enter a new, unique
- or strpos(s2, s1, 0)) // string, asking over and over until
- getsxy(s2, 20, 10, 12, 2); // the strings do NOT match at all.
-
- copychrs(s1, s2, strlen(s1), strlen(s2)); // Copy chars from s2 into s1 (ALL!)
- copystr(s1, s2, strlen(s2), 5); // Copy up to 5 chars from s1 to S2
- gotoxy(10, 14); // reposition the cursor
- pstra(s1, 3); // Print s1 in color at cursor pos.
- pstraxy(s2, 10, 16, 3); // print s2 in color at (10,40)
- substr(s1, 2, 3, s3); // Copy 3 chars from s1 to s3
- subchrs(s2, 2, 3, s4); // Copy 3 chars from s2 to s4
- s3 = s3 + subchr(s1, 1); // Add 1st char of s1 to end of s3
-
- itos(stoi(s4), s4); // Convert S4 to an int if possible,
- // and then convert it right back to
- // a string again...
-
- strcat(s3, s4); // Add s4 to the end of s3
- strupper(s2); // Convert s2 to upper case
-
- if (strchr(s3, 2, "A")) // Convert S3 to lower case ONLY if
- strlower(s3); // S3 contains a capital "A"
-
- inschrs(s3, s1, 4, (strmaxlen(s1)-strlen(s1))); // Fill s1 w/chars from S4
-
- delchrs(s1, 15, 5); // Delete chars from s1, start @ 15th
- delay(50); // pause 5 seconds to view this chaos
- calld("scrnwip.slc"); // Call the screen wipe from disk
- unload_scr("scrnwip.slc"); // Unload screen wipe from memory
-
- prints(""); // Show the results of this carnage
-
- prints(s1);
- prints(s2);
- prints(s3);
- prints(s4);
-
- }
-