Table of Content
HAL Forum
function integer GetByteFromString (
string TargetString,integer Position)
Description:
Returns the ASCII value of a character in a string on a given position.
Parameters:
TargetString The string from where we are extracting the character.
Position The position of the character in a string (starting from 0).
function string 255 CalculateLRC(string CtrlSeq)
begin
  string 255 res;
  Integer i,resi,a;
  
  resi = 0;
  for (i=0;i<len(CtrlSeq);i=i+1) begin
    a = GetByteFromString(Mid(CtrlSeq,i,1),0);
    resi = BitXor(resi,a);
//    resi = BitXor(resi,asc(Mid(CtrlSeq,i,1)));
  end;
  res = NumToHex(resi);
  res = Right(res,2);
  CalculateLRC = res;
  return;
end;
Related topics:
««