| 10 |  | function Encode_Int(input: LongWord): TByteData; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 11 |  | function Decode_Float(buffer: TByteData): Single; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 12 |  | function Encode_Float(input: Single): TByteData; | 
 
 
 
 
 
 
 
 | 13 | + | function IntToBin(Value: Byte): String; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 14 |  | function DataToBin(Data: TByteData): String; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 15 |  | function BinToInt(bin: String): Byte; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 16 |  |  | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 39 |  |  | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 40 |  |  | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 41 |  |  | 
 
 
 
 
 
 
 
 
 | 41 | – |  | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 42 |  | function BoolToStr(bool: Boolean): String; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 43 |  | begin | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 44 |  | if bool then | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 48 |  | end; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 49 |  |  | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 50 |  |  | 
 
 
 
 
 
 
 
 
 | 51 | – |  | 
 
 
 
 
 
 
 
 
 | 52 | – |  | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 51 |  | function HexToLong(hex: String): LongWord; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 52 |  |  | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 53 |  | function NormalizeHexString(var hex: String): Boolean; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 73 |  |  | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 74 |  | begin | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 75 |  | if NormalizeHexString(hex) then | 
 
 
 
 
 
 
 
 
 
 
 | 76 | < | begin | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 79 | < | Result := StrToInt(hex); | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 80 | < | { | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 81 | < | hex    := UpperCase(hex); | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 82 | < | Result := 0; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 83 | < | for i := 1 to Length(hex) do | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 84 | < | begin | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 85 | < | Result := Result shl 4; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 86 | < | case hex[i] of | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 87 | < | '0'..'9': | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 88 | < | Result := Result + Ord(hex[i]) - 48; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 89 | < | 'A'..'F': | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 90 | < | Result := Result + Ord(hex[i]) - 55; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 91 | < | else | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 92 | < | Result := 0; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 93 | < | Exit; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 94 | < | end; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 95 | < | end; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 96 | < | } | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 97 | < | end | 
 
 
 
 
 
 
 
 
 | 76 | > | Result := StrToInt(hex) | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 77 |  | else | 
 
 
 
 
 
 
 
 
 | 99 | – | begin | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 78 |  | Result := 0; | 
 
 
 
 
 
 
 
 
 | 101 | – | end; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 79 |  | end; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 80 |  |  | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 81 |  |  | 
 
 
 
 
 
 
 
 
 | 105 | – |  | 
 
 
 
 
 
 
 
 
 | 106 | – |  | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 82 |  | function Decode_Int(buffer: TByteData): LongWord; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 83 |  | begin | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 84 |  | Result := buffer[0] + buffer[1] * 256 + buffer[2] * 256 * 256 + buffer[3] * 256 * 256 * 256; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 85 |  | end; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 86 |  |  | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 87 |  |  | 
 
 
 
 
 
 
 
 
 | 113 | – |  | 
 
 
 
 
 
 
 
 
 | 114 | – |  | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 88 |  | function Encode_Int(input: LongWord): TByteData; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 89 |  | begin | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 90 |  | SetLength(Result, 4); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 98 |  | end; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 99 |  |  | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 100 |  |  | 
 
 
 
 
 
 
 
 
 | 128 | – |  | 
 
 
 
 
 
 
 
 
 | 129 | – |  | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 101 |  | function Decode_Float(buffer: TByteData): Single; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 102 |  | var | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 103 |  | _valueswitcher: TValueSwitcher; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 109 |  | end; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 110 |  |  | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 111 |  |  | 
 
 
 
 
 
 
 
 
 | 141 | – |  | 
 
 
 
 
 
 
 
 
 | 142 | – |  | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 112 |  | function Encode_Float(input: Single): TByteData; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 113 |  | var | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 114 |  | _valueswitcher: TValueSwitcher; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 118 |  | end; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 119 |  |  | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 120 |  |  | 
 
 
 
 
 
 
 
 | 121 | + | function IntToBin(Value: Byte): String; | 
 
 
 
 
 
 
 
 | 122 | + | var | 
 
 
 
 
 
 
 
 | 123 | + | i: Byte; | 
 
 
 
 
 
 
 
 | 124 | + | begin | 
 
 
 
 
 
 
 
 | 125 | + | Result := ''; | 
 
 
 
 
 
 
 
 | 126 | + | for i := 7 downto 0 do | 
 
 
 
 
 
 
 
 | 127 | + | Result := Result + IntToStr((Value shr i) and $01); | 
 
 
 
 
 
 
 
 | 128 | + | end; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 129 |  |  | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 130 |  |  | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 131 |  | function DataToBin(Data: TByteData): String; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 149 |  | end; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 150 |  |  | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 151 |  |  | 
 
 
 
 
 
 
 
 
 | 175 | – |  | 
 
 
 
 
 
 
 
 
 | 176 | – |  | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 152 |  | function BinToInt(bin: String): Byte; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 153 |  | var | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 154 |  | Add: Integer; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 170 |  |  | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 171 |  |  | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 172 |  |  | 
 
 
 
 
 
 
 
 
 | 198 | – |  | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 173 |  | function FormatNumber(Value: LongWord; Width: Byte; leadingzeros: Char): String; | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 174 |  | begin | 
 
 
 
 
 
 
 
 
 
 
 
 
 | 175 |  | Result := AnsiReplaceStr(Format('%' + IntToStr(Width) + 'u', [Value]), ' ', leadingzeros); |