| 1. |
Solve : Possibly handy VBS script? |
|
Answer» Win2K onwards... nice script Dias, Not sure what you mean. You can feed batch variables into it. In a batch you could invoke it directly if you just wanted to show the answer or you could use FOR to get the answer into a batch variable. Above, I showed it EVALUATING a batch string variable like this: Code: [Select]set pi=(4*atn(1)) set expression=%pi%*(%radius%^^2) for /f "delims==" %%A in ('evaluate "%expression%" ') do set answer=%%A set area=%answer% or... Code: [Select]C:\>set n1=6 C:\>set n2=5 C:\>evaluate %n1%+%n2% 11Quote ^ operator What does the ^ operator do? Exponentiation. I think it escapes characters in batch so I think that has something to do with it. I still say BCScript and BASeParser are better. They can, after all, do this: Code: [Select]STORE(X,{25,36,49}) STORE(Y,Sqr(-X)+X[{1,2,3} PICK 1]) [emailprotected](Y) which would output(possibly, given use of random PICK operator): Code: [Select]{5i+25,6i+49,7i+36} Supports Imaginary numbers, as well as intrinsic support for matrix operations and so forth- not to mention such novel operators such as the "PICK" operator used previous as well as nCr and nPr (number of Combinations and Number of Permutations, respectively) And ** or ^ as multiplication, Logical and boolean operations, etc. It's going to be a TOUGH cookie to document, though... And I assure you it's not one line of code. Actually: 15,080 code lines and 6,863 Comment lines. So I suppose this method wins in the terseness department... Quote from: Dias de verano on February 21, 2009, 08:18:16 AM Quote from: macdad- on February 21, 2009, 07:55:37 AMnice script Dias, thats what i meant...but its pretty good. Really handy - floating point math in batch scripting is a step closer (almost). Thanks Dias.Quote from: BC_Programmer on February 21, 2009, 10:01:42 AM Exponentiation. I think it escapes characters in batch so I think that has something to do with it. And it also can act as a line continuation character, depending on the circumstances. So you can prettify batch scripts where the lines are very long. Code: [Select]@echo off dir ^ /a-d ^ /w But its role as a batch script control character means it needs escaping in a batch file, by the escape char which happens to be another ^ (caret) character. I have seen people call it a "carrot". I've had people call it an up-arrow. Not EXACTLY accurate, or the Asterisk, "I put my password in and I see a bunch of SPIDERS" |
|