Page 1 of 1

1.71-proofing oxps

Posted: Sun Mar 30, 2008 3:00 pm
by Kaks
Thanks to new improved javascript methods & options, 1.71 should be much better for oxp writing purposes than ever before, but... there are quite a few bits and bobs that aren't the same between 1.70 and 1.71.

Bearing in mind that 1.71 is still very much a moving target, and what I'm about to say might be slightly irrelevant by the time 1.71 is released, I found a few general incompatibilites between 1.70 and 1.71 that are fairly easy to correct. Here are my initial findings, including code that will 'do the right thing' in both 1.70 & 1.71. Please take this advice with a pinch of salt! :)

Code: Select all

for (let i in array){//whatever} 
Please avoid. While it should work without problems, at the moment the javascript object model in 1.71 adds extra elements at the end of arrays.

A safe alternative:

Code: Select all

for (let i=0;i<array.length;i++){//whatever} 

Writing to the log from your oxp can be a bit of a problem now, since in 1.71 you will get a lot of warnings in the log if you use older log commands to write to the log. Did I mention 'log'?

My solution?

Code: Select all

this.Log=function(str){
	if (typeof log != 'undefined') log("script."+this.name, str);
	else LogWithClass("script."+this.name, str);
}
then whenever I want to write to the log I use

Code: Select all

this.Log('testing, testing..');
I've just redone a few oxps that had problems with 1.71, and those two kept cropping up all the time :?
Hope this helps others not to make the same mistakes, etc... ;)

Posted: Sun Mar 30, 2008 4:51 pm
by Svengali
Thanks Kaks :-)

It's a good reminder to overhaul my own work.

Posted: Sun Mar 30, 2008 5:12 pm
by Kaks
Oopsie! I made a cut & paste error with the this.Log function... got too many version of the darned thing floating around...

Apologies! The new improved this.Log function should work ok now!