Multiplying variables from edit fields.

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • kraigyb
    Indigo Rose Customer
    • Jul 2003
    • 55

    Multiplying variables from edit fields.

    Hi,
    I'm attempting to multiply two integers stored in variables. It works properly if I set the variables directly, but if one variable is set to the value of an edit field, the edit field variable is always treated as a string.

    Examples:
    (Correct)
    %NumberA% = "3"
    %NumberB% = "4"
    %NumberA% * %NumberB% = "12"

    (Incorrect)
    %NumberA% = "3"
    %NumberB% = EditFieldObject(Text1).GetText)
    %NumberA% * %NumberB% = "4 4 4"

    I'm using a digits-only input mask on the edit field to make sure the value is a number, and I've even tried the Get Delimited String, but even that variable is treated as a string.
    Any way around this?

    Thanks,
    Craig
  • Lorne
    Indigo Rose Staff Member
    • Feb 2001
    • 2729

    #2
    Re: Multiplying variables from edit fields.

    Yes. Remove the space after the 4 in the Text1 object. [img]/ubbthreads/images/icons/smile.gif[/img]

    Your result makes it look to me like the Text1 object has a space after the 4. This makes %numberB% an alphanumeric, instead of just numeric, string. The expression interpreter sees this as (number) * (string) which in this case will repeat the string 3 times.

    What input mask are you using? Make sure it doesn't have a space at the end.

    To confirm my theory, use a Dialog.Message action to display the contents of %NumberB% with a single character in front and behind it, like so:

    "%NumberB%"

    Note that any character will do, you could also use:

    _%NumberB%_

    That way, you can "see" whether there is a space after the 4.
    --[[ Indigo Rose Software Developer ]]

    Comment

    • kraigyb
      Indigo Rose Customer
      • Jul 2003
      • 55

      #3
      Re: Multiplying variables from edit fields.

      That was it!

      My input mask is "####" so there were probably 3 spaces after the 4. All I need to do then is remove the padded spaces created by the input mask:

      %NumberB% = %NumberB% - " "

      Thank you for the quick response!
      Craig

      Comment

      • Lorne
        Indigo Rose Staff Member
        • Feb 2001
        • 2729

        #4
        Re: Multiplying variables from edit fields.

        You're welcome.

        BTW, nice use of string substraction there. [img]/ubbthreads/images/icons/smile.gif[/img] You really have a good grasp of the AutoPlay expression language.
        --[[ Indigo Rose Software Developer ]]

        Comment

        Working...
        X