#159821 - 2006-08-22 09:05 AM
Re: Erroneous Macro Results
|
Richard H.
Administrator
Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
|
Quote:
Invalid macros inside strings regardless of SetOption() should simply be taken as literal text. It is unreasonable to expect KiX to determine invalid macros embedded within strings, period.
As I said in an earlier post, KiXtart already determines invalid macros embedded in strings, "period". So how can you possibly consider that unreasonable?
|
Top
|
|
|
|
#159823 - 2006-08-22 11:53 AM
Re: Erroneous Macro Results
|
Witto
MM club member
Registered: 2004-09-29
Posts: 1828
Loc: Belgium
|
I think, what Jooel and Les want, is that something between quotes, starting with an @-sign, but definitely no macro, just is a part of a string. Only existing macros in strings should be recognised. This is of course when NoMacrosInStrings is Off. I do understand that point of view. Maybe it would be better than it works now. But why is KiXtart so forgiving p.e. for Code:
Break On +Blablabla
And should it not help recognising a mistyped macro between quotes? Once again, as long as NoMacrosInStrings is Off.
|
Top
|
|
|
|
#159824 - 2006-08-22 01:55 PM
Re: Erroneous Macro Results
|
Richard H.
Administrator
Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
|
Quote:
I think, what Jooel and Les want, is that something between quotes, starting with an @-sign, but definitely no macro, just is a part of a string.
I understand that, but why bring the handling of invalid macros down to the lowest common denominator? If the processing is to be changed why not take the opportunity to change it so that macros both inside and outside strings will generate an error if they are mistyped?
Consider this bit of code: Code:
$sMailAddress="helpdesk@service.acme.com"
This is a coding error. If the "@" symbol is intended to be present in the string it should be doubled up "helpdesk@@service.acme.com" - that is the KiXtart syntax.
If the parser is changed to ignore the error then this code will work. But what happens in KiXtart release 4.xx when Ruud introduces the new @SERVICE macro to indicate when a script is running as a service? Oops. It would be better if the programmer had been notified the very first time he tested the script that the string contained an invalid macro. He would have doubled up the "@" and there would be no chance of a namespace clash in the future.
Quote:
But why is KiXtart so forgiving
Backwards compatibility. When KiXtart first appeared it was a fairly simple beast designed to replace BATch files so the syntax was designed to be simple and accomodating. If the parser was made more pedantic now it would break too many existing scripts. Personally I'd be happy with a "Strict" option which disallows some of the easy-coder things like bare strings, multi-line strings and so-on.
|
Top
|
|
|
|
#159826 - 2006-08-22 03:48 PM
Re: Erroneous Macro Results
|
Richard H.
Administrator
Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
|
I guess I'm missing something. Why do you think that KiXtart should not throw an error on a coding error? With NoMacrosInStrings off a single @ in a string is an introduction to a macro. If you're using it for anything else you've made a typo. As I've demonstrated in the somewhat contrived example in the previous post doing anything other than raising an exception is creating the potential for failures in the future.
The only possible problem that I can imagine that erroring on invalid macros might cause is if anyone has added code to check for macro support, something like: Code:
If "@FOO" = "<unknown:FOO" "Sorry, your version of KiXtart does not support the @@FOO macro - please upgrade" ? Exit 1 EndIf
|
Top
|
|
|
|
#159830 - 2006-08-22 05:02 PM
Re: Erroneous Macro Results
|
Shawn
Administrator
Registered: 1999-08-13
Posts: 8611
|
You guys should be very proud of me ... I am getting better ... check-out this script bit:
Re: Map drive by user id.
-Shawn
|
Top
|
|
|
|
#159831 - 2006-08-22 10:08 PM
Re: Erroneous Macro Results
|
Les
KiX Master
Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
|
LOL He uses concatenation on a "temporary" marker line to be used to debug and then throw away.
I was going to reprimand him for going off topic in the beta forum but he's as cute as a lamb and I couldn't bring myself to do it.
Just shoot him, damnit... shoot him!
|
Top
|
|
|
|
#159832 - 2006-09-30 07:40 AM
Re: Erroneous Macro Results
|
Allen
KiX Supporter
Registered: 2003-04-19
Posts: 4548
Loc: USA
|
I'm not sure how practical this is... but here is a stab at making the script exit on a macro error... Maybe in Version 5 there will be no macros as they are now but are accessed through a Macro(Lookup) function.
Code:
break on $=setoption("Novarsinstrings","on")
? macro("KIX") ? macro("err")
function macro($name) dim $ms,$,$colors $ms=setoption("NoMacrosinstrings","off") $=execute("$" + "macro='@@" + $name + "'") if instr($macro,"<unknown:") $colors=split(@color,"/") color $colors[0]+ / $colors[1] "ERROR : Unknown Macro [" + $name + "]" + "!" color $colors[0] / $colors[1] quit endif $ms=setoption("NoMacrosinstrings",$ms) endfunction
Produces: Code:
4.52 ERROR : Unknown Macro [err]!
|
Top
|
|
|
|
Moderator: ShaneEP, Arend_, Jochen, Radimus, Glenn Barnas, Allen, Ruud van Velsen, Mart
|
1 registered
(Allen)
and 566 anonymous users online.
|
|
|