SmartFactory_NEOL/SOURCE/Agent,Kiosk/Lib/global.pas
2026-09-04 14:08:41 +09:00

74 lines
1.5 KiB
ObjectPascal

unit global;
interface
uses Windows, ExtCtrls, Classes;
procedure FloatToData(val : single; var buf : array of byte);
procedure Strsplit(sepq: string; LineStr: string; var tmpList: TStringList);
implementation
procedure Strsplit(sepq: string; LineStr: string; var tmpList: TStringList);
var
//ctnSep : integer;
tmpStr: string;
begin
//ctnSep := 0;
while true do
begin
if Pos(sepq, LineStr) <> 0 then
begin
tmpStr := Copy(LineStr, 0, Pos(sepq, LineStr) - 1);
tmpList.Add(tmpStr);
LineStr := Copy(LineStr, Pos(sepq, LineStr) + 1, Length(LineStr));
continue;
end
else
begin
tmpList.Add(LineStr);
break;
end;
end;
end;
procedure FloatToData(val : single; var buf : array of byte);
var
i : integer;
tmp : array[0..7] of byte;
val_buf : array[0..3] of byte;
begin
Randomize;
for i := 0 to 7 do
begin
tmp[i] := random(1000);
tmp[i] := tmp[i] and $0f;
end;
Move(val, val_buf, sizeof(single));
tmp[0] := tmp[0] or (val_buf[0] and $f0);
tmp[1] := tmp[1] or (val_buf[0] shl 4);
tmp[2] := tmp[2] or (val_buf[1] and $f0);
tmp[3] := tmp[3] or (val_buf[1] shl 4);
tmp[4] := tmp[4] or (val_buf[2] and $f0);
tmp[5] := tmp[5] or (val_buf[2] shl 4);
tmp[6] := tmp[6] or (val_buf[3] and $f0);
tmp[7] := tmp[7] or (val_buf[3] shl 4);
for i := 0 to 7 do
begin
buf[i] := tmp[i];
end;
end;
end.