Decimals

Started by JTaylor, September 12, 2015, 03:42:58 PM

Previous topic - Next topic

JTaylor

I give up....What do I need to do to get message #4 to return the correct answer (.055...) instead of zero?

Jim

Code (winbatch) Select

      Decimals(-1)
    swidth = 1900.0        ;WinMetrics(0)+0.0
    sheight= 1080.0        ;WinMetrics(1)+0.0
message(swidth,sheight)
      ypos  = 27.0                              ;ItemExtract(2,MFB005,",")+0.0
message(1,ypos)
      ypos  = 54.0                              ;TP_V(ypos)+0.0
message(2,ypos)
      ypos  = ((ypos+0.0)\(sheight+0.0))
message(4,ypos)
      ypos  = (ypos*1000.0)
message(5,ypos)


snowsnowsnow

I assume the \ (backslash) is a typo.

When I fixed that, I get .05
which is, I think the right answer for 54/1080

JTaylor

Well...that is a few hours I won't get back :-[

Always something simple.  Thanks.


Jim

snowsnowsnow

You must have been running with ErrorMode(@OFF) - in order to get zero instead of a syntax error/abort.

And you know what Marty says about running with ErrorMode(@OFF) [!]

Anyway, as you probably know, \ is the symbol for integer division in Visual Basic.  When I saw your code, I half-expected you to tell me that that symbol had been added to WinBatch (in the last 9 years) and that it wasn't a typo...

JTaylor

No.  Didn't do anything with ErrorMode.   Thanks again.

Jim

td

Quote from: snowsnowsnow on September 12, 2015, 05:31:24 PM
You must have been running with ErrorMode(@OFF) - in order to get zero instead of a syntax error/abort.

And you know what Marty says about running with ErrorMode(@OFF) [!]

Anyway, as you probably know, \ is the symbol for integer division in Visual Basic.  When I saw your code, I half-expected you to tell me that that symbol had been added to WinBatch (in the last 9 years) and that it wasn't a typo...

FWIW, Using the forward slash (\) for division in a WinBatch script still results in a "3054: Unrecognizable item found on line" error.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

JTaylor

All I can tell you is that when I run the above I get zero.

Jim

snowsnowsnow

QuoteFWIW, Using the forward slash (\) ...

ITYM "backslash".

Actually, I'm guessing you are being a stickler for correctness, since, technically, an argument can be made that that *is* a forward slash.  But common usage is to call it a backslash.  That's just the way it is.

td

As far as I known backslash is the correct term for the glyph '\'.  What can I say?  I was thinking one thing and type another.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

stanl

Quote from: td on September 13, 2015, 08:16:27 PM
As far as I known backslash is the correct term for the glyph '\'.  What can I say?  I was thinking one thing and type another.

depends on if you are left or right-handed

snowsnowsnow

Quote from: td on September 13, 2015, 08:16:27 PM
As far as I known backslash is the correct term for the glyph '\'.  What can I say?  I was thinking one thing and type another.

Actually, the theory is that since English text flows from left to right and top to bottom, it makes sense that something (\) that flows down from left to right is "forward".

Similarly, something (/) that flows "backwards" (down from right to left - or, equivalently, up from left to right) would be called a "backslash".

But as I said, this does not match common usage.  But I have seen this argument advanced.

td

Quote from: snowsnowsnow on September 14, 2015, 06:15:25 AM

Actually, the theory is that since English text flows from left to right and top to bottom, it makes sense that something (\) that flows down from left to right is "forward".

Similarly, something (/) that flows "backwards" (down from right to left - or, equivalently, up from left to right) would be called a "backslash".

But as I said, this does not match common usage.  But I have seen this argument advanced.

Actually, I have very briefly perused a discussion on the topic, but it just reminded me of one of the famous tales of the Irish writer Jonathon Swift.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade