Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: JScript Panel (Read 282301 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

JScript Panel

Reply #25
@always.beta
Tested with your samples.
You need to update though your modified JSSmoothPlaylist to a JScript component compatible version.
[/quote]

I'm currently using the js_smooth_playlist and foo_jscript_panel,I just take the old modified version as an example. Because of the time, I did not modify the new version.Thank you!!



JScript Panel

Reply #28
I just had a crash using a script with JScript panel. The same piece of code has been working with wsh panel mod 1.5.6 for ages, so it seems something has changed in JScript panel. I isolated the problematical code and a snippet that shows the issue is below. It will occur if the user sets the border to <1 but any other value seems OK.

Code: [Select]
var border = 0; // if border set to < 1 crashes in JScript panel; wsh panel mod 1.5.6 doesn't crash
var ny = border * 0.5; // it's this multiplication that results in the bad handling
// weird as 0 * 0.5 should equal 0 & so the multiplication shouldn't actually do anything when border = 0

var n_y = ny - 1;

fb.trace("isNAN", isNaN(n_y)) // returns false so is a number

function on_paint(gr) {
gr.FillSolidRect(0, n_y, 50, 50, RGB(255,0,0))
}

fb.trace("n_y", n_y) // n_y traces to -1

window.RepaintRect(0, -1, 50, 50); // DOESN'T CRASH IF DIRECTLY ENTER -1

window.RepaintRect(0, n_y, 50, 50); // weirdly crashes here when y is calculated as above to -1;

//crashes in JScript panel; wsh panel mod 1.5.6 doesn't crash

function RGB(r, g, b) {
return (0xff000000|(r<<16)|(g<<8)|(b));
}

Seeing as I spotted the issue I have reported it, although I do know how to work around it easily enough. There seems to be something strange going on with the maths handling in JScript panel.

 Edit: I just discovered that it's due to use of the jscript9 engine I was using with JScript panel. Switching wsh panel mod 1.5.6 to jscript 9 also gives the script crash. Both JScript panel and wsh panel mod 1.5.6 run the snippet OK with the jscript engine.

JScript Panel

Reply #29
Can you check your JScript engine setting? For me, it crashes in both components with JScript9. Using just JScript, it works fine in both components.

edit: I see you figured this out. It would have been very troubling if my changes had caused this kind of breakage so I'm glad we can rule that out.

JScript Panel

Reply #30
Yes I realised that after I originally posted and my edit of post #29 crossed with your post.

JScript Panel

Reply #31
Try passing -1.0 to the window.RepaintRect. Yes, that is different from -1 because it is a floating point number instead of an integer.

JScript Panel

Reply #32
This is the source for RepaintRect...

Code: [Select]
STDMETHODIMP FbWindow::RepaintRect(UINT x, UINT y, UINT w, UINT h, VARIANT_BOOL force)
{
    TRACK_FUNCTION();

    m_host->RepaintRect(x, y, w, h, force != FALSE);
    return S_OK;
}


According to a quick google, UINT should be a positive integer so I don't know why using -1 doesn't throw errors all the time??

EDIT: I just added this inside the function...

Code: [Select]
console::formatter() << y;


and it spits out this when you feed it -1.

Code: [Select]
4294967295


That just happens to the maximum possible value for UINT. So even though it's not crashing, it's not repainting the area you want it to either!!

With JScript9 engine, the console code doesn't even get to run. I get an overflow error before it happens. Presumably there is some difference with how the scripting engine handles these numbers??

EDIT2
: I've updated the docs...

Code: [Select]
window.RepaintRect(x, y, w, h[, force]);
// x, y, w, h must be an integer, 0 or above. if you cannot be sure of values when
// calculating, do something like this...
// window.RepaintRect(Math.max(0, x), Math.max(0, y), w, h);
// force: boolean, default false
// use this instead of Repaint on frequently updated areas
// such as time, bitrate, seekbar, etc. this should reduce CPU usage.
// you can use Windows Task Manager to double check.


JScript Panel

Reply #34
Just a little maintenance update...

Code: [Select]
- CHG: Update Columns UI SDK to 6.4
- CHG: Update WTL to 9.1
- CHG: Update scintilla to 3.6.2
- CHG: Tidy up docs/samples.


https://github.com/19379/foo-jscript-panel/releases

And before anyone grumbles, I'm well aware of the increased file size. This is caused by the scintilla update.

JScript Panel

Reply #35
You probably remember: in the WSH thread i posted a updated WSH component with a fix to on_mouse_wheel (because my laptop trackpad wasn't working with the previous function).
But it look like you didn't merge my changes to your new component.
In my component i also added two functions similar to UpdateFileInfoSimple, in order to update a group of songs with a nice progress bar while the update is going on, instead of updating the songs one by one.

IFbMetadbHandleList.UpdateFileInfoSimple(field1, value1 [, filed2, value2 [,...] ] [, multivalue_fields]);
This one update the metadb tags for a IFbMetadbHandleList, in order to update a group of songs with a nice progress bar while the update is going on, instead of updating the songs one by one.

IFbMetadbHandleList.UpdateFileInfoArray([field1, value1,field2, value2....]);
This one update the metadb tags based on the array given as a parameter. I needed that because sometimes in my code, the number of tags to update vary depending of the file, so i would have to call UpdateFileInfoSimple for each tag (because you can't have a dynamic number of arguments) and then i wouldn't have a real progress bar if the action take time. With UpdateFileInfoArray, you can build your array of tags to update first, and then you can call the function at the end, and you have a progress bar. This function may need an update, it doesn't care about multivalue fiedl i think, i don't remember exactly how i did it ..

The sources are here http://www.mediafire.com/download/1vl0x0zd....10_sources.zip, if you browse those sources and search for the names of my functions, you will be able to add them to your component. I can eventually help you

JScript Panel

Reply #36
I'll take a look. Thanks.

JScript Panel

Reply #37
I think utils.MapString(text, lcid, flags) need to be explained in the docs...
At least a link to the documentation its API relate to.
The discussions in this page make me confused. BTW I'm a simplified Chinese user myself.

JScript Panel

Reply #38
As in WSH Panel Mod Plus, I found the window controlling functions much useful in certain situations. Maybe that's worth considering to be added in JS Panel?

JScript Panel

Reply #39
@colagen, your sources only contain the mouse wheel changes.

@Scrummble, I copied the MapString function from that other component which also has no documentation. I'm English and only speak English so it's no good asking me. And the window stuff is illegal. I'd rather not the flout the SDK terms given I'm posting on the official forums.


JScript Panel

Reply #41
Actually, the mapstring function has documentation:
Code: [Select]
// see https://msdn.microsoft.com/en-us/library/windows/desktop/dd318700(v=vs.85).aspx

Yep, just a link, but still useful to other users.

BTW I'd like to know, did the SDK terms forbid components influencing one another?
The "window controlling functions" which I mentioned, are just functions that controls the panels in Panel Stack Splitters, I think, rather than the main window. The author of wshpm+ do not speak English, and I'd like to check if there's any misunderstanding.
Apologise for any of my ignorance.

JScript Panel

Reply #42
Code: [Select]
v1.0.6
- ADD: FbMetadbHandleList UpdateFileInfoSimple method.


https://github.com/19379/foo-jscript-panel/releases

@colagen, I've added your trackpad fix but I haven't documented it because no one else has ever had this issue. Also, thanks for the UpdateFileInfoSimple code.
@Scrummble, I'm not adding any of the window stuff. You can always use that other component side by side with this or compile your own component.

JScript Panel

Reply #43
Thanks a lot.
Will you add the updateFileInfoArray later to your component ? I can't find any way to do my code with one unique call to the standard UpdateFileInfoSimple.
Actually what i made is a function which remove all the tags from the selected tracks, except the ones i want to keep. I use it for all the new tracks added to my library, it's a fast way to organize the new files. And obviously i can't list all the weird tags directly in my code, so i have to check the file tags, and when there is a tag which i don't want, i add it to my array of tag to erase, and i call updateFileInfoArray at the end.

Maybe you didn't add it because my code is dirty ? Which is probably true, i'm not a developer myself, i did it without a clear understanding of what i was doing, so it may be buggy.

JScript Panel

Reply #44
If you had provided an example of how to use the function within a script, I might have considered it. I'm totally confused by your post and the fact you've added it as a handle method as well!!

JScript Panel

Reply #45
General question:

Is it possible to make a button in JScript with (switch to playlist) as menu?

Thx


JScript Panel

Reply #47
If you had provided an example of how to use the function within a script, I might have considered it. I'm totally confused by your post and the fact you've added it as a handle method as well!!


Nope, it's just a FbMetadbHandleList method.
I can provide you an example of use yes, but i don't know if it will be easier to understand
The function is quite easy, it's basically the same function than UpdateFileInfoSimple, but it accept only an array as argument, and this array must contain the tags to update, and their values.
FbMetadbHandleList.UpdateFileInfoArray ( ["tagName1","TagValue1","tagName2","TagValue2"...] )

Below is a example, it's a little script i just wrote, which loop over the tags of the first item of a FbMetadbHandleList ( plist_items.Item(0) ), and build an array containing all the tags which aren't in the array named toKeepArray (it use a function named arrayContains(array, string), which is defined below), and after the tag name, an empty string.
Then, with the resulting array, i can call UpdateFileInfoArray and it will remove all those tags from all the items of this FbMetadbHandleList.
This is something you can't do with UpdateFileInfoSimple(). But you course this is a very specific usage, and it's not a big deal if it can't be added to the component.

Code: [Select]
var toRemoveArray=Array();
var toKeepArray=["album","artist","composer","date","genre","title","tracknumber"];
var track_FileInfo = plist_items.Item(0).GetFileInfo();
for (var i = 0; i <= track_FileInfo.MetaCount; i++) {
       if(!arrayContains(toKeepArray , track_FileInfo.MetaName(i))) {
           toRemoveArray[toRemoveArray.length]=track_FileInfo.MetaName(i);
           toRemoveArray[toRemoveArray.length]="";
       }
}
plist_items.UpdateFileInfoArray(toRemoveArray);


function arrayContains(array,string){
    for (var i = 0; i < array.length; i++) {
        if(array[i]==string) return true;
    }
    return false;
}

JScript Panel

Reply #48
Nope, it's just a FbMetadbHandleList method.


You are quite right. I need my eyes testing.

I'll just need to do some testing before I include it.

JScript Panel

Reply #49
Hi marc,

I seem to be having problems with certain bands for the last.fm bio.

This was the error message
Quote
JScript Panel (Last.fm Bio by marc2003): Microsoft JScript runtime error:
Unable to get value of the property 'length': object is null or undefined
File: text.js
Line: 249, Col: 25
<source text only available at compile time>


With the latest release it says the cached file is corrupted but I've removed the file so there is nothing there to be corrupted. All other information is fetched, album review, similar artists and other releases.