CAPL9

55)  strlen

Syntax            long strlen(string s);
Function         Determine the length of string s.
Parameters     String to find length of.
Returns          Length of string.
Example
...
length = strlen(“CANalyzer”);
...
Result: length = 9
See also strncat, strncpy, strncmp

56) strncat

Syntax              strncat(string dest, string src, long len);
Function         This function appends src to dest. The function ensures that there is a terminating ‘\0’ in the dest string. Thus, a maximum of len- 1 characters are copied.
Parameters     dest = Original string (that this function adds to).
                        src = String to append to dest.
                        len = the maximum length of the resulting string.
Returns          None. The resulting string is contained in dest.
Example
...
string s1 = {“Vector”};
string s2 = {“CANalyzer”};
strncat(s1,s2,16);
...
Result: s1 = “VectorCANalyzer”
See also           strlen, strncpy, strncmp

57)  strncmp

Syntax             long strncmp(string s1, string s2, long len);
Function         This function compares s1 with s2 for a maximum of len characters.
Parameters     s1 and s2 - strings to compare len - number of characters to compare. Can usually be set to the length of the longest string.
Returns -        1 if s1 < s2
                        0 if s1 = s2
                        1 if s2 > s1
Example
...
if(strncmp(s1, s2, strlen(s1))
write(“not equal”);
else
write(“equal”);
...
See also           strlen, strncat, strncpy


58) strncpy

Syntax                strncpy(string dest, string src, long len);
Function         This function copies src to dest. len indicates the maximum length of src and dest. The function ensures that there is a terminating ‘\0’. Thus, a maximum of len-1 cahracters are copied.
Parameters     dest - String to copy src to.
                        src - Original string.
                        len - Number of characters to copy + 1 (usually the length of src plus 1).
Returns          None. The string dest is updated.
Example
...
string s1 = {“Vector”};
string s2 = {“CANalyzer”};
strncpy(s1, s2, strlen(s2) + 1);
...
Result: s1 = “CANalyzer”
See also           strlen, strncat, strncmp

59) swapDWord

Syntax               dword swapDWord(dword x);
Function         Swaps bytes of parameters. CAPL arithmetic follows the little-endian-format (Intel). The swap-functions serve for swapping bytes for the transition to and from the big-endian-format (Motorola).
Parameters     Value whose bytes are to be swapped.
Returns          Value with swapped bytes.
See also           swapInt, swapLong, swapWord


60) swapInt

Syntax               int swapInt(int x);
Function         Swaps bytes of parameters. CAPL arithmetic follows the little-endian-format (Intel). The swap-functions serve for swapping bytes for the transition to and from the big-endian- format (Motorola).
Parameters     Value whose bytes are to be swapped.
Returns          Value with swapped bytes.
See also           swapDword , swapLong , swapWord

61) swapLong

Syntax              long swapLong(long x);
Function         Swaps bytes of parameters. CAPL arithmetic follows the little-endian-format (Intel). The swap-functions serve for swapping bytes for the transition to and from the big-endian-  format (Motorola).
Parameters     Value whose bytes are to be swapped.
Returns          Value with swapped bytes.
See also           swapDword, swapInt, swapWord


No comments:

Post a Comment