Previous Thread
Next Thread
Print Thread
Page 17 of 116 1 2 15 16 17 18 19 115 116
Joined: Mar 2008
Posts: 1,049
Very Senior Member
OP Offline
Very Senior Member
Joined: Mar 2008
Posts: 1,049
queryXML is very a nice function!
I already implementing in templates for get new informations!
But it's make a new call for every new system refresh....
It's possible to create a new cache for this?
For every $ID$ loaded or for a load for all systems (a new call when QMC2 is started)
That can speed the things up wink


"A user interface is like a joke. If you have to explain it, it's not that good."
Joined: May 2008
Posts: 4,930
Likes: 24
Q
Very Senior Member
Offline
Very Senior Member
Q
Joined: May 2008
Posts: 4,930
Likes: 24
The XML query is already operating on the cached data, there's few you can do to speed this up, unfortunately. I could only restrict the XML query to the data relevant for the current system (ID), which should be faster, but the data still needs to be searched first. (EDIT: this has been implemented now, see below!)

Last edited by qmc2; 02/17/13 12:54 PM.

A mind is like a parachute. It doesn't work unless it's open. [Frank Zappa]
Joined: May 2008
Posts: 4,930
Likes: 24
Q
Very Senior Member
Offline
Very Senior Member
Q
Joined: May 2008
Posts: 4,930
Likes: 24
OK, that's in SVN r4716 smile! You can use 'qmc2NEO.queryLocalXml(id, query)' now to restrict the XQuery (query) to a single game/machine (id)... everything else is the same as in the global query.

Example:

Code:
<script>
        if ( "$EMULATOR_TYPE$" == "MESS" ) {
                document.write("<h3>" + tr('Software lists') + "</h3>");
                if ( qmc2NEO.queryLocalXml("$ID$", "doc($xmlDocument)//machine/softwarelist/@name/string()") ) {
                        var result = qmc2NEO.getXmlResult();
                        if ( result.length > 0 ) {
                                document.write("<p>" +  tr('Associated software-lists:'));
                                for (var i = 0; i < result.length; i++)
                                        document.write((i > 0 ? ", " : " ") + result[i]);
                                document.write("</p>");
                        } else
                                document.write("<p>" + tr('This system has no associated software-lists.') +"</p>");
                } else
                        document.write(tr('XML query error!'));
        }
</script>

I'm reusing a slightly modified function from the ROMAlyzer to accomplish this. There's implicit internal indexing whenever a game/machine is queried, so subsequent queries of the same game's/machine's XML data will be faster. This is much faster than a global query and should thus also be usable for bigger data as in MAME and UME.


A mind is like a parachute. It doesn't work unless it's open. [Frank Zappa]
Joined: May 2008
Posts: 4,930
Likes: 24
Q
Very Senior Member
Offline
Very Senior Member
Q
Joined: May 2008
Posts: 4,930
Likes: 24
Originally Posted By qmc2
Also, I could just add a switch to negate the pattern match, regardless of the pattern syntax (so include what's matched / not matched).

This has been added in SVN r4719 (see here). I'll add support for switching the pattern-syntax later.


A mind is like a parachute. It doesn't work unless it's open. [Frank Zappa]
Joined: Mar 2008
Posts: 1,049
Very Senior Member
OP Offline
Very Senior Member
Joined: Mar 2008
Posts: 1,049
Thanks for this!
I just having some troubles with that yet :p...
Originally Posted By qmc2
OK, that's in SVN r4716 smile! You can use 'qmc2NEO.queryLocalXml(id, query)' now to restrict the XQuery (query) to a single game/machine (id)... everything else is the same as in the global query.

Example:

Code:
<script>
        if ( "$EMULATOR_TYPE$" == "MESS" ) {
                document.write("<h3>" + tr('Software lists') + "</h3>");
                if ( qmc2NEO.queryLocalXml("$ID$", "doc($xmlDocument)//machine/softwarelist/@name/string()") ) {
                        var result = qmc2NEO.getXmlResult();
                        if ( result.length > 0 ) {
                                document.write("<p>" +  tr('Associated software-lists:'));
                                for (var i = 0; i < result.length; i++)
                                        document.write((i > 0 ? ", " : " ") + result[i]);
                                document.write("</p>");
                        } else
                                document.write("<p>" + tr('This system has no associated software-lists.') +"</p>");
                } else
                        document.write(tr('XML query error!'));
        }
</script>

I'm reusing a slightly modified function from the ROMAlyzer to accomplish this. There's implicit internal indexing whenever a game/machine is queried, so subsequent queries of the same game's/machine's XML data will be faster. This is much faster than a global query and should thus also be usable for bigger data as in MAME and UME.


I tried:
Code:
   if (qmc2NEO.queryLocalXml("$ID$", "doc($xmlDocument)//machine/driver/@emulation/string()") ) 
   {
      tdCor("Emulation", qmc2NEO.getXmlResult());         
   } 
   
   else
      document.write(tr('XML query error!'));

But I don't know why, it's giving me a runtime error in Windows7 x86 :p
I'm doing something wrong?

but:
Code:
if (qmc2NEO.queryXml("doc($xmlDocument)//machine[@name = \"$ID$\"]/driver/@emulation/string()") ) 
   {
      tdCor("Emulation", qmc2NEO.getXmlResult());         
   } 
   
   else
      document.write(tr('XML query error!'));

Works :p

If I don't did nothing wrong, I suspect that may the new LocalXml have a bug on windows...

Ps.: r4723


"A user interface is like a joke. If you have to explain it, it's not that good."
Joined: May 2008
Posts: 4,930
Likes: 24
Q
Very Senior Member
Offline
Very Senior Member
Q
Joined: May 2008
Posts: 4,930
Likes: 24
Well, the example shown above as used in the default / example template works fine (tried it?), so I'm not sure why it should be causing a run-time error for you...

EDIT: also, the driver's emulation status is already available through macros smile ($DRIVER_STATUS$ and $DRIVER_STATUS_UT$).

Last edited by qmc2; 02/19/13 08:31 AM.

A mind is like a parachute. It doesn't work unless it's open. [Frank Zappa]
Joined: May 2008
Posts: 4,930
Likes: 24
Q
Very Senior Member
Offline
Very Senior Member
Q
Joined: May 2008
Posts: 4,930
Likes: 24
I've now also tried it on Windows 7 x64, which works fine. However, it seems that you're probably working with the old XML cache which didn't include the DTD. If that's the case, I can imagine that queryLocalXml() may crash (which I should try to avoid, of course).

So please make sure that the XML cache gets recreated before you try again! Either start QMC2 with the -cc command line switch or clear the cache through the menu (Tools -> Clean up -> Clear ALL emulator caches) and reload/restart.


A mind is like a parachute. It doesn't work unless it's open. [Frank Zappa]
Joined: May 2008
Posts: 4,930
Likes: 24
Q
Very Senior Member
Offline
Very Senior Member
Q
Joined: May 2008
Posts: 4,930
Likes: 24
PS: It's really important that you prefer to use the "local" query since it's so much faster than the "global" one. That's why I'm insisting smile.

The global XML query may still be useful if you would like to add some functionality that's not in QMC2 yet, like certain queries you may offer to be executed on-demand (things like remax's request to get a list of games/machines that have software-lists associated with them, for example). But you should only use global queries in case of MESS!


A mind is like a parachute. It doesn't work unless it's open. [Frank Zappa]
Joined: Mar 2008
Posts: 1,049
Very Senior Member
OP Offline
Very Senior Member
Joined: Mar 2008
Posts: 1,049
Originally Posted By qmc2
Well, the example shown above as used in the default / example template works fine (tried it?), so I'm not sure why it should be causing a run-time error for you...

EDIT: also, the driver's emulation status is already available through macros smile ($DRIVER_STATUS$ and $DRIVER_STATUS_UT$).

Emulation status is different than Driver status for MESS/MAME/UME (driver is general. sometimes, Emulation is good and Driver impefect, for example).
The problem, I fixed.
I forget to clean the caches before use the new features :p

Ps.: LocalXML is much faster! I liked a lot!!! Thanks!


"A user interface is like a joke. If you have to explain it, it's not that good."
Joined: Mar 2008
Posts: 1,049
Very Senior Member
OP Offline
Very Senior Member
Joined: Mar 2008
Posts: 1,049
The QueryXML and QueryLocalXML functions are very good.
But they have just a little problem: it returns a result listed in alphabetically order.

And that's a big problem for me.
I'll show why!

Please, look the normal result for a hypothetical search with -listxml:


Ok!

To show that information, I create a function:
Code:
      /*CPU*/   
      if (qmc2NEO.queryLocalXml("$ID$", "doc($xmlDocument)//machine/chip/@name/string()")) 
      {
         var result = qmc2NEO.getXmlResult(); 
         var len = result.length;        

         qmc2NEO.queryLocalXml("$ID$", "doc($xmlDocument)//machine/chip/@tag/string()");  
         var tag = qmc2NEO.getXmlResult();      
      
         qmc2NEO.queryLocalXml("$ID$", "doc($xmlDocument)//machine/chip/@type/string()");  
         var type = qmc2NEO.getXmlResult();
      
         qmc2NEO.queryLocalXml("$ID$", "doc($xmlDocument)//machine/chip/@clock/string()");
         var clock = qmc2NEO.getXmlResult(); 
      
         document.write("<td max-width=\"25%\" align=\"center\"><b><u>"+len+" "+tr('PROCESSORS')+": </u></b>"); 
      
         if (len > 0) 
         {
            var i=0;
            
   				  while (i<len)
		   		  {
					     document.write("<br><b>"+tag[i]+" ("+type[i]+"):</b> "+result[i]);
					     if (clock[i])
					     {
					        c = (clock[i] / 1048576);
					        
					        c=Math.round(c*100)/100;
                 
					        document.write(" ("+c+" MHz)");
					     }   
					     i++;
				    }	
				    document.write("</td>");
			   } 
			   else
				    document.write("<td max-width=\"25%\" align=\"center\"><br><b>"+tr('PROCESSORS')+": </b>"+tr('None')+"</td>");                    
      } 
      else
         document.write(tr('XML query error!'));

As you can see, it only get the length of the processors and, assuming that the result will come in the same order from -listxml it will draw in the screen.
But unfortunatelly, qmc2NEO.queryLocalXml combined with qmc2NEO.getXmlResult will sort every value in the own alphabetical order, and mess up with the order, and draw a weird result, as you can see in the next photo:



Probably, these functions are doing any sorting to list in alphabetical order. That surely takes some performance, but the problem with the order it's big too.
I don't know if this a Query problem from Qt itself, but if there way to solve this problem, be creating a new function or modifing the existent, surely that will be very welcome and this problem can be solved wink


"A user interface is like a joke. If you have to explain it, it's not that good."
Page 17 of 116 1 2 15 16 17 18 19 115 116

Moderated by  qmc2 

Link Copied to Clipboard
Who's Online Now
2 members (Dullaron, 1 invisible), 29 guests, and 9 robots.
Key: Admin, Global Mod, Mod
ShoutChat
Comment Guidelines: Do post respectful and insightful comments. Don't flame, hate, spam.
Forum Statistics
Forums9
Topics9,103
Posts119,275
Members5,019
Most Online890
Jan 17th, 2020
Our Sponsor
These forums are sponsored by Superior Solitaire, an ad-free card game collection for macOS and iOS. Download it today!

Superior Solitaire
Forum hosted by www.retrogamesformac.com