DELPHIXE UNIGUI 二维码名片解析

DELPHIXE UNIGUI 二维码名片解析

UNIGUI 条形码和二维码的生成和识别在****上有很多,这里就不多说了,主要说下二维码名片的解析

unit Test;

type
TContactBar = record
conName: string; // 姓名
conPhone: string; // 电话1
conEmail: string; // 邮箱
conRemark: string; // 备注
end;

implementation

解析二维码名片代码如下:
// 从字符串sl中以sFlag为分隔取出第idx段内容
// 例 GetIdxStr(‘ab|cd|12345’, 3,’|’) 返回结果为’12345’
// 参数idx必须从1开始计数
function GetIdxStr(sL: string; idx: integer; sFlag: string): string;
var
i, iLength, iFindCount: integer;
st: string;
begin
i := 1;
iLength := Length(sL);
iFindCount := 0;
if sFlag = ‘’ then
sFlag := ‘,’;

st := ‘’; // ab|cd|ef
while (iFindCount <> idx) and (i <= iLength) do
begin
if sL[i] = sFlag then
begin
Inc(iFindCount);
if iFindCount = idx then
begin
Result := st;
break;
end
else
begin
st := ‘’;
end;
end
else
begin
st := st + sL[i];
end;
Inc(i);
end;
Result := st;
end;

procedure TMainForm.UniButton8Click(Sender: TObject);
var
sval:string;
contBar: TContactBar;
sMsg:string;
begin
sval:=‘MECARD:N:刘德华;SOUND:;TEL:;TEL:18236444444;EMAIL:;EMAIL:[email protected];NOTE:大明星;;’

with contBar do
begin
conName := GetIdxStr(GetIdxStr(sval,1,’;’),3,’:’);
conPhone := GetIdxStr(GetIdxStr(sval,4,’;’),2,’:’);
conEmail := GetIdxStr(GetIdxStr(sval,6,’;’),2,’:’);
conRemark := GetIdxStr(GetIdxStr(sval,7,’;’),2,’:’);
sMsg:=‘姓名:’+conName+#13#10+‘电话:’+conPhone+#13#10+‘邮箱:’+conEmail+#13#10+‘备注:’+conRemark;
end;
EasyHelperDialog(sMsg,TEhDialog.info);
end;

DELPHIXE UNIGUI 二维码名片解析
DELPHIXE UNIGUI 二维码名片解析

DELPHIXE UNIGUI 二维码名片解析