WinBatch® Technical Support Forum

All Things WinBatch => WinBatch => Topic started by: JTaylor on September 12, 2015, 03:42:58 PM

Title: Decimals
Post by: JTaylor on September 12, 2015, 03:42:58 PM
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)

Title: Re: Decimals
Post by: snowsnowsnow on September 12, 2015, 04:51:39 PM
I assume the \ (backslash) is a typo.

When I fixed that, I get .05
which is, I think the right answer for 54/1080
Title: Re: Decimals
Post by: JTaylor on September 12, 2015, 05:09:26 PM
Well...that is a few hours I won't get back :-[

Always something simple.  Thanks.


Jim
Title: Re: Decimals
Post by: 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...
Title: Re: Decimals
Post by: JTaylor on September 12, 2015, 05:38:35 PM
No.  Didn't do anything with ErrorMode.   Thanks again.

Jim
Title: Re: Decimals
Post by: td on September 13, 2015, 08:34:14 AM
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.
Title: Re: Decimals
Post by: JTaylor on September 13, 2015, 10:07:22 AM
All I can tell you is that when I run the above I get zero.

Jim
Title: Re: Decimals
Post by: snowsnowsnow on September 13, 2015, 06:44:36 PM
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.
Title: Re: Decimals
Post by: 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.
Title: Re: Decimals
Post by: stanl on September 14, 2015, 05:10:47 AM
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
Title: Re: Decimals
Post by: snowsnowsnow on September 14, 2015, 06:15:25 AM
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.
Title: Re: Decimals
Post by: td on September 14, 2015, 06:45:25 AM
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.