Consider a simple program like this:
Message("",Param1/4)
So you run this with a parameter of 3. You get back 0 instead of .75
(Obviously, this example is contrived, but it springs from a real world problem)
The only workaround I could find is:
Message("",%Param1%.0/4)
It seems to me there should be a more straightforward (less ugly) way to force it to do decimal math. Is there?
Edit: I just thought of this. Would this work?
Message("",(Param1+0.0)/4)
Is that any better?
I often do something like that but there is also...
num = ObjectType("R4",7)
message("HEY",num/4)
Jim
What is ObjectType() ?
Don't think that exists in my version of WB.
[see attachment]
It just seems like there should be a way to just say:
Evaluate this string in floating point.
without the kludgieness of any of the "solutions" we've seen so far in this thread (many of them by me).
You can. That is the purpose of ObjectType(). You just tell it a variable is explicitly a floating point and it will treat that way from that point on. It is simply the trade-off for the automagical conversion ability of WinBatch but really no different than strongly typed languages where you have to explicitly type them for every definition. WinBatch just uses the ObjectType syntax for the typing when you want it explicit but makes it easier for everything else.
Jim