val() issue

Product Compare Forums Multi-Edit Support val() issue

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #1286
    MewUser
    Participant

    Using MEW 9.0e on Windows 2000 Professional.
    Passing in a string value greater than ‘FF’ causes this function to not respond with the anticipated value.
    For example,
    string is set to ’10B’, the result of this function is 10.

    I do not see any restrictions in the help format as listed below:
    Val( result, string ) integer function
    Converts string to an integer value, stored in result.

    RETURNS: 0 if no errors are detected, otherwise returns the position in the string where the error occurred. If string is empty (zero length) then 0 will be returned, and result will be set to 0.

    example:

    if ( Val(Temp_Value, ‘1000’) == 0 )
    New_Value = Old_Value + Temp_Value;
    Additional Resources:

    String Manipulation Function List

    Any suggestions?
    Thanks

    #4613
    tlscales
    Participant

    The problem isn’t that the value is greater than 0xFF, it’s that val() is treating the string as an ASCII representation of a decimal rather than hexidecimal value and stops converting when it finds a digit other than 0-9(‘B’ in this case). I’m not sure what would happen if you tried using “0x10B” as your string instead.

    #4641
    ReidSweatman
    Participant

    And the answer is, “it would work.” In CMac, hexadecimal numbers must begin with either $ or 0x.

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.