Description of the string functions

You will find a general example for the use of Stringfunctions here.

The script language contains a sequence of functions on string processing. These functions work always on char* strings. Here is a summary of all string functions:
Name Description
⇨ memory
alloc Reserve memory
release Release memory
⇨ Arithmetical operations
strlen Length
strcmp Content comparison
strncmp Length limited content comparison
itoa Integer as character strings
val haracter strings as integerl
⇨ Build
strcpy Copy
strncpy Copy with limitation
strcat Append
strncat Append with limitation
strsubstring Part string
strinsert Insert text parts
strcut Cut out text parts
strreplace Replace text parts
⇨ Formatting
format, sprintf Create formatted string
⇨ Content
strchr Substring starting with character
strchrpos Position of character
strstr Search substring
strstrpos Position of substring
⇨ Tokens
string::get_token_count Number of tokens
string::get_token Get nth token
⇨ Convert
strtrim Trim
strupper Upper case letters
strlower Lower case letters
strreverse reverse
strhash Unique number allocation
⇨ Anzeige
showmessage Show formatted string
showerror Error message
printf, display Message in the console

The example shows the use of the string functions.

int main ()
{
    char		str[512];
    char		str1[512];
    char		str2[512];
    int 		i;
strcpy (str, "Matthias"); strcpy (str1, "Matthias");
// subchar, substring showmessage ("t im Matthias : <%s>, pos=%d",   strchr (str, 't'),   strchrpos (str, 't'));
showmessage ("hi im Matthias : <%s>, pos=%d",   strstr (str, "hi"),   strstrpos (str, "hi"));
showmessage ("tt -> t : %s -> %s",   str1,   strreplace (str, "tt", "t"));
showmessage ("a -> aAa : %s -> %s",   str1,   strreplace (str, "a", "aAa"));
showmessage ("Ma-%s-as",   strsubstring ("Matthias", 2, 4));
showmessage ("Ma-%s",   strsubstring ("Matthias", 2));
// trim, lower, upper strcpy (str, " Übelmüdigkeit (Morbus Döhler) \t \r");
strcpy (str1, str); showmessage ("trim <%s>", strtrim (str1));
strcpy (str1, str); showmessage ("upper <%s>", strupper (str1));
strcpy (str1, str); showmessage ("lower <%s>", strlower (str1));
// cut, insert strcpy (str, "Matthias"); showmessage ("cut <%s>", strcut (str, 2, 4)); showmessage ("cut <%s>", strcut (str, 2));
strcpy (str, "Maas"); showmessage ("insert <%s>", strinsert (str, 2, "tthi"));
// strncpy, strncat *str = 0; showmessage ("strncpy <%s>", strncpy (str, "Seidelsky", 6)); showmessage ("strncpy <%s>", strncpy (str, "Matthias", 16)); showmessage ("strncat <%s>", strncat (str, " Seidelsky", 7));
// reverse showmessage ("reverse <%s>", strreverse (str));
strcpy (str, "reverse"); showmessage ("reverse %s", strreverse (str));
return 0; }

Since

Available
priint:comet InDesign® Plug-Ins, comet_pdf

Alphabetic index HTML hierarchy of classes or Java