Delphi用if else实现 select case、switch语句功能,实现case 以字符串为分类条件。
function RetTextFromStr(inputstr:string):string;stdcall;
var
i:integer;
beginRetTextFromStr:='';if inputstr='9000' thenRetTextFromStr := '成功!'else if inputstr='9100' thenbeginpcdbeep(20);RetTextFromStr := '成功!';endelse if inputstr='6281' thenRetTextFromStr := '回送的数据可能错误!'else if inputstr='6283' thenRetTextFromStr := '选择文件无效,文件或密钥校验错误!'else if inputstr='6400' thenRetTextFromStr := '状态标志未改变!'else if inputstr='6581' thenRetTextFromStr := '写 EEPROM 不成功!'else if inputstr='6700' thenRetTextFromStr := '长度错误!'else if inputstr='6900' thenRetTextFromStr := 'CLA 与线路保护要求不匹配!'else if inputstr='6901' thenRetTextFromStr := '无效的状态!'else if inputstr='6981' thenRetTextFromStr := '命令与文件结构不相容!'else if inputstr='6982' thenRetTextFromStr := '不满足安全状态!'else if inputstr='6983' thenRetTextFromStr := '密钥被锁死!'else if inputstr='6984' thenRetTextFromStr := 'MAC格式不符合!'else if inputstr='6985' thenRetTextFromStr := '使用条件不满足!'else if inputstr='6986' thenRetTextFromStr := '请先选择文件!'else if inputstr='6987' thenRetTextFromStr := '无安全报文!'else if inputstr='6988' thenRetTextFromStr := '安全报文数据项不正确!'else if inputstr='6A80' thenRetTextFromStr := '数据域参数错误!'else if inputstr='6A81' thenRetTextFromStr := '功能不支持或卡中无MF 或卡片已锁定!'else if inputstr='6A82' thenRetTextFromStr := '文件未找到!'else if inputstr='6A83' thenRetTextFromStr := '记录未找到!'else if inputstr='6A84' thenRetTextFromStr := '文件无足够空间!'else if inputstr='6A86' thenRetTextFromStr := '参数P1 P2 错!'else if inputstr='6A88' thenRetTextFromStr := '密钥未找到!'else if inputstr='6B00' thenRetTextFromStr := '在达到Le/Lc 字节之前文件结束,偏移量错误!'else if inputstr='6E00' thenRetTextFromStr := '无效的CLA!'else if inputstr='6F00' thenRetTextFromStr := '数据无效!'else if inputstr='9302' thenRetTextFromStr := 'MAC 错误!'else if inputstr='9303' thenRetTextFromStr := '应用已被锁定!'else if inputstr='9401' thenRetTextFromStr := '金额不足!'else if inputstr='9403' thenRetTextFromStr := '密钥未找到!'else if inputstr='9406' thenRetTextFromStr := '所需的MAC 不可用!'else if inputstr='91AE' thenRetTextFromStr := '认证失败,请检查命行的参数和前期计算是否错误!'else if inputstr='91CA' thenRetTextFromStr := '上一个命令未完全完成!'else if inputstr='917E' thenRetTextFromStr := '指令长度错误!'else if inputstr='9140' thenRetTextFromStr := '当前目录或应用密钥不存在,请先选择正确的目录或应用!'else if inputstr='919D' thenRetTextFromStr := '处于未验证密码的状态,该指令无法操作!'else if inputstr='911E' thenRetTextFromStr := 'MAC错误!'else if inputstr='91F0' thenRetTextFromStr := '该文件号不存在!'else if inputstr='919E' thenRetTextFromStr := '参数无效!'else if inputstr='91BE' thenRetTextFromStr := '试图读取/写入的数据超出文件/记录的边界!'else if inputstr='91A0' thenRetTextFromStr := '请求的 AID 不存在!'elsebeginif midstr(inputstr,1,3)='63C' thenbegini:=strtoint('$'+midstr(inputstr,3,1));if i>0 thenRetTextFromStr := '再试 '+inttostr(i)+' 次错误密码将锁定!'elseRetTextFromStr := '密码已被锁定!' ;endelseRetTextFromStr:='未知的异常';end;
end;
NFC URI网址写入:https://item.taobao.com/item.htm?spm=a21dvs.23580594.0.0.52de2c1bJicRWj&ft=t&id=615391857885