Page 1 of 2

Scripting: new SC "notepad"

Posted: 26 Jul 2010 09:12
by Stefan
Minor wish, but i have to ask :wink: , maybe i find an open ear?


I know how to do this on my own
but i like to suggest an new scripting command "notepad" or "edit"
to work like "text" but just open the default text editor instead.

Instead of
$List = report("{Name}");
writefile("%tmp%\randomfilename, $List);
run notepad $List;
delete $List;

(i know i can save an line here)

i am interested into just using
notepad report("{Name}");
where XY keeps the data just in memory or use an temp file too.

(I guess i can use workarounds like function or include but that wouldn't be the same)

Re: Scripting: new SC "notepad"

Posted: 26 Jul 2010 09:44
by admin
Not bad! Remind me later...

Re: Scripting: new SC "notepad"

Posted: 26 Jul 2010 11:11
by jacky
Stefan wrote:but i like to suggest an new scripting command "notepad" or "edit"
to work like "text" but just open the default text editor instead.
Does it have to be the default text editor (Which would require the use of a temp file) ?

Cause otherwise, XY already provides such a function, called input. Try this: msg input(,,report("{Name}"),m);

Re: Scripting: new SC "notepad"

Posted: 26 Jul 2010 12:39
by Stefan
jacky wrote:
Stefan wrote:but i like to suggest an new scripting command "notepad" or "edit"
to work like "text" but just open the default text editor instead.
Does it have to be the default text editor
No, an option to set an different editor as default inside XY could be nice anyway too.
Would be also nifty for other situations to open text files with an favorite editor without the need for do POM or scripting first. (for non-adv. users)
But this was not my intention.
(Which would require the use of a temp file) ?
Not really (PostMessage/SendMessage, isn't it?)
Cause otherwise, XY already provides such a function, called input. Try this: msg input(,,report("{Name}"),m);
Thanks jacky but this is basically the same as using 'text report("{Name}");'
But this dialog lacks all the advance features of an editor like "Sort", "Search&Replace", "LineNumbers" and above all...: "Save as"

I know that i can use 'writefile' and 'run notepad' on my own... but since this is
an common use i want to suggest an simpler/quicker way.

An other idea would be an optional "Save as..." -button for text() and input() ?
But notepad() or edit() would be more useful me think?

.

Re: Scripting: new SC "notepad"

Posted: 26 Jul 2010 13:59
by jacky
Stefan wrote:
(Which would require the use of a temp file) ?
Not really (PostMessage/SendMessage, isn't it?)
That would mean you're assuming any & all text editor support & respond the same way to those, and I'm not sure there's any basis for such an assumption.
Stefan wrote:Thanks jacky but this is basically the same as using 'text report("{Name}");'
With one major difference though: text only shows the text, it's read-only, whereas input let's you edit it, obviously. ;)
Stefan wrote:But this dialog lacks all the advance features of an editor like "Sort", "Search&Replace", "LineNumbers" and above all...: "Save as"

I know that i can use 'writefile' and 'run notepad' on my own... but since this is
an common use i want to suggest an simpler/quicker way.
As you say, using writefile you can make yourself a quick internal editor, it'll be a very basic one but it's fast & can be quite useful. For more, it'll probably have to be a self-made call to your text editor, which you can probably reduce to a simple

Code: Select all

global $gbl_text; $gbl_text = report("{Name}"); goto '@edit';
(and of course have your script launching the text editor triggered via alias @edit).
Or if you don't mind messing with your clipboard, you drop the use of global vars of use copytext instead.

Re: Scripting: new SC "notepad"

Posted: 26 Jul 2010 14:12
by TheQwerty
Personally, I think it makes more sense to define a PFA for your chosen editor and then give the temp file a name that triggers that PFA when you use the Open command on the temp file.

It gets the script down to two lines.

We have PFA so I see absolutely no reason to have a separate "Default Text Editor" option and a command to open that program. :?

Re: Scripting: new SC "notepad"

Posted: 26 Jul 2010 14:36
by SkyFrontier
A bit off-topic but in the same "how-to-quick-script" subject:
-It doesn't make sense to me having a "step mode" toggle who needs a function entered in the script itself to be respected and work. Why not simply execute the entire script at once as if it were being executed thru "User/run script" (or other) if STEP MODE is OFF? It's a pain to User/Manage commands (Ok, CTRL+ALT+F9 for the sharpen...)/select script/edit/make the tuning/click ok/ok again/assign shortcut (temporary just to try to save some pain...)/go to User again/run script (or else just use the previously assigned temp-CKS) and see what happens instead of just scripting/try script (or a cleverCKS!)/paste-edit/ok and see the magic - as it was in a distant past, pre-step mode!

-or am I missing something here?

Thanks.

Re: Scripting: new SC "notepad"

Posted: 26 Jul 2010 14:50
by Stefan
:lol: thanks fellows,
those are all nice work around you can do if you are an coder and they glossy show how good you are...
but in no sense easy scripting command for the average user like me :wink:

See, if i come to XY i don't wanna get an diploma in programming but use an file manager with easy to use commands.


 

Re: Scripting: new SC "notepad"

Posted: 26 Jul 2010 14:59
by SkyFrontier
I'd don't mind in having an XY degree... fighting a way to create folders out of a file name's without extensions... don't even figure out how to start creating the FOLDERS based on a recent script that worked for FILES... quite a damn simple task! Nah... :|

Re: Scripting: new SC "notepad"

Posted: 26 Jul 2010 17:28
by admin
SkyFrontier wrote:A bit off-topic but in the same "how-to-quick-script" subject:
-It doesn't make sense to me having a "step mode" toggle who needs a function entered in the script itself to be respected and work. Why not simply execute the entire script at once as if it were being executed thru "User/run script" (or other) if STEP MODE is OFF? It's a pain to User/Manage commands (Ok, CTRL+ALT+F9 for the sharpen...)/select script/edit/make the tuning/click ok/ok again/assign shortcut (temporary just to try to save some pain...)/go to User again/run script (or else just use the previously assigned temp-CKS) and see what happens instead of just scripting/try script (or a cleverCKS!)/paste-edit/ok and see the magic - as it was in a distant past, pre-step mode!

-or am I missing something here?

Thanks.
I read that 2 times and have not the slightest idea what it's about. :) I hope somebody else has an answer.

Re: Scripting: new SC "notepad"

Posted: 26 Jul 2010 17:57
by SkyFrontier
What about:

I want to be able to "Script/Try script", paste/write script, and have the script working without dozens of code-check pop-ups? Because that's what happens, no matter what "Step mode" is on or off. :mrgreen:

Re: Scripting: new SC "notepad"

Posted: 26 Jul 2010 19:38
by admin
SkyFrontier wrote:What about:

I want to be able to "Script/Try script", paste/write script, and have the script working without dozens of code-check pop-ups? Because that's what happens, no matter what "Step mode" is on or off. :mrgreen:
Ah! Right-click the Continue button in the Step dialog to see an option you don't know about yet...

Re: Scripting: new SC "notepad"

Posted: 26 Jul 2010 19:48
by Stefan
SkyFrontier, did you talk about "Scripting > Try Script..."
and the debug "Stepping through a Script"-dialog?
IF yes, try an right click on the [Continue]-button at this dialog and see what's hidden there.

Re: Scripting: new SC "notepad"

Posted: 26 Jul 2010 20:00
by SkyFrontier
Admin:
Ah! Right-click the Continue button in the Step dialog to see an option you don't know about yet...
...man, I'm amazed... Right click a "continue" button? I will really have to take some XY classes more... lol
Don't know if it's intended to work that way, but it popped a second stepping window then worked as expected. It's far less work than what I extensively described (not my fault!) above, though. Thanks for another tip (will check if it's documented, anyway, and included that on the project... which will demand some "flash" (i hate flash!) lessons, as it seems...).
---
Thanks also, Stefan! Updated the scripts section following your guidance... hope it's better worded, now.

Re: Scripting: new SC "notepad"

Posted: 26 Jul 2010 20:16
by admin
SkyFrontier wrote:Admin:
Ah! Right-click the Continue button in the Step dialog to see an option you don't know about yet...
...man, I'm amazed... Right click a "continue" button? I will really have to take some XY classes more... lol
Don't know if it's intended to work that way, but it popped a second stepping window then worked as expected.
This depends on the current script line; if it is nested it might need a couple of pops to get out of the sub. I might be able to improve this later...

Did you note that the button has a tooltip? Sometimes it's good to read them... :P