Modifying a script with a embeded function

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Post Reply
neil9090
Posts: 64
Joined: 28 Jun 2014 00:09

Modifying a script with a embeded function

Post by neil9090 »

Does XY cache the code of a function based on its name?

I have a script used in a custom column, called via load "script" that has a function (no include statements or anything in the script).
When I modify the script the function does not adapt to the changes I made to the script file.
If I change the function name within the script it works. It is similar to the include/include_once where you modify the underlying script, but doesn't take effect until you reload XY.

Is there a way to clear the cache, force unloading of the script functions? is there a tweak to unload the script functions after the last function call.
I guess it has been done for speed, but when you are creating/debugging a function it would be nice to see the amendments without unloading XY or changing the function name.

Unless I am missing something, which is very possible.

highend
Posts: 13274
Joined: 06 Feb 2011 00:33

Re: Modifying a script with a embeded function

Post by highend »

show the part of the custom column script and the script that is loaded via load <script>?
One of my scripts helped you out? Please donate via Paypal

neil9090
Posts: 64
Joined: 28 Jun 2014 00:09

Re: Modifying a script with a embeded function

Post by neil9090 »

adding a custom column,

Code: Select all

	load "C:\mytest.xys"


// c:\mytest.xys
	return test();
	
	
	function test()
	{
		return "test";
	}
this works ok until I want to change the test function
e.g. load mytest.xys in notepad etc.
edit the function test() to

Code: Select all

	function test()
	{
		return "test2";
	}
save xys file
go back to xy, refresh the custom column.
The value returned doesn't change.
If I change the function name or reload XY, it loads a fresh, but making changing to the script file doesn't refresh the function code.

highend
Posts: 13274
Joined: 06 Feb 2011 00:33

Re: Modifying a script with a embeded function

Post by highend »

Mh, at least it seems like there is some file caching involved...

May I ask why do you want to do it this way (use load to load a script resource)?

For easier testing?

You can easily create / debug a custom column script by using it on normal list entries
just by replacing <cc_item> with <curitem>. No need to load it from a script file...
One of my scripts helped you out? Please donate via Paypal

neil9090
Posts: 64
Joined: 28 Jun 2014 00:09

Re: Modifying a script with a embeded function

Post by neil9090 »

Guess its easier editing in notepad++ rather than editing directly in XY (non resizable window, no highlighting etc.), and all the scripts are usually in one place for easy management as I use a beta XY and a normal version (as well as different machines) thus using the same scripts not specific to install location.

Also I guess now we have function calls just thought it looks cleaner.

Workaround, is to not use functions until its finished.

The caching element also appears to occur for the include + include_once (which I can understand for include_once) maybe its a side effect of this.
i.e. in a script it has an include statement, the functions within that script are cached for speed, but for editing it means reloading while testing..
Or as you said using a different method to debug/test.

Post Reply