#150536 - 2005-10-25 03:31 PM
Helpful Hint(?)
|
tsmith
Fresh Scripter
Registered: 2005-10-19
Posts: 27
|
You say you want to 'shell' out with a long line of code, but Kixtart won't allow it? Say, something like this:
GO "C:" CD "\" Shell "%COMSPEC% /e:1024 /c DIR /s *.mp? > Y:DSI_" + @YEAR@MONTHNO + "_" + @WKSTA + ".txt"
This will *not* work. (Well, not for *me* anyway.) So you have to build it in pieces. Try this:
Dim $ShellStr $ShellStr = "" $ShellStr = "%COMSPEC% /e:1024 /c DIR /s *.mp? > Y:DSI_" + @YEAR $ShellStr = $ShellStr + @MONTHNO $ShellStr = $ShellStr + "_" + @WKSTA + ".txt" GO "C:" CD "\" SHELL $ShellStr
This *does* work.
(I just thought this might save someone else a few hours of head banging against that proverbial brick wall. )
Tom
|
|
Top
|
|
|
|
#150539 - 2005-10-25 05:20 PM
Re: Helpful Hint(?)
|
tsmith
Fresh Scripter
Registered: 2005-10-19
Posts: 27
|
Well now... Guess what? Placing a '+' between them *does* work. So...
This does: @YEAR + @MONTHNO
This doesn't: @YEAR@MONTHNO
Hmmm... In those words of that famous Cuban Band Leader, Ricky Ricardo...
"Lucy, you gotta lotta splainin to do!" 
Seriously, could I impose upon someone to explain the difference between this (which works):
If Not Exist ("Y:CompInfo_@YEAR@MONTHNO.txt")
and this? (which doesn't work):
Shell "%COMSPEC% /e:1024 /c DIR /s *.mp? > Y:DSI_" + @YEAR@MONTHNO + "_" + @WKSTA + ".txt"
I'm assuming that I thought if one worked, that the other should too, which is why I hadn't tried placing a '+' between them myself.
Thanks,
Tom
|
|
Top
|
|
|
|
#150541 - 2005-10-26 11:34 AM
Re: Helpful Hint(?)
|
Richard H.
Administrator
   
Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
|
I'll elaborate on Glenn's explanation a little.
The issue is one of expressions. KiXtart is a fairly free format language, which allows you to do things like place multiple commands or expressions on a single line.
For example, the following three scripts are all equivalent: Code:
$a=1 $b=2
Code:
$a = 1 $b = 2
Code:
$a=1$b=2
You can see in the second example that we didn't even need a space between the two expressions - the interpreter knows when it sees the "$" character that the previous expression has ended.
With a very few exceptions (such as a comment), KiXtart has no understanding of a "line" of script.
Consider this simple example: Code:
"Your login is "@USERID@CRLF
This is actually three completely seperate expressions which have nothing to do with each other. You just happened to put them on one line. Each expression is evaluated and the output sent to the console before the interpreter moves on to the next one.
You could code this as a single expression: Code:
"Your login is "+@USERID+@CRLF
Now, as each sub-expression is evaluated it is kept on the internal data stack and the operator (+) is applied. The result is a single expression or value which is output to the console in one pass.
Another way of making this a single expression is to include the variables in the quotes, however this has it's own problems and you are strongly advised to avoid "VarsInStrings".
The difference is not just a matter of coding style as you've already seen.
|
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 1283 anonymous users online.
|
|
|