Jump to content

[RESOLVED] Weird SciTE behaviour; script to open file to edit ...


Recommended Posts

Scripting automating SciTE to open a specific AU3 seems to return blank filename tabs with parts of the file name instead of the script itself.

i.e., when I shellexecute so that first part is SciTE then followed by file name (in the usual way of setting another app to open a file rather than default), a bunch of blank tabs is all that is opened up. To give an example,

ShellExecute("L:\AutoIt\TOOLS\Editor- SciTE\SciTE v1.74\APP- SciTE v1.74\SciTe.exe", @ScriptDir & "\TIME say.au3", "", "open", @SW_MAXIMIZE)

gets me 4 blank tabs labelled: "Documents", "and", ""TIME", and "say.au3"

whereas

ShellExecute("L:\TEXT\npad, Metapad v3.51\APP- Metapad v3.51\Metapad.exe", @ScriptDir & "\TIME say.au3", "", "open", @SW_MAXIMIZE)

, which is just exchanging SciTE path to my noteplad replacement , opens up the file properly (?). Weird. Must be because SciTE deals with tabs, maybe (?).

Was wondering if anyone had gotten around that behaviour.

Thanks! :)

Edited by Diana (Cda)
Link to comment
Share on other sites

The paths that you are using may have whitespace in them so you need to double quote the paths to keep the path as one complete string.

Using ShellExecute which can handle documents by the registry associations can be done this way.

ShellExecute('"' & @ScriptDir & '\TIME say.au3"', '', @ScriptDir, 'edit', @SW_MAXIMIZE)oÝ÷ ئZÁªÞ¡ö§Ê^÷«mú+®éçx-ç±yË­i¹^±È­yì^Â+aJ¥L^^v*ÞrÛ(!©§¢Ø(x-¡Ø¬¦V²¶­bjzî©ÞÅç.µ¦å{­§jwijË)j¶¦z׫²Ú"µ«­¢+ÙIÕ¸ ÌäìÅÕ½Ðí0èÀäÈíÕѽ%ÐÀäÈíQ==1LÀäÈí¥Ñ½È´M¥QÀäÈíM¥QØĸÜÐÀäÈíA@´M¥QØĸÜÐÀäÈíM¥Q¹áÅÕ½ÐìÅÕ½ÐìÌäìµÀìMÉ¥ÁѥȵÀìÌäìÀäÈíQ%5Íä¹ÔÌÅÕ½ÐìÌäì°MÉ¥ÁѥȰM]}5a%5%i¤((ì½ÈÕÍ()IÕ¸ ÌäìÅÕ½Ðí0èÀäÈíQaPÀäÈí¹Á°5ÑÁØ̸ÔÄÀäÈíA@´5ÑÁØ̸ÔÄÀäÈí5ÑÁ¹áÅÕ½ÐìÅÕ½ÐìÌäìµÀìMÉ¥ÁѥȵÀìÌäìÀäÈíQ%5Íä¹ÔÌÅÕ½ÐìÌäì°MÉ¥ÁѥȰM]}5a%5%i¤

Notice how I use double quotes to retain the path as one complete string. I use double quotes in any Run parameters also to keep each of them as a comlplete string also. The use of single quotes helps to surround the strings while keeping definition from what the double quote purpose is.

You may notice that I always use single quote by default and it is for the very reason of adding double quote to protect paths with spaces is why I do it. Also a single quote is easier to type as no shift key needed to press.

:)

Link to comment
Share on other sites

The paths that you are using may have whitespace in them so you need to double quote the paths to keep the path as one complete string.

Okay, wow. New concept I wasn't aware of, "path white space". Never saw this before, believe it or not ... Trouble is, though intellectually I believe I'm understanding the problem of whitespace, I just can't wrap my brain around the solution given (what else is new?!).

I see only one quote and two single apostrophes before the first part of the syntax, yet 2 double quotes after which are separated by a space? When I go to change anything, paths or apps, I get an error because I don't see what I need to do. I don't see the double quotes you speak of, sorry, just the one before and two after, separated by a space <sheepish>.

Yet no matter what I do using Metapad, the code works. I developed a lot of relative path tricks so that the path to Metapad, for example, is controlled by a single entry in an include file. This was a proactive solution to enormous drive letter problems after these change following an OS wipe/reinstall or whenever I go to a new computer and the memory stick is assigned a different letter. When I get to new computer, I make a tiny edit if it's needed to the _PartitionLetters.au3 include file I came up. I just type in the new drive letter and, presto, all the scripts work that reference it, just with a small 1-time edit per computer change.

So, to avoid the multiple problems with absolute paths, I'd change my script to this type of thing:

#include <_PartitionLetters.au3>
ShellExecute($Fldr_Programs_DriveLtr & "\TEXT\npad, Metapad v3.51\APP- Metapad v3.51\Metapad.exe", @ScriptDir & "\TIME say.au3", "", "open", @SW_MAXIMIZE)
This works just great, again, in Metapad but if I try to just substitute the Metapad path for SciTE, busted!

I went back to this ShellExecute format because it's something I know since other than copy/pasting your RUN code _exactly_ can't get that to work. And can't use the exact syntax as situations change, i.e., I use full path to determine viability; then change to relative paths once the script works. Nothing works that isn't an exact duplicate of your code.

Where does the problem lie (besides my brain, of course! <lol>)?

Thanks. Appreciate the help enormously, as always! :)

Link to comment
Share on other sites

Okay, wow. New concept I wasn't aware of, "path white space". Never saw this before, believe it or not ... Trouble is, though intellectually I believe I'm understanding the problem of whitespace, I just can't wrap my brain around the solution given (what else is new?!).

I see only one quote and two single apostrophes before the first part of the syntax, yet 2 double quotes after which are separated by a space? When I go to change anything, paths or apps, I get an error because I don't see what I need to do. I don't see the double quotes you speak of, sorry, just the one before and two after, separated by a space <sheepish>.

I have some information for you to read. May you learn something from it. Let me know if you do not understand but do attempt to read many times if needed until it makes some sense to you.

Help.zip

So, to avoid the multiple problems with absolute paths, I'd change my script to this type of thing:

#include <_PartitionLetters.au3>
ShellExecute($Fldr_Programs_DriveLtr & "\TEXT\npad, Metapad v3.51\APP- Metapad v3.51\Metapad.exe", @ScriptDir & "\TIME say.au3", "", "open", @SW_MAXIMIZE)
This works just great, again, in Metapad but if I try to just substitute the Metapad path for SciTE, busted!
You mention no error information so I guess you may need to debug. I have prepared some code for debugging. Let me know of the results.

test.au3

I went back to this ShellExecute format because it's something I know since other than copy/pasting your RUN code _exactly_ can't get that to work. And can't use the exact syntax as situations change, i.e., I use full path to determine viability; then change to relative paths once the script works. Nothing works that isn't an exact duplicate of your code.

Where does the problem lie (besides my brain, of course! <lol>)?

Thanks. Appreciate the help enormously, as always! :)

OK, once you are experienced enough, then you can do what needs to be done, but you cannot run away from Run forever :P .
Link to comment
Share on other sites

  • 4 weeks later...

I have some information for you to read. May you learn something from it. Let me know if you do not understand but do attempt to read many times if needed until it makes some sense to you.

Help.zip

You mention no error information so I guess you may need to debug. I have prepared some code for debugging. Let me know of the results.

test.au3

OK, once you are experienced enough, then you can do what needs to be done, but you cannot run away from Run forever muttley .

Finally was able to come back to this over a couple of session in last 2 days. If it weren't for great people like MHz willing to help others that were really stupid at any new slightly complex syntax, I'd have given up on AI aeons ago! <sigh> <g>

First off, I have to say that you are amazing, that help file is incredible. I'm sorry I didn't say so sooner. I dl the files and got stuck on the rest of the instructions back then for a couple of sessions and then was sidetracked by life, etc., when I didn't make headway <g>. RL seems to have a way of doing that a lot, doesn't it? I spent 2 solid hours on this in the early hours of this morning when I finally stupid me studied the help file. Had I done that first rather than the downloaded AU3 file, I'd have found the fix! It's an amazing file. I still understand the concepts just as well as before, it's just that I didn't have any luck again either until I used the example in the help file and replaced things word for word. I still don't get the why's of the placement of the apostrophes so will come back to that help file until I do. Like before, things work with full paths and it's easy to see. But with any "relative path" tricks, that's when the punctuation gets really tricky.

Here's what ultimately worked:

#include<_PartitionLetters.au3>

Run('"' & $Fldr_Programs_DriveLtr & '\AutoIt\TOOLS\Editor- SciTE\SciTE v1.74\APP- SciTE v1.74\SciTe.exe" "' & _
        $Fldr_Programs_DriveLtr & '\AutoIt\APP- AutoIt v3.2.10.0\Include\_PartitionLetters.au3"')

As a note because other newbies might run into this problem and might have same conditions, there is something that I wasn't always remembering, I use AI and SciTE as standalones. I'm betting that plays a big part in this problem of whitespaces here. I use as many apps as possible as standalones and AI and SciTE seem to work nearly 100% fine this way. But I had trouble with a context menu freeware and SciTE since I posted this thread initially. Though it may turn out to be unrelated, I don't think so as it's too similar a problem. I manually opened a script via this context menu freeware and I got the same blank multiple tab behaviour without the original script appearing anywhere. You can imagine my surprise, this behaviour occurring twice in two different operations when it never had before. However, this was first time I'd used imported settings in the freeware. Fix there turned out to be simple - went back and changed all settings for opening the apps from {filename} to "{filename}". Whitespace again! So ...

for other newbies, if you run into problems when opening AU3 files with SciTE programmatically and you use relative paths or other shortcut variables so must use RUN, dl the most excellent help file above that MHz created and has made available to us and follow the excellent instructions there.  They work!
I've copied MHz's excellent "help.chm" file into both my hdd and USB flash drive TIPS folders for future study. I'm going to learn how to work RUN business no matter what! <g>

(p.s., the debugging didn't seem to do very much either when I used it last time or last night. The usual empty tabs come up in SciTE, labelled "Documents", "time" and "TIME" and "say" and 2 text files open with the script. That's it.)

Thanks! Another issue resolved. :)

Edited by Diana (Cda)
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...