Why can't we declare local constant variables in inno-setup [Code]?

Do you know why when declaring local const vars , the script cannot compile? Sorry, I know a very small Pascal and can not understand why this does not work!

This example (see function CircleArea ) shows that my syntax must be accurate. http://www.tutorialspoint.com/pascal/pascal_quick_guide.htm

This is what I am trying to do:

//---placed within [Code] procedure MyLog(const _functionName, _msg: String); begin Log(_functionName + '(): ' + _msg); end; function MyExec(const _filename, _params, _dir: String): Boolean; const // <--- compilation fails in this line! MethodName = 'MyExec'; var ResultCode: Integer; begin MyLog(MethodName, _filename); // ... invoke Exec(), etc. ... end; //--- 
+4
source share
1 answer

You tried it right. If Inno Setup used Pascal, it would even work, but since it is based on a custom Pascal Script language with a restriction on declaring local constants, you cannot do this. Instead, you should define your constant globally:

 [Code] const MethodName = 'MyExec'; function MyExec(const _filename, _params, _dir: String): Boolean; var ResultCode: Integer; begin MyLog(MethodName, _filename); // ... invoke Exec(), etc. ... end; 
+6
source

Source: https://habr.com/ru/post/1501920/


All Articles