Andromo - Start Making Apps - Free Signup

Announcement

Collapse
No announcement yet.

Operators as variables

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Operators as variables

    How do I assign an operator symbol like "+" to a variable without the engine thinking that I'm trying to perform a mathematical operation. I'm just needing the character "+" to be placed in particular areas throughout the program. I tried assigning it like this

    operator = +;

    but it wont compile due to the operator character. I thought I read somewhere that you can preface it with a "\" like this

    operator = \+;

    but I tried that and it didn't work either. any ideas?

    thanks

  • #2
    operator = "+"; will create a string named operator with the plus sign in there.

    If you are trying to do dynamic math then try using:

    operator = "plus";

    and the later us an if statement to act accordingly, i.e.

    if operator == "plus" then
    result = x + y;
    end

    if operator == "minus" then
    result = x - y;
    end

    And so forth, or at least that's one way to do it anyhow.

    Corey Milner
    Creative Director, Indigo Rose Software

    Comment


    • #3
      Thanks

      Corey,

      Thanks for your help again....

      Dave

      Comment


      • #4


        Corey Milner
        Creative Director, Indigo Rose Software

        Comment


        • #5
          Re: Thanks

          Originally posted by SonHouse
          Corey,

          Thanks for your help again....

          Dave
          Boy if I had a nickel for everytime someone said that here on the forums . . .
          TJ-Tigger
          "A common mistake that people make when trying to design something completely foolproof was to underestimate the ingenuity of complete fools."
          "Draco dormiens nunquam titillandus."
          Map of IR Forum Users - IR Project CodeViewer - Online Help - TiggTV - QuizEngine

          Comment


          • #6
            Pah! *You* "da man"... :o

            Corey Milner
            Creative Director, Indigo Rose Software

            Comment

            Working...
            X