AdvancedHMI Software

General Category => Support Questions => Topic started by: joko markono on October 24, 2019, 04:22:42 AM

Title: Keyboard Input Negative (-) Value.
Post by: joko markono on October 24, 2019, 04:22:42 AM
Hi All,

I've read this thread:
https://www.advancedhmi.com/forum/index.php?topic=136.msg268#msg268 (https://www.advancedhmi.com/forum/index.php?topic=136.msg268#msg268)

Seems that there is no solution to input the negative value (if i don't miss anything there).

I'm setting up a page where i can always change the minimum and maximum value from the HMI.
The problem is i cannot enter negative numbers. I will get this warning: Failed to write value-Arithmetic operation resulted in an overflow.

Is there any way i can solve this problem?
Title: Re: Keyboard Input Negative (-) Value.
Post by: Archie on October 24, 2019, 06:55:20 AM
Are you using version 3.99x or 3.99y ?
Title: Re: Keyboard Input Negative (-) Value.
Post by: joko markono on October 24, 2019, 08:17:08 PM
It's 3.99y
Title: Re: Keyboard Input Negative (-) Value.
Post by: Archie on October 24, 2019, 08:40:39 PM
What negative number are you trying?
Title: Re: Keyboard Input Negative (-) Value.
Post by: joko markono on October 24, 2019, 08:45:38 PM
Any none decimal negative value. For example -6237
Title: Re: Keyboard Input Negative (-) Value.
Post by: Archie on October 24, 2019, 08:52:46 PM
I will have to setup an Omron PLC and test this. The only reason I can see that you would get that error is if you exceeded the limits of a 16 bit integer. For example -32800
Title: Re: Keyboard Input Negative (-) Value.
Post by: joko markono on October 24, 2019, 08:56:24 PM
i appreciate that. my number will not reach -XXXXX.
FYI, I got the error even before i connect to PLC.
Title: Re: Keyboard Input Negative (-) Value.
Post by: Archie on October 24, 2019, 09:06:19 PM
Does this also happen if you use a BasicLabel and set the PLCAddressKeypad ?

Do you have anything in the ScaleFactor property?
Title: Re: Keyboard Input Negative (-) Value.
Post by: joko markono on October 24, 2019, 09:31:03 PM
Yes, same thing. The scale value for the basic label is 1.
Title: Re: Keyboard Input Negative (-) Value.
Post by: joko markono on November 01, 2019, 04:31:27 AM
I'm just following up if there is any update on this?
Title: Re: Keyboard Input Negative (-) Value.
Post by: Godra on November 01, 2019, 02:29:44 PM
Can you explain what driver you are using, what are those controls in the first picture you posted (more details)?

What does this mean:

I got the error even before i connect to PLC.
Title: Re: Keyboard Input Negative (-) Value.
Post by: joko markono on November 03, 2019, 09:55:06 PM
I'm using Omron serial hostlink protocol.
that statement means, before I connect the serial port to my PLC, there's already an error warning when I enter -ve value.
Title: Re: Keyboard Input Negative (-) Value.
Post by: Archie on November 03, 2019, 11:10:26 PM
The problem comes from this code:
Code: [Select]
        '**************************************
        '* Convert an integer value to Hexadecimal
        '**************************************
        Public Shared Function IntToHex(ByVal data As Integer) As String
            If data < 16 Then
                Return "000" & String.Format("{0:X}", data)
            ElseIf data < 256 Then
                Return "00" & String.Format("{0:X}", data)
            ElseIf data < 4096 Then
                Return "0" & String.Format("{0:X}", data)
            Else
                Return String.Format("{0:X}", data)
            End If
        End Function

It is supposed to return 4 characters representing the hex value, but a negative value doesn't work.

I'll try to look for a fix later, but if anyone can suggest a fix in the mean time, I'll give it a go.
Title: Re: Keyboard Input Negative (-) Value.
Post by: Godra on November 04, 2019, 01:10:49 AM
Maybe this:

Code: [Select]
    '**************************************
    '* Convert an integer value to Hexadecimal
    '**************************************
    Public Shared Function IntToHex(ByVal data As Integer) As String
        If data < 0 Then
            Return Hex(data).Substring(4) 'or Hex(data).TrimStart("F").PadLeft(4, "F"c)
        Else
            Return Hex(data).PadLeft(4, "0"c)
        End If
    End Function

Title: Re: Keyboard Input Negative (-) Value.
Post by: Archie on November 04, 2019, 08:09:07 PM
I'm getting an error about the function Hex

Do you know where that is coming from?
Title: Re: Keyboard Input Negative (-) Value.
Post by: Godra on November 04, 2019, 08:12:26 PM
It's a member of Microsoft.VisualBasic.Conversion.
Title: Re: Keyboard Input Negative (-) Value.
Post by: Archie on November 04, 2019, 08:19:55 PM
I removed all of the references to Microsoft.VisualBasic, so I'll try this:

Code: [Select]
        Public Shared Function IntToHex(ByVal data As Integer) As String

            If data < 0 Then
                Return data.ToString("X").Substring(4)
            Else
                Return data.ToString("X").PadLeft(4, "0"c)
            End If
        End Function
Title: Re: Keyboard Input Negative (-) Value.
Post by: Godra on November 04, 2019, 08:30:16 PM
That seems to work properly as well.
Title: Re: Keyboard Input Negative (-) Value.
Post by: joko markono on November 21, 2019, 08:26:52 PM
I'm sorry where should i access to modify the code please
Title: Re: Keyboard Input Negative (-) Value.
Post by: Godra on November 22, 2019, 12:09:59 AM
That seems to be inside the dll file so you will have to wait for Archie to do it.
Title: Re: Keyboard Input Negative (-) Value.
Post by: joko markono on March 26, 2020, 03:47:59 AM
i just want to keep this link here for reference:
https://www.advancedhmi.com/forum/index.php?topic=764.msg3648#msg3648
Title: Re: Keyboard Input Negative (-) Value.
Post by: joko markono on March 30, 2020, 04:36:11 AM
this problem is solved with v399y Beta35