我想使用以下代码检查文件的MD5:
$query = $this->Courses->find('all')
->contain(['CourseMemberships'])
->where(['CourseMemberships.student_id' => $student['id'], 'CourseMemberships.grade' => 'A']);
但是在比较两个字符串时出现“Type Mismatch”错误,所以我假设这不是你比较它们的方式。
修改:我已尝试[Code]
var
MD5Comp: string;
procedure ExitProcess(uExitCode:UINT);
external 'ExitProcess@kernel32.dll stdcall';
procedure CurStepChanged(CurStep: TSetupStep);
begin
MD5Comp := '32297BCBF4D802298349D06AF5E28059';
if CurStep = ssInstall then
begin
if not MD5Comp=GetMD5OfFile(ExpandConstant('{app}\cg.npa')) then
begin
MsgBox('A patched version detected. Setup will now exit.', mbInformation, MB_OK);
ExitProcess(1);
end;
end;
end;
,但它永远不会执行if中的内容。
答案 0 :(得分:7)
这似乎是Pascal脚本编译器的一个例外。你期待这样的表达式(假设S1
和S2
是string
变量):
if not (S1 = S2) then
但是编译器会这样对待它:
if (not S1) = S2 then
好吧,我个人希望编译器错误而不是运行时错误。如果您明确将该比较括在括号中,至少可以解决此问题:
if not (MD5Comp = GetMD5OfFile(ExpandConstant('{app}\cg.npa'))) then
或者可选地写更多文字:
if MD5Comp <> GetMD5OfFile(ExpandConstant('{app}\cg.npa')) then
请注意,在这种情况下,不需要括号,因为使用<>
运算符它将成为单个布尔表达式。