tree code error

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • GoOgLe
    Forum Member
    • Mar 2007
    • 452

    tree code error

    it seemed to b right but i get the error in the image... when i click in tree object where there is no node i get this error...

    Code:
    seleccionado = Tree.GetSelectedNode("Tree1");
    if seleccionado ~= nil then
    infodelarbol = Tree.GetNode("Tree1", seleccionado);
    if infodelarbol.Data ~= "" then
    		IExplorer.Navigate("Plugin1", infodelarbol.Data);
    		Input.SetText("AdressBar", infodelarbol.Data);
    		else
    end
    end


    and when i use that code it loads the first node of tree object, if i click somewhere that doesnt have a node in tree object !!!

    Code:
    seleccionado = Tree.GetSelectedNode("Tree1");
    if seleccionado ~= "" then
    infodelarbol = Tree.GetNode("Tree1", seleccionado);
    if infodelarbol.Data ~= "" then
    		IExplorer.Navigate("Plugin1", infodelarbol.Data);
    		Input.SetText("AdressBar", infodelarbol.Data);
    		else
    end
    end
    Last edited by GoOgLe; 02-27-2009, 04:47 AM.
  • jassing
    Indigo Rose Customer
    • Jan 2001
    • 3124

    #2
    from the help on Tree.GetNode():

    If no data exists, or an error occurs, nil will be returned. You can use Application.GetLastError to determine whether this action failed, and why.

    I find that no mater what you're doing, if a function returns a table always check for it to be a table & not nil..

    In otherwords; do something like this:

    Code:
    infodelarbol = Tree.GetNode("Tree1", seleccionado);
    if infodelarbol and type("infodelarbol") == "table" then

    Comment

    • GoOgLe
      Forum Member
      • Mar 2007
      • 452

      #3
      thanks alot jassing

      i tried that but it didnt work either...

      Code:
      seleccionado = Tree.GetSelectedNode("Tree1");
      if seleccionado ~= "" then
      infodelarbol = Tree.GetNode("Tree1", seleccionado);
      if infodelarbol and type("infodelarbol") == "table" then
      		IExplorer.Navigate("Plugin1", infodelarbol.Data);
      		Input.SetText("AdressBar", infodelarbol.Data);
      		else
      end
      end

      Comment

      • jassing
        Indigo Rose Customer
        • Jan 2001
        • 3124

        #4
        what error are you getting?(and on what line)

        Comment

        • GoOgLe
          Forum Member
          • Mar 2007
          • 452

          #5
          no error it just doesnt load the node to iexplorer...

          Comment

          • jassing
            Indigo Rose Customer
            • Jan 2001
            • 3124

            #6
            Originally posted by GoOgLe View Post
            no error it just doesnt load the node to iexplorer...
            "i tried that but it didnt work either" leads us to think you got the same or another error.... we can't help unless you give us information....

            My guess is that infodelarbol is not evaluating to a table...

            Try this, and report any errors, or results you get.

            Code:
            seleccionado = Tree.GetSelectedNode("Tree1");
            if seleccionado ~= "" then
              infodelarbol = Tree.GetNode("Tree1", seleccionado);
              if infodelarbol and type("infodelarbol") == "table" then
                IExplorer.Navigate("Plugin1", infodelarbol.Data);
                Input.SetText("AdressBar", infodelarbol.Data);
              else
                Dialog.Message("Error condition","'infodelarbol' not a table");
              end
            else
              Dialog.Message("Error condition","'seleccionado' is nil");
            end

            Comment

            • GoOgLe
              Forum Member
              • Mar 2007
              • 452

              #7
              thanks for ur helps jassing...

              this is the orror i get using ur code

              Comment

              • Dermot
                Indigo Rose Customer
                • Apr 2004
                • 1790

                #8
                Tree.GetSelectedNode() returns a string not a table. You just need to check that it is not nil.
                Dermot

                I am so out of here :yes

                Comment

                • jassing
                  Indigo Rose Customer
                  • Jan 2001
                  • 3124

                  #9
                  (no need to post here & send me a PM)

                  Then your call to Tree.GetSelectedNode() has failed.
                  Use Application.GetLastError() to determine why.


                  From the help file:

                  Returns
                  (string) A string containing the selected item's node index or an empty string ("") if an error occurs. You can use Application.GetLastError to determine whether this action failed, and why.

                  Comment

                  • Dermot
                    Indigo Rose Customer
                    • Apr 2004
                    • 1790

                    #10
                    This will always return false because it is never going to be a table.

                    Code:
                    if infodelarbol and type("infodelarbol") == "table" then
                    Dermot

                    I am so out of here :yes

                    Comment

                    • jassing
                      Indigo Rose Customer
                      • Jan 2001
                      • 3124

                      #11
                      Originally posted by Dermot View Post
                      This will always return false because it is never going to be a table.

                      Code:
                      if infodelarbol and type("infodelarbol") == "table" then
                      So the help file is wrong? (or have I been looking at it too long?)

                      table Tree.GetNode( string ObjectName, string NodeIndex )

                      Comment

                      • Dermot
                        Indigo Rose Customer
                        • Apr 2004
                        • 1790

                        #12
                        Sorry my fault, I thought we were talking about Tree.GetSelectedNode() which returns a string. Tree.GetNode() returns a table so you are right. Just ignore me.
                        Dermot

                        I am so out of here :yes

                        Comment

                        • GoOgLe
                          Forum Member
                          • Mar 2007
                          • 452

                          #13
                          here is the apz... i tried Application.GetLastError() and it said no node selected !!!
                          Attached Files

                          Comment

                          • Dermot
                            Indigo Rose Customer
                            • Apr 2004
                            • 1790

                            #14
                            OK this is all you need. The On Select event returns the selected index so you don't need to find out what node is selected.

                            Code:
                            local infodelarbol = Tree.GetNode("Tree1", e_NodeIndex);
                            
                            if infodelarbol then
                            	IExplorer.Navigate("Plugin1", infodelarbol.Data);
                            	Input.SetText("Input1", infodelarbol.Data);
                            end
                            Dermot

                            I am so out of here :yes

                            Comment

                            Working...
                            X