Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Evaluate Variables in QtScript
Forum Updated to NodeBB v4.3 + New Features

Evaluate Variables in QtScript

Scheduled Pinned Locked Moved General and Desktop
7 Posts 3 Posters 2.1k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • W Offline
    W Offline
    walteste
    wrote on last edited by
    #1

    I am looking for a way to find out the variables in a script (QtScript).

    An example would be this formula:
    @c = a + b + 15@

    The variables I would like to find is a, b and c.

    Can someone give me a hint with this?

    1 Reply Last reply
    0
    • B Offline
      B Offline
      Buggy
      wrote on last edited by
      #2

      I think you are looking for how to solve an equation using JavaScript - something very different from evaluating script, such as the QtScript engine does.

      The problem you pose has more than one solution as well, as you can see here: "Wolfram Alpha":http://www.wolframalpha.com/input/?i=c+=+a+++b+++15 (sorry you have to enter the equation again as this forum destroys it).

      Some solutions for your equation would be
      25 = 5 + 5 + 15
      35 = 10 + 10 + 15

      and so on.

      1 Reply Last reply
      0
      • W Offline
        W Offline
        walteste
        wrote on last edited by
        #3

        Thanks for your input, but my equation was just a sample.

        What I want is as example to load this equation from a file, but I would like to find out the used variables before putting it into the script engine.

        1 Reply Last reply
        0
        • B Offline
          B Offline
          Buggy
          wrote on last edited by
          #4

          Hello,

          OK now I get it - you are not looking for variable values but variable names.

          Do you have a real-world example of what you want to achieve?

          1 Reply Last reply
          0
          • W Offline
            W Offline
            walteste
            wrote on last edited by
            #5

            I do not have a real world example, but I try to explain it more global.

            Let's assume I can get script-code in several ways (file, tcp, ...) and I want to execute this code in the script engine. Before executing the code I would like to get somehow a list of used variables.

            The question is now, how to get the list of variables?

            1 Reply Last reply
            0
            • D Offline
              D Offline
              DerManu
              wrote on last edited by
              #6

              Parse the code. Either with an own parser or by using some ECMAScript parser library. Maybe you can somehow rip out the parsing code of the QtScript module.

              1 Reply Last reply
              0
              • W Offline
                W Offline
                walteste
                wrote on last edited by
                #7

                Okay, but it seems there is no way that the QtScript could do this?

                1 Reply Last reply
                0

                • Login

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved