Help over XML.GetValue

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • DoveBirkoff
    Forum Member
    • Jul 2008
    • 36

    Help over XML.GetValue

    Code:
    if e_ID > 3000 then
    	urlID=e_ID-3000
    	tbURL = XML.GetValue("bookmarks/site:"..urlID.."/url");
    
       Input.SetText("input_TEST", tbURL);
    
    end
    This is the content of bookmarks.XML:

    <bookmarks>
    <site>
    <name>Carrera</name>
    <url>"AutoPlay\\Plugins\\TEMPLATES\\ID201_01_TIT.t xt"</url>
    </site>
    </bookmarks>

    Note: ID201_01_TIT.txt contains text to be shown on a Input-box
    This text if not displayed.

    Question 1: Is not possible use : Input.SetText("input_TEST", tbURL) when tbURL is gets from a XML file?

    This tbURL should store the value: "AutoPlay\\Plugins\\TEMPLATES\\ID201_01_TIT.tx t" (as example).

    So why using Input.SetText("input_TEST", tbURL) does not work?


    Thanks in advance guys
    Dove
    Last edited by DoveBirkoff; 08-10-2008, 01:48 PM.
  • RizlaUK
    Indigo Rose Customer
    • May 2006
    • 5552

    #2
    Code:
    urlID=e_ID-3000
    urlID = 0, you are subtracting the value of e_ID from e_ID leaving 0

    why subtract 3000 ?
    Embrace change in your life, you never know, it could all work out for the best

    Comment

    • DoveBirkoff
      Forum Member
      • Jul 2008
      • 36

      #3
      Hi Rizla

      As you see I'm improving a bit ! (not so much, but I managed to do a few things already).

      The reason to be subtracting 3000 is because the apps name the menus starting from 3000. so the result is the line number to seek for the tag on the XML file (I'm reusing an example called favourites.apz)

      The thing is, as previous post, that is not possible storage a relative file path in a XML file and then use it as :

      tbURL = XML.GetValue("bookmarks/site:"..urlID.."/url");
      Input.SetText("input_TEST", tbURL);

      -- When XML file
      <bookmarks>
      <site>
      <name>Carrera</name>
      <url>"AutoPlay\\Plugins\\TEMPLATES\\ID201_01_TIT .t xt"</url>
      </site>
      </bookmarks>


      Just nothing happens, when such file contains text.

      There is another way to do this?
      - Populate a menu bar from a XML file (tag NAME)
      - Read from a XML file the tag "url" which contains a path to a txt file.
      - Set text on TXT file in a Input-box.
      Last edited by DoveBirkoff; 08-10-2008, 02:51 PM.

      Comment

      • DoveBirkoff
        Forum Member
        • Jul 2008
        • 36

        #4
        Sorry, I missed a code line:

        Code:
        tbURL = XML.GetValue("bookmarks/site:"..urlID.."/url");
        rdURL = TextFile.ReadToString(tbURL);
        Input.SetText("input_TEST", rdURL)
        ;

        Comment

        • RizlaUK
          Indigo Rose Customer
          • May 2006
          • 5552

          #5
          The reason to be subtracting 3000 is because the apps name the menus starting from 3000
          yeah makes sence, im a bit slow on the uptake today, sorry


          Sorry, I missed a code line:
          so you got it working then ?
          Embrace change in your life, you never know, it could all work out for the best

          Comment

          • DoveBirkoff
            Forum Member
            • Jul 2008
            • 36

            #6
            No, I missed the line inbetween to show you.

            Just need to know if possible what I wanna do.

            Thanks

            Comment

            • RizlaUK
              Indigo Rose Customer
              • May 2006
              • 5552

              #7
              yeah its possable, and i cant really see why its not working from the code you provided

              how are you loading the xml file ?, is it loaded ? and did you check for any xml errors ?


              try it like this and post the resulting error

              Code:
              if e_ID > 3000 then
              	urlID=e_ID-3000
              	tbURL = XML.GetValue("bookmarks/site:"..urlID.."/url");
              	-- Test for error
              	error = Application.GetLastError();
              	if (error ~= XML.OK) then
              		Dialog.Message("Error", _tblErrorMessages[error], MB_OK, MB_ICONEXCLAMATION);
              	end
              
                 Input.SetText("input_TEST", tbURL);
              
              end
              Embrace change in your life, you never know, it could all work out for the best

              Comment

              • DoveBirkoff
                Forum Member
                • Jul 2008
                • 36

                #8
                The error check is set on PRELOAD event.

                Please have a look to attached project.

                The idea still:
                - Populate a menu bar from a XML file (tag "name" will contain this info)
                - Read from a XML file the tag "url" which contains a path to a txt file ("AutoPlay\\Plugins\\TEMPLATES\\ID201_01_TIT.tx t")
                - Set text on TXT file in a Input-box.


                Thanks again

                Edit: Please ignore the rest of the objects, they remain cause Im using favourites.apz project as base.
                Attached Files
                Last edited by DoveBirkoff; 08-10-2008, 04:30 PM.

                Comment

                • RizlaUK
                  Indigo Rose Customer
                  • May 2006
                  • 5552

                  #9
                  ok, after a little messing about and a few harsh words with my pc i finally found the fault(s)

                  1st, check your object names, the first letter was not a capital in the script but the object name it is, also, maybe not need but add _SourceFolder variable

                  Code:
                  if e_ID > 3000 then
                  	urlID=e_ID-3000
                  	tbURL = XML.GetValue("bookmarks/site:"..urlID.."/url");
                  	rdURL = TextFile.ReadToString(tbURL);
                  	Input.SetText("[COLOR="Red"]i[/COLOR]nput_TEST", rdURL);
                  end
                  should be

                  Code:
                  if e_ID > 3000 then
                  	urlID=e_ID-3000
                  	tbURL = XML.GetValue("bookmarks/site:"..urlID.."/url");
                  	rdURL = TextFile.ReadToString([COLOR="Red"]_SourceFolder.."\\"..[/COLOR]tbURL);
                  	Input.SetText("[COLOR="Red"]I[/COLOR]nput_TEST", rdURL);
                  end
                  2nd, remove the quotation marks and double backslash from the path in your xml file, you do not need to escape file paths held in text files, only in code
                  Code:
                  <bookmarks>
                  <site>
                  <name>Carrera</name>
                  <url>"AutoPlay\\Plugins\\TEMPLATES\\ID201_01_TIT.txt"</url>
                  </site>
                  </bookmarks>
                  should be

                  Code:
                  <bookmarks>
                  <site>
                  <name>Carrera</name>
                  <url>AutoPlay\Plugins\TEMPLATES\ID201_01_TIT.txt</url>
                  </site>
                  </bookmarks>
                  and that should fix it


                  edit, wow, that took me 45 min to debug
                  Last edited by RizlaUK; 08-10-2008, 05:18 PM.
                  Embrace change in your life, you never know, it could all work out for the best

                  Comment

                  • DoveBirkoff
                    Forum Member
                    • Jul 2008
                    • 36

                    #10
                    Still not working, now even I got a nice error on load XML file.

                    If you could have a quick look to the new attached project, in there I tried to applied the code but was no way.


                    Thanks Rizla
                    Attached Files
                    Last edited by DoveBirkoff; 08-10-2008, 06:11 PM. Reason: Misspelling

                    Comment

                    • DoveBirkoff
                      Forum Member
                      • Jul 2008
                      • 36

                      #11
                      I found already a line in the XML file bad ending:

                      <SUG></SUG

                      Changed to:
                      <SUG></SUG>

                      But still not working

                      Comment

                      • RizlaUK
                        Indigo Rose Customer
                        • May 2006
                        • 5552

                        #12
                        ok, you have a error in your xml file, the bracket in red is missing from all sections, and you have "item" one to many times in the file,

                        Code:
                        <BUG></BUG>
                        <SUG></SUG[COLOR="Red"]>[/COLOR]
                        <RID></RID>
                        heres the fixed xml code
                        Code:
                        <Menu>  
                        <item> 
                        <NAME>Career</NAME> 
                        <TIT>AutoPlay\Plugins\TEMPLATES\ID200_01_TIT.txt</TIT>
                        <REP>AutoPlay\Plugins\TEMPLATES\ID200_02_REP.txt</REP>
                        <BUG></BUG>
                        <SUG></SUG>
                        <RID></RID>
                        </item>
                        
                        <item> 
                        <NAME>Career</NAME> 
                        <TIT>AutoPlay\Plugins\TEMPLATES\ID200_01_TIT.txt</TIT>
                        <REP>AutoPlay\Plugins\TEMPLATES\ID200_02_REP.txt</REP>
                        <BUG></BUG>
                        <SUG></SUG>
                        <RID></RID>
                        </item>
                        
                        <item> 
                        <NAME>Career</NAME> 
                        <TIT>AutoPlay\Plugins\TEMPLATES\ID200_01_TIT.txt</TIT>
                        <REP>AutoPlay\Plugins\TEMPLATES\ID200_02_REP.txt</REP>
                        <BUG></BUG>
                        <SUG></SUG>
                        <RID></RID>
                        </item>
                        
                        
                        <item>
                        <NAME>Career</NAME> 
                        <TIT>AutoPlay\Plugins\TEMPLATES\ID200_01_TIT.txt</TIT>
                        <REP>AutoPlay\Plugins\TEMPLATES\ID200_02_REP.txt</REP>
                        <BUG></BUG>
                        <SUG></SUG>
                        <RID></RID>
                        </item>
                        
                        
                        </Menu>
                        also in preload, the index of the menu items is wrong, a submenu set must always start with 1, (it was starting with 4 and causeing an error)

                        Code:
                        if (error == XML.OK) then
                        	nCount = XML.Count("Menu", "item");
                        	
                        	if nCount ~= 0 then
                        		mI=4
                        		for i=1, nCount do
                        			tblMenu[1].SubMenu[[COLOR="Red"]i[/COLOR]] = {};
                        			tblMenu[1].SubMenu[[COLOR="Red"]i[/COLOR]].Text = XML.GetValue("Menu/item:"..i.."/NAME");
                        			tblMenu[1].SubMenu[[COLOR="Red"]i[/COLOR]].ID = 199+i;
                        			tblMenu[1].SubMenu[[COLOR="Red"]i[/COLOR]].Checked = false;
                        			tblMenu[1].SubMenu[[COLOR="Red"]i[/COLOR]].Enabled = true;
                        			
                        			mI=mI+1
                        		end	
                        	end
                        else    
                            Dialog.Message("Error", _tblErrorMessages[error]);
                        end
                        thats as far as i can go, the on menu code looks ok, so add your template files and test it

                        this time, it should work
                        Embrace change in your life, you never know, it could all work out for the best

                        Comment

                        • RizlaUK
                          Indigo Rose Customer
                          • May 2006
                          • 5552

                          #13
                          Originally posted by DoveBirkoff View Post
                          I found already a line in the XML file bad ending:

                          <SUG></SUG

                          Changed to:
                          <SUG></SUG>

                          But still not working

                          lol, check the whole file :yes
                          Embrace change in your life, you never know, it could all work out for the best

                          Comment

                          • DoveBirkoff
                            Forum Member
                            • Jul 2008
                            • 36

                            #14
                            I almost give up...

                            I did all those changes but does not work.


                            Thanks anyway for your support Rizla, but maybe its too much for me
                            Attached Files

                            Comment

                            • RizlaUK
                              Indigo Rose Customer
                              • May 2006
                              • 5552

                              #15
                              dont give up, your almost there :yes

                              thats my fault, i forgot one thing

                              on preload, uncomment the line shown in red, the submenu is not being created
                              Code:
                              -- Create a table containing all menu information
                              tblMenu = {};
                              tblMenu[1] ={};
                              tblMenu[1].Text = "&Bug Templates";
                              tblMenu[1].ID = 299;
                              tblMenu[1].Checked = false;
                              tblMenu[1].Enabled = true;
                              [COLOR="Red"]--tblMenu[1].SubMenu = {};[/COLOR]
                              --tblMenu[1].SubMenu[1] = {};
                              --tblMenu[1].SubMenu[1].Text = "&Add To Favourites";
                              --tblMenu[1].SubMenu[1].ID = 101;
                              --tblMenu[1].SubMenu[1].Checked = false;
                              --tblMenu[1].SubMenu[1].Enabled = true;
                              -- tblMenu[1].SubMenu[3].Text = "---";
                              -- tblMenu[1].SubMenu[3].ID = 0;
                              -- tblMenu[1].SubMenu[3].Checked = false;
                              -- tblMenu[1].SubMenu[3].Enabled = true;
                              Embrace change in your life, you never know, it could all work out for the best

                              Comment

                              Working...
                              X