The following script instructions recognize the use of the double-quote syntax to indicate a literal, null-terminated ASCII character string. Although the talk instruction also uses a double-quote syntax, the meaning is different. It implies a talkfile search for phrases that match the string.
strcmp(ctype.src, ctype.src [, type.len ])
The strcmp instruction allows a script to compare two character strings. The ctype.src arguments can be either an address or a literal string. The results of the comparison are returned in r.0. The return value is interpreted as follows:
If r.0 is ... |
Then ... |
=0 |
The strings are equal (exactly the same) |
<0 |
The first string is lexicographically less than the second string |
>0 |
The first string is lexicographically greater than the second string |
If the optional type.len argument is used, the comparison is limited to the number of characters specified by that argument.
Below are two examples of the strcmp instruction. In the first example, the strcmp instruction returns a value less than 0 because abc is lexicographically less than abx. In other words, the string abc appears before the string abx in an alphabetical listing. In the second example, the return value is greater than 0 because abcd appears before abx in an alphabetical listing even though abcd has more characters than abx.
strcmp("abc","abx")
strcmp("abx","abcd")
Note:
Capital letters are always lexicographically less than lowercase letters and numbers are always lexicographically less than letters.
strcpy(ctype.dst, ctype.src [, type.len ])
The strcpy instruction allows a script to copy a source string to a specified destination. The ctype.dst argument specifies the destination address to which the source string (including the terminating null character), specified by the second argument, is copied. The first argument must be an address. The second ctype.src argument specifies the source string to be copied. This argument may be a literal string or the address at which the first character of the string is located.
If the optional type.len argument is used, the strcpy instruction copies, at most, the number of characters specified by that argument. The result may or may not be null terminated, depending on whether a null character was copied before the type.len character limit was reached.
Below are examples of the strcpy instruction. In the first example, the string ch.ORIGINAL is copied to the destination ch.COPY. In the second example, the string Welcome is copied to the destination ch.COPY.
strcpy(ch.COPY,ch.ORIGINAL)
strcpy(ch.COPY,"Welcome")
strlen(ctype.src)
The strlen instruction computes the length of the string specified by the ctype.src argument. The type.src argument can be a literal string or the location of a string. The length of the string (that is, the number of characters in the string) is returned in r.0.