Chapter Contents

Previous

Next
CALL DMYTECKS

CALL DMYTECKS



Calculates the checksum (exclusive OR) of all the characters in a DataMyte packet, excluding the checksum itself

Window specifics all


Syntax
Details
Example
See Also

Syntax

DMYTECKS (string, initial-cks, calculated-cks)

string
is the string for which the checksum is calculated. This argument can be a character variable, a character literal enclosed in quotation marks, or another character expression. A DataMyte can transmit a string of up to 256 characters.

initial-cks
is the initial checksum value. This value is ''00'x if the string is under 200 characters.

calculated-cks
is the calculated checksum for string. This value is a 2-byte hexadecimal number.


Details

The CALL DMYTECKS routine calculates the checksum for a packet. The checksum is the exclusive OR (XOR) of all the characters in the packet (including the start-of-text character, the character count, and end-of-transmission character), excluding the checksum itself. Because the length of SAS character variables is limited to 200, if you want to calculate the checksum for a packet that is longer than 200 characters, you have to call the CALL DYMTECKS routine twice. Call it once for the first 200 characters of the packet. Then pass the remaining characters to the CALL DYMTECKS routine using the calculated checksum from the first call as the initial checksum value for the second call.


Example

In the following example, the final checksum is stored in CALC_CS2.

data _null_;
   length string1 string2 $200 checksm1 checksm2 calc_cs1 calc_cs2; */
     /* The string received from the DataMyte is longer than 200    */
     /* characters, so it is split into two string, STRING1 and     */
     /* STRING2. However, you must calculate the checksum for the   */
     /* entire string (STRING1||STRING2).  SAS statements reading   */
     /* in data from DataMyte until EOT is found.                   */
     /* Initialize the first checksum.                              */
   checksm1='00'x;
   call dmytecks(string1,ckecksm1,calc_cs1);
   checksm2=calc_cs1;
   call dmytecks(string2,checksm2,calc_cs2);
run;

See Also


Chapter Contents

Previous

Next

Top of Page

Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.