Here is a simple hybrid package / JScript file that can be used to echo the results of any valid JScript expressions, including using \ xnn. It supports all byte codes from \ x00 to \ xFF.
A package takes one argument, enclosed in double quotes. The argument must be a valid JScript expression. Double quotes are not part of the expression. JScript strings inside an expression must be enclosed in single quotes.
By default, a new line is not printed at the end of the result. The / N option is used to add a new line at the end of the result.
If used in a batch file, then, of course, the script should be called using CALL.
jEval.bat
@if (@X)==(@Y) @end /* harmless hybrid line that begins a JScrpt comment ::: Batch part :::: @echo off cscript //nologo //e:JScript "%~f0" %* exit /b *** JScript part ***/ if (WScript.Arguments.Named.Exists("n")) { WScript.StdOut.WriteLine(eval(WScript.Arguments.Unnamed(0))); } else { WScript.StdOut.Write(eval(WScript.Arguments.Unnamed(0))); }
Here is an example call that uses \ xnn to enter a new line in the output file, and also contains floating point math.
>jEval " 'Hello world!\x0a4/5=' + 4/5 " /n Hello world! 4/5=0.8 >
dbenham
source share