#142878 - 2005-07-04 11:00 AM
Environment variable causes parser failure
|
Richard H.
Administrator
Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
|
In specific conditions the parser will fail when an environment variable is the first element of an expression.
Originally reported by John_c here: http://www.kixtart.org/ubbthreads/showfl...;gonew=1#UNREAD
This code: Code:
"Version: " @KIX ? "1 " "%WINDIR%" ? "2 " (%WINDIR%) ? "3 " CStr(%WINDIR%) ? "4 " ""+%WINDIR% ? "5 " %WINDIR% ?
Produces: Code:
C:\Temp>kix32 err.kix Version: 4.50 1 C:\Windows 2 C:\Windows 3 C:\Windows 4 C:\Windows 5 ERROR : unknown command [%WINDIR%]! Script: C:\Temp\err.kix Line : 6
It may also fail when the environment variable is the first part of an expression, such as: Code:
%WINDIR%+"" ?
|
Top
|
|
|
|
#142884 - 2005-07-04 04:20 PM
Re: Environement variable causes parser failure
|
Richard H.
Administrator
Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
|
Quote:
AFAIK, KiX has always behaved this way. Why do you consider it an issue?
If wrapped in quotes it is well behaved.
Well, you should reasonably expect to be able to use an environment variable in exactly the same way that you would a KiXtart variable or macro (notwithstanding the fact that it is read only)
I don't believe that the current action is intentional which is why I've highlighted it here.
|
Top
|
|
|
|
#142886 - 2005-07-05 09:28 AM
Re: Environement variable causes parser failure
|
Richard H.
Administrator
Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
|
Quote:
No, it is not, IMHO. One indication would be that there is the EXPANDENVIRONMENTVARS() function, which would be mostly superfluous then.
Not at all.
The primary purpose of ExpandEnvironmentVars() is used to expand environment variables when they are already in strings. A good example (and I'd guess what ExpandEnvironmentVars was originally coded for) is when they are read from the registry. The only other easy way to do this is to use Execute(), which hasn't always been available in KiXtart.
Quote:
also, nowhere in the KiXtart Manual is mentioned that one can use environment variables just like KiXtart variables or macros.
No, nor does it mention that you cannot A reasonable assumption unless you're told otherwise would be that an environment variable can be used wherever a KiXtart variable can.
Consider the examples. Why does this code work: Code:
(%VARIABLE%) ?
But this code causes the parser to fail: Code:
%VARIABLE% ?
The parentheses are redundant so it's not affecting the script process at all. It's a parser failure, not a code failure.
You can turn the argument on it's head of course and ask yourself if it is reasonable for the parser to fail in this way. If you think that it is, what are the reasons that this is a good thing? Do you think that this action should be preserved?
|
Top
|
|
|
|
Moderator: ShaneEP, Arend_, Jochen, Radimus, Glenn Barnas, Allen, Ruud van Velsen, Mart
|
0 registered
and 507 anonymous users online.
|
|
|