View Full Version : Suggestion to prevent typos in variable names
NewsArchive
05-07-2011, 06:23 AM
Hi Friedrich
i would like to suggest a new pragma
STRICT.
If this is set, a variable can only be used, if it is defined first.
If a variable is used without definig it first, the compiler stops with
a fatal error.
This would prevent you from using wrong variable values because of a
simple typo.
What do you think?
Markus
NewsArchive
05-07-2011, 06:23 AM
Hi Markus,
The SB7 compiler should always detect this.
Where can you use a variable that has not been previously defined?
Friedrich
NewsArchive
05-07-2011, 06:24 AM
I have to check it. I can't actual remember.
Markus Zander
NewsArchive
05-07-2011, 06:24 AM
>
>I have to check it. I can't actual remember.
>
Thank you. Then we have to fix it in this function(s).
Friedrich
NewsArchive
07-06-2011, 01:47 AM
Hi Friedrich,
> The SB7 compiler should always detect this.
> Where can you use a variable that has not been previously defined?
please have a look at the attached screen shot. The compiler Variable
[COMPANY] does not exist but the compiler doesn't give me an error but
treat this as a string...
Markus
NewsArchive
07-06-2011, 01:47 AM
Hi Markus,
> please have a look at the attached screen shot. The compiler Variable
> [COMPANY] does not exist but the compiler doesn't give me an error but
> treat this as a string...
Yes, in some places, compiler and/or runtime variables were not allowed in
the past (SB5/SB6). The compiler enhanced and can handle variables now, but
some functions still do not check if the variable has been previously
defined.
Fixed in the "Shortcuts" functions now.
Friedrich
NewsArchive
07-06-2011, 01:48 AM
Thank you.
Markus Zander
NewsArchive
07-06-2011, 01:50 AM
Hi Friedrich,
now I found the real reason for my post...
I just had a "Cannot find variable %XYZ%" at runtime :-(
What I asked for was a special "DEFINE" statement for Runtime-Variables
in combination with a "STRICT" pragma.
Why?
This would prevent:
a) Typos in a set variable statement
b) Undefined variables at runtime if a variable is accidentally set only
in an if clause, but used outside.
The DEFINE statement should work at runtime like
set variable XYZ to ''
and at compile time, it MUST be used in the first level (without
indentation, ==> no if condition or something else at runtime).
What do you think?
Markus
NewsArchive
07-06-2011, 02:38 AM
Hi Markus,
>
> What do you think?
>
The SB75 compiler "should" detect all undefined variables at compile-time
now. There were still some older functions were the variable check
mechanism was only partially implemented. This should help to overcome
"problem #1". To overcome "problem #2", I would suggest to always declare
your variables in the [ Initialize Setup ] section.
Friedrich
NewsArchive
07-07-2011, 12:37 AM
Hi Friedrich,
perhaps I don't understand how things work...
How can I declare a variable?
At the moment, i think a variable is implicit defined, if it is set for
the first time.
Markus
NewsArchive
07-07-2011, 12:37 AM
Hi Markus,
> perhaps I don't understand how things work...
>
> How can I declare a variable?
>
> At the moment, i think a variable is implicit defined, if it is set for
> the first time.
As I understand it, you received a "Cannot find variable YADA" at installer
runtime.
There are two possible causes for this:
1. You used a variable before you defined it and the compiler did not catch
this (compiler bug!!).
2. You defined the variable before you used it but you did it in a
conditional statement that never resolved to TRUE.
For example:
1 Set Variable %TEST% to "0"
2 If %TEST% Equals "1" Then
3 Set Variable %YADA% to "1"
4 End
5 Set Variable %TEST% to "%YADA%"
6 Display Message Box "%TEST%" -- ""
You define %YADA% in Line 3 before you use it in Line 5. But at runtime,
the "If" statement in Line 2 never resolves to TRUE and so in fact, the line
that defines the variable is never executed.
So to be on the safe side (variable definition wise), do this:
1 ! All my variable definitions go here
2 Set Variable %YADA% to ""
3
4 Set Variable %TEST% to "0"
5 If %TEST% Equals "1" Then
6 Set Variable %YADA% to "1"
7 End
8 Set Variable %TEST% to "%YADA%"
9 Display Message Box "%TEST%" -- ""
Friedrich
NewsArchive
07-07-2011, 12:38 AM
Hi Friedrich,
I want to be FORCED to declare all variables.
This prevents me from accidentally use an "implicit" declared variable
somewhere in the script.
Markus
NewsArchive
07-07-2011, 12:38 AM
Hi Markus,
> I want to be FORCED to declare all variables.
>
> This prevents me from accidentally use an "implicit" declared variable
> somewhere in the script.
By design, this is not possible in SB7 nor in SB8. But I see where you are
coming from. Perhaps it will be supported in one of the future versions.
Friedrich
NewsArchive
07-07-2011, 12:39 AM
Hi Markus,
> I want to be FORCED to declare all variables.
>
> This prevents me from accidentally use an "implicit" declared variable
> somewhere in the script.
Okay, I know that you need a good reason to renew your SetupBuilder
maintenance and support subscription plan <g> Just joking... ;-)
Experimental 'STRICT' #pragma added to SetupBuilder 7.5.
Friedrich
--
Friedrich Linder
Lindersoft
www.lindersoft.com
+1.954.252.3910
SetupBuilder is Windows 7 installation -- "point. click. ship"
-- Official Comodo Code Signing and SSL Certificate Partner
NewsArchive
07-07-2011, 12:39 AM
> Experimental 'STRICT' #pragma added to SetupBuilder 7.5.
Friedrich Linder, bona fide rocket surgeon!
--
Lee White
RPM Report Viewer.: http://www.cwaddons.com/products/rpm/
RPM Review........: http://www.clarionmag.com/cmag/v11/v11n06rpm.html
Report Faxing.....: http://www.cwaddons.com/products/afe/
---Enroll Today---: http://CWaddons.com
Enhanced Reporting: http://www.cpcs-inc.com
Product Release & Update Notices
http://twitter.com/DeveloperPLUS
NewsArchive
07-07-2011, 12:40 AM
Cool. Calling it "EXPLICIT" or "OPTIONEXPLICIT" might make it more
intuitive for VB customers.
Jeff Slarve
www.jssoftware.com
www.twitter.com/jslarve
NewsArchive
07-07-2011, 12:41 AM
http://msdn.microsoft.com/en-us/library/y9341s4f(v=vs.80).aspx
Jeff Slarve
www.jssoftware.com
www.twitter.com/jslarve
NewsArchive
07-07-2011, 12:41 AM
How about "I_REALLY_MEAN_IT"? <g>
--
Russell B. Eggen
www.radfusion.com
NewsArchive
07-07-2011, 12:43 AM
Russ,
> How about "I_REALLY_MEAN_IT"? <g>
As long as it's NOT... "__Dont_Touch_Me__" !!!
--
Lee White
RPM Report Viewer.: http://www.cwaddons.com/products/rpm/
RPM Review........: http://www.clarionmag.com/cmag/v11/v11n06rpm.html
Report Faxing.....: http://www.cwaddons.com/products/afe/
---Enroll Today---: http://CWaddons.com
Enhanced Reporting: http://www.cpcs-inc.com
Product Release & Update Notices
http://twitter.com/DeveloperPLUS
NewsArchive
07-07-2011, 12:44 AM
I've been rooting for _CAN'T_TOUCH_THIS_
http://www.metrolyrics.com/u-cant-touch-this-lyrics-mc-hammer.html
Abe Jimenez
NewsArchive
07-07-2011, 12:44 AM
http://bit.ly/nHt8Q8
Jeff Slarve
www.jssoftware.com
www.twitter.com/jslarve
NewsArchive
07-07-2011, 12:45 AM
Touchy, ain't ya? <g>
--
Russell B. Eggen
www.radfusion.com
NewsArchive
06-28-2012, 10:54 AM
Hi Friedrich,
I can't find our latest discussion concerning this. As I can read in the
documentation, I'm forced to declare all variables in the "initialize
setup" section in the .sb7 script. But what about include scripts? I
think, we need a section [initialize variables] in each include script.
What do you think?
Markus
NewsArchive
06-28-2012, 10:55 AM
Hi Markus,
> I can't find our latest discussion concerning this. As I can read
> in the documentation, I'm forced to declare all variables in the
> "initialize setup" section in the .sb7 script. But what about include
> scripts? I think, we need a section [initialize variables] in each
> include script.
>
> What do you think?
I can put this to the wish-list, but I don't expect it in the near future.
This would be a major compiler modification.
Friedrich
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.