Skip to main content

Topic: WSH Panel Mod (Read 580129 times) previous topic - next topic

0 Members and 2 Guests are viewing this topic.
  • marc2003
  • [*][*][*][*][*]
WSH Panel Mod
Reply #650
if you're using the script i posted the other day, it's my fault.  i'm reading the cached text file during window.repaint()  i originally made the script without knowing how to scroll and my panel is locked in size so it didn't matter at the time. i really should have updated it. 

or maybe you figured that out already.
  • Last Edit: 19 January, 2010, 11:32:19 AM by marc2003

  • carmenm
  • [*][*][*][*][*]
WSH Panel Mod
Reply #651
if you're using the script i posted the other day, it's my fault.  i'm reading the cached text file during window.repaint()  i originally made the script without knowing how to scroll and my panel is locked in size so it didn't matter at the time. i really should have updated it. 

or maybe you figured that out already.

Yeah i corrected that. I also made sure that i measure the string height only when necessary. The time it takes to repaint is only due to the drawing itself

  • marc2003
  • [*][*][*][*][*]
WSH Panel Mod
Reply #652
whilst on the subject of that, i found this neat activex component to properly decode all special characters. use it like this....

Code: [Select]
ck = new ActiveXObject("CkString.StrFun");

try {
    text = xmlDoc.getElementsByTagName("content")[0].childNodes[0].nodeValue;
    text = ck.StripHtml(text);
    text = ck.HtmlEntityDecode(text);
} catch(e) {
    text = "This artist does not have a biography page on Last.fm.";
}


http://www.chilkatsoft.com/downloads.asp - ckstring, 2nd from the bottom. you need to register the dll using "regsvr32 ckstring.dll" in an administrator command prompt.

EDIT: question about gdi draw text array removed. using measure string instead.
  • Last Edit: 19 January, 2010, 12:17:10 PM by marc2003

  • carmenm
  • [*][*][*][*][*]
WSH Panel Mod
Reply #653
i need help with WshShell.run
i have that command
Code: [Select]
"C:/Program Files/AlbumArtDownloader/aad.exe" /sources "LastFM Artist" /ar "Bloc Party" /mn 500 /mx 1000 /path "D:/Martin/My Documents/My Music/LastFmData/Bloc Party.jpg"

i am launching it with WshShell.Run(command, 0, true); so that i wait for the result
but i never go to the next line :s
Yet the command works perfeclty in a cmd.

Does anyone have an idea of what might be the problem?
Is there any to get the output of the command in the console?

Thanks

  • marc2003
  • [*][*][*][*][*]
WSH Panel Mod
Reply #654
use "cmd.exe /k c:\program...." to troubleshoot. this spawns a command prompt window and it keeps it open so you can see what happens. it's probably to do with escaping of quotes.

  • carmenm
  • [*][*][*][*][*]
WSH Panel Mod
Reply #655
ok something is really wrong, it doesnt open the command line :s

  • T.P Wang
  • [*][*][*][*]
  • Developer
WSH Panel Mod
Reply #656
Quote
whilst on the subject of that, i found this neat activex component to properly decode all special characters. use it like this....

Another way:
http://www.daniweb.com/forums/post658176.html#post658176

Quote
EDIT: found it in the Graphics. COuld you give us access to setClip TPWang?

It's already used before calling on_paint(gr);
You should stop using DT_CALCRECT in that case (or use with limited).


  • carmenm
  • [*][*][*][*][*]
WSH Panel Mod
Reply #657
Quote
whilst on the subject of that, i found this neat activex component to properly decode all special characters. use it like this....

Another way:
http://www.daniweb.com/forums/post658176.html#post658176

i cant get it to work.  I have difficulties translating the function.

Quote
Quote
EDIT: found it in the Graphics. COuld you give us access to setClip TPWang?

It's already used before calling on_paint(gr);
You should stop using DT_CALCRECT in that case (or use with limited).

Yes it s a lot better! and i dont need DT_CALCRECT anymore as i know the size so thank you!

  • T.P Wang
  • [*][*][*][*]
  • Developer
WSH Panel Mod
Reply #658
Quote
i cant get it to work. I have difficulties translating the function.

Code: [Select]
function decodeXMLEntites(text) {
   var xmlDoc = new ActiveXObject("MSXML.DOMDocument");
   xmlDoc.async = false;
   xmlDoc.loadXML("<sometext>" + text + "</sometext>");

   if (xmlDoc.parseError.errorCode != 0) {
       return "";
   }
  
   return xmlDoc.text;
}

fb.trace(decodeXMLEntites("&quot;Some text&quot;"));

  • carmenm
  • [*][*][*][*][*]
WSH Panel Mod
Reply #659
Quote
i cant get it to work. I have difficulties translating the function.

Code: [Select]
function decodeXMLEntites(text) {
   var xmlDoc = new ActiveXObject("MSXML.DOMDocument");
   xmlDoc.async = false;
   xmlDoc.loadXML("<sometext>" + text + "</sometext>");

   if (xmlDoc.parseError.errorCode != 0) {
       return "";
   }
  
   return xmlDoc.text;
}

fb.trace(decodeXMLEntites("&quot;Some text&quot;"));
thanks

  • marc2003
  • [*][*][*][*][*]
WSH Panel Mod
Reply #660
function decodeXMLEntites(text) {
}


fine with plain text but when you have special characters.....

Code: [Select]
fb.trace(xmlDoc.parseError.reason);
Reference to undefined entity 'oacute'



  • T.P Wang
  • [*][*][*][*]
  • Developer
WSH Panel Mod
Reply #661
@marc2003:
Then try this:
Code: [Select]
function decodeXMLEntites(text) {
   var doc = new ActiveXObject("htmlfile");
   doc.open();
   var div = doc.createElement("div");
   div.innerHTML = text;
  
   return div.innerHTML;
}

  • carmenm
  • [*][*][*][*][*]
WSH Panel Mod
Reply #662
@marc2003:
Then try this:
Code: [Select]
function decodeXMLEntites(text) {
   var doc = new ActiveXObject("htmlfile");
   doc.open();
   var div = doc.createElement("div");
   div.innerHTML = text;
  
   return div.innerHTML;
}
WIth the latest version i loose all the  "\n"

  • T.P Wang
  • [*][*][*][*]
  • Developer
WSH Panel Mod
Reply #663
Yes, because "\n" will be ignored in HTML, use <br/> instead.

  • carmenm
  • [*][*][*][*][*]
WSH Panel Mod
Reply #664
Yes, because "\n" will be ignored in HTML, use <br/> instead.

Thanks, i replace "\n" with <br/>, decode then replace <BR> with "\n" and it works !

  • marc2003
  • [*][*][*][*][*]
WSH Panel Mod
Reply #665
what have you ended up with? this is what i have. 

Code: [Select]
text = text.replace(/&(lt|gt);/g, function (strMatch, p1){
    return (p1 == "lt")? "<" : ">";
});
text = text.replace(/<\/?[^>]+(>|$)/g, "");
doc = new ActiveXObject("htmlfile");
doc.open();
div = doc.createElement("div");
div.innerHTML = text.replace(/\n/g, "<br>");
text = div.innerHTML;
text = text.replace(/<BR>/g,"\n");
text = text.replace(/&amp;/g,"&");

  • carmenm
  • [*][*][*][*][*]
WSH Panel Mod
Reply #666
what have you ended up with? this is what i have. 

Code: [Select]
text = text.replace(/&(lt|gt);/g, function (strMatch, p1){
    return (p1 == "lt")? "<" : ">";
});
text = text.replace(/<\/?[^>]+(>|$)/g, "");
doc = new ActiveXObject("htmlfile");
doc.open();
div = doc.createElement("div");
div.innerHTML = text.replace(/\n/g, "<br>");
text = div.innerHTML;
text = text.replace(/<BR>/g,"\n");
text = text.replace(/&amp;/g,"&");


Code: [Select]
text = strInputCode.replace(/<\/?[^>]+(>|$)/g, "");
                            text = text.replace(/\n/g, "<br/>");
                            text = decodeXMLEntites(text);
                            text = text.replace(/<BR>/g, "\n");
                            text = text.replace(/&quot;/g, '"');
                            artistbio = text.replace(/&amp;/g,"&");

i use that directly from lastfm api input

  • marc2003
  • [*][*][*][*][*]
WSH Panel Mod
Reply #667
i've stumbled across a really odd problem. i'm fetching data from last.fm and and am using this to save the results to text files.

Code: [Select]
ts = fso.FileExists(filename) ? fso.OpenTextFile(filename, 2) : fso.CreateTextFile(filename, 2);
ts.WriteLine(text);
ts.close();


but i've found a couple of artists that are causing this error...

Code: [Select]
WSH Panel Mod (GUID: 61276294-C90D-48B6-BE13-0C2328792088): Microsoft JScript runtime error:
Invalid procedure call or argument
Ln: 42, Col: 9
<source text only available in compile time>


line 42 is simply

Code: [Select]
ts.WriteLine(text);


how can the contents of "text" cause the function to fail? this is one example of some problematic text...

edit: sample removed. T.P has provided the solution.
  • Last Edit: 21 January, 2010, 12:08:56 AM by marc2003

  • T.P Wang
  • [*][*][*][*]
  • Developer
WSH Panel Mod
Reply #668
@marc2003:
First you make wrong use of CreateTextFile() (but it's not important), and acutally OpenTextFile() can be used to create a file if file doesn't exist.

This most important thing is:
You try to write unicode chars (there are some korean chars in your sample) in ANSI files, so, open a text file in Unicode mode using:

Code: [Select]
var fs = fso.OpenTextFile(filename, 2, true, -1);


That's all.

  • marc2003
  • [*][*][*][*][*]
WSH Panel Mod
Reply #669
cheers. that's sorted it.

  • T.P Wang
  • [*][*][*][*]
  • Developer
WSH Panel Mod
Reply #670
WSH Panel Mod 1.3.0 Uploaded.

  • carmenm
  • [*][*][*][*][*]
WSH Panel Mod
Reply #671
@TPWang: I think i found a bug.
I use the on_playback_time(time)  to provoke media downloading.
If time ==3 i do the download.
If i do WshShell.run just there in the on_playback_time(time), i get the error that WshShell doesnt exist which i really good as it doesnt !
But if i do it the way i do it which is
Code: [Select]
function on_playback_time(time) 
{
    if(time == 3)
    {
        
    xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
        xmlhttp.open("GET", url + "&s=" + Math.random(), true);
    xmlhttp.setRequestHeader('User-Agent','foo_lastfm_playcount_sync');
    xmlhttp.send();
    xmlhttp.onreadystatechange = function()
    {
             WshShell.run
        }
     }
}

I dont see the error. (i remove most of the code).
I suppose the stdout from xmlhttp isnt redirected to the console

  • T.P Wang
  • [*][*][*][*]
  • Developer
WSH Panel Mod
Reply #672
I don't think so.

  • carmenm
  • [*][*][*][*][*]
WSH Panel Mod
Reply #673
I don't think so.

OK but still i dont see the error.

  • marc2003
  • [*][*][*][*][*]
WSH Panel Mod
Reply #674
you didn't remove this bit. did you?

Code: [Select]
xmlhttp.onreadystatechange = function() {
    if (xmlhttp.readyState == 4) {
        if (xmlhttp.status == 200) {
            //on success do something
        } else {
            fb.trace(xmlhttp.responsetext);
        }
    }
}


you have to wait for it to complete and this can take a few seconds if the remote server is being slow.