Page 1 of 2

Edit: List All Script Files

Posted: 03 Apr 2008 12:52
by jacky
Well, since we have a new place to share scripts, I thought I'll share some scripts I've made recently...

This little script will popup a menu listing all your script files, allowing you to chose which one to edit. In order to work all your script files must be located under a subfolder "Scripts", or you'll have to change the location used ("<xypath>\Scripts"), and must be called *.xys, or you'll have to change the selection filter ("*.xys").

Code: Select all

"Edit: List All Script Files..."
 // Open New Tab
 #340;
 // goto folder
 goto "<xypath>\Scripts";
 sortby name, a;
 sel 1,0;
 selfilter "*.xys";
 // Copy Item Path/Name(s)
 #101;
 set $script, <clipboard>;
 // Close Tab
 #351;
 regexreplace $script, $script, "^(.+)\\(.+)\.xys$", """Edit $2"" open  ""$1\$2.xys"";";
 load $script,,s;
Also, they need to be associated with a text editor of your choice, since the command used here is open. Easiest way to do that is simply to add a PFA for *.xys to your text editor of choice.

And if you don't want to use any associations, you can also specifiy the app to start, with the script file as parameter, in the generated script (on the regexreplace command)

Here's an example of that, using notepad :

Code: Select all

 regexreplace $script, $script, "^(.+)\\(.+)\.xys$", """Edit $2"" open """"notepad"" $1\$2.xys"";";

Posted: 06 Apr 2008 19:30
by RalphM
Nice script Jacky, thanks.

Since we all somehow agreed, that the subfolder "Scripts" of appath should be the standard location for scriptfiles, wouldn't it make sense, if the Scripts / Load Script File... menu command would go there automatically? Or should a standard script path variable be added to the config?

Posted: 07 Apr 2008 17:14
by admin
RalphM wrote:Nice script Jacky, thanks.

Since we all somehow agreed, that the subfolder "Scripts" of appath should be the standard location for scriptfiles, wouldn't it make sense, if the Scripts / Load Script File... menu command would go there automatically? Or should a standard script path variable be added to the config?
I did that.
I just wonder if this order
<xydata>
<xydata>\Scripts
or this order
<xydata>\Scripts
<xydata>
is better.
Maybe the second, and thus making \Scripts the "official" first location for script files. Okay?

Posted: 07 Apr 2008 17:53
by j_c_hallgren
admin wrote:Maybe the second, and thus making \Scripts the "official" first location for script files. Okay?
Fine with me! Sounds like a workable plan with little or no impact on current users.

Posted: 07 Apr 2008 21:14
by jacky
Yep, fine with me. Means I'll be able to remove "Scripts\" from all my calls ;)

So, does that mean menu Scripting|Load Script File will try to open in that folder Scripts first, and only if it doesn't exist be in <xydata> ? Would make sense as well I'd say.

(And if you really want to make this a default folder, why not create it yourself when XY is starting for the very first time, along with FindTemplates & NewItems ? Just to "help" new users to use this folder...)

Posted: 07 Apr 2008 21:37
by admin
jacky wrote:Yep, fine with me. Means I'll be able to remove "Scripts" from all my calls ;)

So, does that mean menu Scripting|Load Script File will try to open in that folder Scripts first, and only if it doesn't exist be in <xydata> ?
Exactly!
jacky wrote:(And if you really want to make this a default folder, why not create it yourself when XY is starting for the very first time, along with FindTemplates & NewItems ? Just to "help" new users to use this folder...)
Well, If they cannot even create a folder...

Posted: 07 Apr 2008 21:59
by jacky
admin wrote:Well, If they cannot even create a folder...
I'm sure they can, but for newcomers that don't start by reading the entire help, to see a such a folder will have them use it. Otherwise, they might not know about it, and since Scripting|Load Script File would not open there obviously but in <xydata> they could easily assume that this is the default place...

Posted: 07 Apr 2008 22:22
by admin
jacky wrote:
admin wrote:Well, If they cannot even create a folder...
I'm sure they can, but for newcomers that don't start by reading the entire help, to see a such a folder will have them use it. Otherwise, they might not know about it, and since Scripting|Load Script File would not open there obviously but in <xydata> they could easily assume that this is the default place...
Okay, but ensuring/creating a folder at startup takes time. Nothing is for free. :wink:

Posted: 07 Apr 2008 23:05
by jacky
admin wrote:Okay, but ensuring/creating a folder at startup takes time. Nothing is for free. :wink:
Yeah but that's why I said only "the very first time", I assumed you had a way to tell already if it was or not (eg. cause there's no INI present).

Otherwise you're right, no big deal, leave it as is.

Posted: 08 Apr 2008 04:57
by j_c_hallgren
Or...why not just create it via the Installation process, like most other apps do? And have it as empty folder within the no-install process so it would be established then also.

Posted: 08 Apr 2008 09:12
by admin
j_c_hallgren wrote:Or...why not just create it via the Installation process, like most other apps do? And have it as empty folder within the no-install process so it would be established then also.
Because I have a no-install package, too. And because I don't like it.

Posted: 08 Apr 2008 09:18
by admin
Well, I did it anyway. :) (ensuring on startup)

Posted: 08 Apr 2008 09:41
by j_c_hallgren
admin wrote:
j_c_hallgren wrote:Or...why not just create it via the Installation process, like most other apps do? And have it as empty folder within the no-install process so it would be established then also.
Because I have a no-install package, too. And because I don't like it.
Actually, if you provided a simple sample script or two, then the script folder would be non-empty on install/unload and problem would be solved plus it would give users a demo to begin with... :wink:

Posted: 08 Apr 2008 10:04
by admin
j_c_hallgren wrote:
admin wrote:
j_c_hallgren wrote:Or...why not just create it via the Installation process, like most other apps do? And have it as empty folder within the no-install process so it would be established then also.
Because I have a no-install package, too. And because I don't like it.
Actually, if you provided a simple sample script or two, then the script folder would be non-empty on install/unload and problem would be solved plus it would give users a demo to begin with... :wink:
Ah, now you are talking. :) Will do...

Re: Edit: List All Script Files

Posted: 16 Jul 2008 22:19
by RalphM
Since there were some changes to the controls that are focused as a standard, this script didn't work properly anymore.
It needs the additional line focus l; before copying the items to clipboard, 'cos otherwise the tree has the focus and you end up with an error msg.

Code: Select all

"Edit: List All Script Files..."
 // Open New Tab
 #340;
 // goto folder
 goto "<xypath>\Scripts";
 sortby name, a;
 sel 1,0;
 selfilter "*.xys";
 focus l; 
// Copy Item Path/Name(s)
 #101;
 set $script, <clipboard>;
 // Close Tab
 #351;
 regexreplace $script, $script, "^(.+)\\(.+)\.xys$", """Edit $2"" open  ""$1\$2.xys"";";
 load $script,,s;