Pascal脚本中的全局变量是否初始化为零? [英] Are global variables in Pascal Script zero-initialized?

查看:120
本文介绍了Pascal脚本中的全局变量是否初始化为零?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我在Inno Setup脚本的[Code]部分(Pascal脚本)中声明全局变量时,它会自动初始化为零/空值吗?还是我必须显式初始化它(例如,在 InitializeSetup事件函数中) )?

When I declare a global variable in [Code] section (Pascal Script) of Inno Setup script, is it automatically initialized to zero/empty value? Or do I have to explicitly initialize it (e.g. in InitializeSetup event function)?

var
  GlobalNumber: Integer;

function InitializeSetup(): Boolean;
begin
  { Is this necessary? }
  GlobalNumber := 0;

  Result := True;
end;

根据我的经验,变量是零初始化的.不过,我不确定自己是否不幸运.

From my experience, the variables are zero-initialized. Though, I'm not sure if I just have not been lucky.

我已经完成了10.000次测试代码的迭代.全局变量(或各种类型,整数,字符串,指针)始终为零初始化.

I've done 10.000 iterations of a test code. The global variables (or various types, integer, string, pointer) were always zero-initialized.

推荐答案

变量在 Pascal脚本 afaik中自动初始化.

Variables are automatically initialized in Pascal Script afaik.

我以为我也曾在文档中的某处读过这篇文章,但是我在文档中再也找不到清晰的陈述.但是,如果您查看Pascal Script官方手册中的示例,则变量也不总是在那里初始化.例如,在此页面的第一个代码中,添加了字符串到Messages而不先对其进行初始化.

I thought that I also read this in earlier times somewhere in the docs, but I could not find a clear statement in documentation again. However, if you look at the examples from Pascal Script's official manual, variables are also not always initialized there. In the first code on this page for example, strings are added to Messages without having it initialized before.

这篇关于Pascal脚本中的全局变量是否初始化为零?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆