8 Replies Latest reply on Aug 25, 2009 11:02 AM by anjemalo

    Add field of database to a list

    anjemalo Level 1

      Hello:

      I have three fields in a table (database) with the following data:

       

      Name-> "John" 

      LastName-> "Wilson"

      Id -> 18

       

      Name-> "Andrew"

      LastName-> "Spielberg"

      Id->: 21

       

      etc, etc...

       

      I need these data in a property list like this:

       

      [Name: "John" , LastName: "Wilson", Id : 18],

      [Name: "Andrew", LastName: "Spielberg", Id : 21]

       

      Can you help me to get this please?

      Thank you very much

        • 1. Re: Add field of database to a list
          Chunick Level 3

          more information is needed:

           

          1. Is this shockwave or a standalone executable?

          2. Is the database located on a server somewhere or is it local?

          3. What version of Director are you running?

          • 2. Re: Add field of database to a list
            anjemalo Level 1

            Thank you very much.

             

            Is for Projector.

            Director 11.5

            Database is local.

             

            Is not a problem about database fields. I only need to work with list of lists.

            First.-   I need to add data in a property list like myList

            Second .- Search inside the list combining two fields. #User and #password and find if exist in the list.

             

             

            this is my list (I need to get this kind of list first and then search through):

             

            myList= [[#User: "Joseph", #password: "1234", #Country: "Spain"], \

                          [#User: "Spielberg", #password: "2345", #Country: "U.K."], \

                          [#User: "Andersen", #password: "3456", #Country: "France"]]

             

            Many thanks

            • 3. Re: Add field of database to a list
              Chunick Level 3

              anjemalo wrote:

               

              Thank you very much.

               

              Is for Projector.

              Director 11.5

              Database is local.

               

              Is not a problem about database fields. I only need to work with list of lists.

              First.-   I need to add data in a property list like myList

              Second .- Search inside the list combining two fields. #User and #password and find if exist in the list.

               

               

              this is my list (I need to get this kind of list first and then search through):

               

              myList= [[#User: "Joseph", #password: "1234", #Country: "Spain"], \

                            [#User: "Spielberg", #password: "2345", #Country: "U.K."], \

                            [#User: "Andersen", #password: "3456", #Country: "France"]]

               

              Many thanks

              ok, so let's take a step back and ask this: Do you have a way to communicate with the database yet? It doesn't sound like you do. This usually requires an Xtra. The Mile High Table of Products lists many Xtras that can communicate with databases: http://www.deansdirectortutorials.com/MileHighTable/

               

              once you find the right Xtra for your needs, it typically will return a property list based off your query so after that it should be no problem to get the information you require.

              • 4. Re: Add field of database to a list
                anjemalo Level 1

                Do you have a way to communicate with the database yet?.   Yes I have it.

                 

                But forget the database. I don't need database for this.

                 

                I only need to work with list of lists.

                First.-   I need to add data in a property list.

                           How to get a list like myList?

                Second .- Search inside the list combining two fields. #User and #password and find if exist in the list.

                 

                 

                this is my list (I need to get this kind of list first and then search through):

                 

                myList= [[#User: "Joseph", #password: "1234", #Country: "Spain"], \

                              [#User: "Spielberg", #password: "2345", #Country: "U.K."], \

                              [#User: "Andersen", #password: "3456", #Country: "France"]]

                 

                thanks again.

                • 5. Re: Add field of database to a list
                  Mike Blaustein Level 4

                  --declare the main list

                  myList=[]

                  --make a proplist for the data

                  user1=[:]

                  --add in the actual data

                  user1[#User]="Joseph"

                  user1[#password]="1234"

                  user1[#Country]="Spain"

                  --put this data into the main list

                  myList.append(user1)

                  --add the next user

                  user2=[:]

                  user2[#User]="Spielburg"

                  user2[#password]="2345"

                  user2[#Country]="U.K."

                  myList.append(user2)

                  --etc

                   

                  put myList

                  -- [[#User: "Joseph", #password: "1234", #Country: "Spain"],[#User: "Spielberg", #password: "2345", #Country: "U.K."]]

                   

                  put myList[1]

                  -- [#User: "Joseph", #password: "1234", #Country: "Spain"]

                   

                  put myList[1][#User]

                  -- "Joseph"

                  • 6. Re: Add field of database to a list
                    anjemalo Level 1

                    Thank you very much.

                    That is OK.

                     

                    The second question was:

                    Search inside the list.

                    for example:

                    if I want to find  "Joseph",  How to do it?

                    or If I want to find   #User,   How to do it?

                    • 7. Re: Add field of database to a list
                      Mike Blaustein Level 4

                      put myList[1][#User]

                      -- "Joseph"

                       

                      put myList[1].getOne("Joseph")

                      -- #user

                       

                      repeat with i=1 to myList.count

                        thisUser=myList[i]

                        put thisUser

                        repeat with j=1 to thisUser.count

                           put thisUser.getPropAt(j)

                           put thisUser[j]

                        end repeat

                      end repeat

                       

                      -- [#user: "Joseph", #password: "1234", #Country: "Spain"]
                      -- #user
                      -- "Joseph"
                      -- #password
                      -- "1234"
                      -- #Country
                      -- "Spain"
                      -- [#user: "Spielberg", #password: "2345", #Country: "U.K."]
                      -- #user
                      -- "Spielberg"
                      -- #password
                      -- "2345"
                      -- #Country
                      -- "U.K."

                      • 8. Re: Add field of database to a list
                        anjemalo Level 1

                        Thank you very much and best regards.