9 Replies Latest reply on Jun 9, 2006 4:53 PM by Newsgroup_User

    getProp

    JamieCrow
      When I use this code:

      repeat with index = 1 to loadList1.count
      thePropertyName=loadList1.getPropAt(index)
      set thePropertyName=getProp(loadList1, string(thePropertyName))
      end repeat

      it doesn't come up with an error. However the value of the property I'm setting in this script remains void. Can you use a variable as the proeprty name when using getProp?

      Thanks.
        • 1. Re: getProp
          Level 7
          I think your problem lies in the second line of the repeat loop. Why are you
          setting the value of your variable thePropertyName again, after setting it
          in the first line? I bet you really want to set something else here. Also
          you sould not be changing the symbol into a string. getProp take a symbol as
          the second parameter.


          "JamieCrow" <webforumsuser@macromedia.com> wrote in message
          news:e6buq6$9n7$1@forums.macromedia.com...
          > When I use this code:
          >
          > repeat with index = 1 to loadList1.count
          > thePropertyName=loadList1.getPropAt(index)
          > set thePropertyName=getProp(loadList1, string(thePropertyName))
          > end repeat
          >
          > it doesn't come up with an error. However the value of the property I'm
          > setting in this script remains void. Can you use a variable as the
          proeprty
          > name when using getProp?
          >
          > Thanks.
          >


          • 2. Re: getProp
            Level 7
            What is it that you want to achieve here?

            From the code that you show, it looks like you want to extract the value
            of each property in the list. Is this correct?

            If that's the case then you don't need to iterate through the list to
            extract the property names. You can just do this:

            repeat with index = 1 to loadList1.count
            thePropertyName=getAt(loadList1,index)
            end repeat

            If you want something else then please explain.

            If you want to keep your current method then you don't need, or want, to
            use the string function on the property names in the list. You can just
            use the property name itself.

            I don't know why you are getting a value of void at either step. It may
            be that the list is out of scope or that it contains nothing. Normally
            Lingo will throw an error if it doesn't recognize the reference to
            anything in the function. So if the list loadList1 was out of scope, you
            would get an error complaining about the getPropAt() function.

            --
            Rob
            _______
            Rob Dillon
            Adobe Community Expert
            http://www.ddg-designs.com
            412-243-9119

            http://www.macromedia.com/software/trial/
            • 3. Re: getProp
              JamieCrow Level 1
              Hi, Thanks for your response. You're right the problem lies in the second bit of code

              set thePropertyName=getProp(loadList1, thePropertyName)

              This code lies in a parent script. I'm trying to set the properies of the child by first reteiving the property names from a list, and then setting their values.


              the list looks like this:

              ["htOfTopOfDpcAboveFinalGroundLevelOrSlab1": 0.300, "modelPosition1": vector( 93.939, -341.822, 120.588 ), "modelRotation1": 0, "categorycount1": 1, "ModelName1": "Exterior Wall 1", "modelType1": "Exterior Wall", "modelHeight1": 1.000, "modelLength1": 245.173, "modelWidth1": 1.000, "modelNumber1": 1] ETC


              I'm trying to make it so that I don't need to do this:


              set overallWidthOfWallBelowGround=getProp(loadList1, #"overallWidthOfWallBelowGround")
              set cavityWidthBelowGround=getProp(loadList1, #"cavityWidthBelowGround")
              set blockworkPlastered=getProp(loadList1, #"blockworkPlastered")
              set plasteringBlockworkDecorated=getProp(loadList1, #"plasteringBlockworkDecorated")
              set numberOfSkirtingBoards=getProp(loadList1, #"numberOfSkirtingBoards")
              set primeSkirtingBoards=getProp(loadList1, #"primeSkirtingBoards")

              ETC


              I think the problem is that I can't use a variable as a property name.
              • 4. Re: getProp
                Level 7
                You can use a variable as a property name with the Symbol function

                symbol(yourVariableName)


                • 5. Re: getProp
                  Level 7
                  so where you have code like

                  #"overallWidthOfWallBelowGround"

                  you should be using

                  symbol("overallWidthOfWallBelowGround")


                  • 6. Re: getProp
                    Level 7
                    or just
                    #overallWidthOfWallBelowGround

                    --
                    Craig Wollman
                    Word of Mouth Productions

                    phone 212 928 9581
                    fax 212 928 9582
                    159-00 Riverside Drive West #5H-70
                    NY, NY 10032
                    www.wordofmouthpros.com


                    "Dave C" <private@email.com> wrote in message
                    news:e6c9fh$n08$1@forums.macromedia.com...
                    > so where you have code like
                    >
                    > #"overallWidthOfWallBelowGround"
                    >
                    > you should be using
                    >
                    > symbol("overallWidthOfWallBelowGround")
                    >
                    >


                    • 7. Re: getProp
                      Level 7
                      I guess I do not understand what Jamie is trying to achieve. It seems like
                      he is trying to automatically set the value of a bunch of variables, without
                      explicity having a seperate line of code for each one. So if we take a
                      simple example of a list that looked like

                      ["a":1,"b":2]

                      he wants to loop through the list so that a variable called a gets set to
                      the value of one, a variable b gets set to 2, etc. I don't understand why
                      you wouldn't just refer to the properties of the list directly. Director can
                      not dynamically create variables (at runtime) anyway, can it?


                      • 8. Re: getProp
                        Level 7
                        I agree and I'm equally confused.


                        --
                        Craig Wollman
                        Word of Mouth Productions

                        phone 212 928 9581
                        fax 212 928 9582
                        159-00 Riverside Drive West #5H-70
                        NY, NY 10032
                        www.wordofmouthpros.com


                        "Dave C" <private@email.com> wrote in message
                        news:e6cd2c$rbf$1@forums.macromedia.com...
                        >I guess I do not understand what Jamie is trying to achieve. It seems like
                        > he is trying to automatically set the value of a bunch of variables,
                        > without
                        > explicity having a seperate line of code for each one. So if we take a
                        > simple example of a list that looked like
                        >
                        > ["a":1,"b":2]
                        >
                        > he wants to loop through the list so that a variable called a gets set to
                        > the value of one, a variable b gets set to 2, etc. I don't understand why
                        > you wouldn't just refer to the properties of the list directly. Director
                        > can
                        > not dynamically create variables (at runtime) anyway, can it?
                        >
                        >


                        • 9. Re: getProp
                          Level 7
                          On Fri, 09 Jun 2006 18:01:44 GMT, Dave C posted in macromedia.director.lingo:

                          > Director can
                          > not dynamically create variables (at runtime) anyway, can it?

                          There is a way, but before I mention it, I think we should wait and see if
                          Jamie really needs to do it. As you say, a property list is already set up
                          easy access via the properties.

                          Jamie?


                          --
                          Mark A. Boyd
                          Keep-On-Learnin' :)