How do you determine if an object has be constructed in Inno Setup Pascal Script?

断了今生、忘了曾经 提交于 2021-02-04 21:27:07

问题


How do I check that my checkbox has been created / constructed and can be used to check if checked?

[Code]

var
  MyCheckBoxThatMayExistOrNot: TNewCheckBox;

procedure Whatever();
begin
  { Check if MyCheckBoxThatMayExistOrNot exists and checked }
  if ????? and MyCheckBoxThatMayExistOrNot.Checked then
  begin
    ...
  end;
end;

TIA!!


回答1:


Compare the variable value against nil:

if (MyCheckBoxThatMayExistOrNot <> nil) and MyCheckBoxThatMayExistOrNot.Checked then

An equivalent is use of Assigned function:

if Assigned(MyCheckBoxThatMayExistOrNot) and MyCheckBoxThatMayExistOrNot.Checked then

You might want to explicitly initialize the variable to nil in InitializeSetup or InitializeWizard, but it should not be necessary: Are global variables in Pascal Script zero-initialized?



来源:https://stackoverflow.com/questions/62708973/how-do-you-determine-if-an-object-has-be-constructed-in-inno-setup-pascal-script

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!