You are not logged in.

Zephyr

Professional

  • "Zephyr" started this thread

Posts: 1,003

Location: Netherlands

Occupation: Web developer

  • Send private message

1

Monday, June 6th 2011, 9:31pm

a way to check if plugin exists?

Hi,

I want to know the existence of a plugin. If the plugin doesnt exist, I should create it. My initial thought was by checking

Source code

1
if(get(plugin[someplugin]) == null, addplugin(someplugin), removeplugin(someplugin));


but I cant get it to validate. I even tried get(plugin[someplugin].count) == null

Any clues? Atm I resolved it by creating a dummy plugin, so I don't get an error, but it's not the neatest way ofcourse.

spacerywirtualne

Professional

Posts: 1,117

Location: Poland, Europe

Occupation: krpano developer : virtual tours : the cms4vr owner

  • Send private message

2

Monday, June 6th 2011, 10:00pm

maybe this code?

Hi

Source code

1
if(plugin[someplugin].loaded, removeplugin(someplugin), addplugin(someplugin));


I use something similar and for me it works great.


pietero
Your own professional, online cloud tool for creating virtual tours - www.cms4vr.com

facebook page :: youtube :: wiki.cms4vr.com

cms4vr team *thumbsup*

Zephyr

Professional

  • "Zephyr" started this thread

Posts: 1,003

Location: Netherlands

Occupation: Web developer

  • Send private message

3

Tuesday, June 7th 2011, 12:02am

thanks, that did the trick!

spacerywirtualne

Professional

Posts: 1,117

Location: Poland, Europe

Occupation: krpano developer : virtual tours : the cms4vr owner

  • Send private message

4

Tuesday, June 7th 2011, 9:52am

*thumbup*

pietero
Your own professional, online cloud tool for creating virtual tours - www.cms4vr.com

facebook page :: youtube :: wiki.cms4vr.com

cms4vr team *thumbsup*

5

Wednesday, June 8th 2011, 12:05am

Hi,

the 'strict equal' if operater (===) would be also a possibility,

e.g.

Source code

1
2
if(plugin[xyz] === null, trace(there is NO plugin named xyz));
if(plugin[xyz] !== null, trace(there is a plugin named xyz));


best regards,
Klaus

Zephyr

Professional

  • "Zephyr" started this thread

Posts: 1,003

Location: Netherlands

Occupation: Web developer

  • Send private message

6

Sunday, July 24th 2011, 1:25am

I still having problems when I put this in an loop...

if(plugin[get(thumbname)] !== null,
removeplugin(thumbname);
);

sometimes returns ERROR: remove - unknown array item - thumbname

which doesnt make sense, it shoudnt pass the if statement if i couldnt delete it :(

Posts: 1,857

Occupation: Virtual Tours - Photography - Krpano developer

  • Send private message

7

Sunday, July 24th 2011, 6:00am

KRPano Developer: Portfolio ::Gigapixel Tagging Solutions - Porfolio 2 :: Facebook :: Twitter :: reddit.com/r/VirtualTour

Zephyr

Professional

  • "Zephyr" started this thread

Posts: 1,003

Location: Netherlands

Occupation: Web developer

  • Send private message

8

Sunday, July 24th 2011, 12:21pm

thanks :) I had another error. I tried to removeplugin(thumbname) instead of get(thumbname).

this works:

Source code

1
2
3
4
txtadd(thumbname,'thumb_', get(i));
				if(plugin[get(thumbname)].loaded, 
					removeplugin(get(thumbname));
					);


but this too, and i find this better:

Source code

1
2
3
4
txtadd(thumbname,'thumb_', get(i));
				if(plugin[get(thumbname)] !== null, 
					removeplugin(get(thumbname));
					);

Similar threads