Jump to content

[SOLVED] SciTE: When I hit F5 on an include, run the main script instead


 Share

Recommended Posts

Edit: A solution was found! Thanks Jos and others who helped me find this:

You can have AutoIt run a different "Main" autoit script when you hit F5 instead of the current one, per folder, by doing the following:

  1. Run SciTE (might need administrator, depending on how autoit was installed)
  2. Options -> global properties (alt o g)
  3. Uncomment properties.directory.enable=1 (line 270 in my case)
  4. create a file SciTEDirectory.properties in the project's main folder
    • Alternatively, if you don't have admin or don't want to edit the global.properties for whatever reason, you can just skip step 1,2,3 and name it SciTE.properties
  5. Put in the file you created command.go.$(au3)="$(SciteDefaultHome)\..\AutoIt3.exe" "$(SciteDefaultHome)\AutoIt3Wrapper\AutoIt3Wrapper.au3" /run /prod /ErrorStdOut /in "NAME OF SCRIPT HERE.au3" /UserParams $(1) $(2) $(3) $(4)
  6. Save the file. Now anything you run in that folder or subfolder will run the main script when you hit F5

Using SciTEDirectory.properties effects that folder and subfolders, where as SciTE.properties only effects that folder. Apart from that they work the same


Original question:
I have a main script, and a bunch of includes / udf's. Almost every single time I edit my includes I hit F5 to run the script, but it runs the include instead. I'm tired of switching back to the main script's tab in SciTE to run it, just to switch back to the include. Is there some kind of #flag or option to set a "main au3 file" so when I hit F5, it will see that and run the main file instead?

Edited by corgano

0x616e2069646561206973206c696b652061206d616e20776974686f7574206120626f64792c20746f206669676874206f6e6520697320746f206e657665722077696e2e2e2e2e

Link to comment
Share on other sites

  • Developers

Guess you really want this since you posted it 3 times. (Merged :))

I can't imagine you have include files that you only need for one single main script, but a simple solution to you question could be to temporarily add an #include("path\mainscript.au3") at the end of the include while developing the include file.

Jos

Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Wait, what? Something must have messed up,  had no intention of posting this three times! Is there a way i can delete the duplicates? Sorry for the triple-post. Thanks mods

I will give  #include("path\mainscript.au3")  a try, but i think running the include first might have issues, because it uses global vars declared in the main.

Is there a SciTE option for this? like to check for a "makefile" of sorts with something like "mainscript=file.au3" in it, and then have SciTE run whatever mainscript is if the makefile exists, and if it doesn't run the current file? I know SciTE is very configurable but not sure if it can do something like this.

Edited by corgano

0x616e2069646561206973206c696b652061206d616e20776974686f7574206120626f64792c20746f206669676874206f6e6520697320746f206e657665722077696e2e2e2e2e

Link to comment
Share on other sites

How would SciTE, or any other program know that the include file you're editing isn't the main script, or know which script IS the main script?

Also, where are your #include lines in your main script if they depend on Global variables in the main script to work?

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

  • Developers
15 hours ago, corgano said:

Is there a SciTE option for this?

I assume you mean an #AutoIt3Wrapper directive and No there is none and I have no intent to even consider this as I doubt this will be used much.
As far as SciTE options is concerned: THe only option I can think of is to have the set of include files into its own directory and add a scite.properties to that directory in which you modify the F5/Run option to run the Main script instead of the file being edited.

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

4 hours ago, Jos said:

..add a scite.properties to that directory...

Wait, you can have a .properties on a per-folder basis? Does it override the au3.properties? Where in the SciTE docs do i find info on this? I wasn't sure what to search for. A folder-wide SciTE.properties that overwrites command.go.$(au3) would work perfectly!

0x616e2069646561206973206c696b652061206d616e20776974686f7574206120626f64792c20746f206669676874206f6e6520697320746f206e657665722077696e2e2e2e2e

Link to comment
Share on other sites

Thanks Jos, I think I found it. For anyone looking to set a custom command, here are the steps:

  1. Run SciTE (might need administrator, depending on how autoit was installed)
  2. Options -> global properties (alt o g)
  3. Uncomment properties.directory.enable=1 (line 270 in my case)
  4. create a file SciTEDirectory.properties in the project's main folder
    • Alternatively, if you don't have admin or don't want to edit the global.properties for whatever reason, you can just skip step 1,2,3 and name it SciTE.properties
  5. Put in the file you created command.go.$(au3)="$(SciteDefaultHome)\..\AutoIt3.exe" "$(SciteDefaultHome)\AutoIt3Wrapper\AutoIt3Wrapper.au3" /run /prod /ErrorStdOut /in "NAME OF SCRIPT HERE.au3" /UserParams $(1) $(2) $(3) $(4)
  6. Save the file. Now anything you run in that folder or subfolder will run the main script when you hit F5

I love this solution, it is a lot better than modding UDFs and works almost out-of-the-box. Thanks for pointing me in the right direction :D

Edited by corgano

0x616e2069646561206973206c696b652061206d616e20776974686f7574206120626f64792c20746f206669676874206f6e6520697320746f206e657665722077696e2e2e2e2e

Link to comment
Share on other sites

  • Developers

I would not recomment to modify SciTEGlobal.properties since this file will be overridden with the next installer.
Either go the SciTE.properties route or modify that setting in your SciTEUser.properties.

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

  • 2 years later...

I came across this post by accident, and just wanted to add my own quick fix to this problem. Personally I don't want to run the main script instead like OP does. I just want to avoid running it by accident causing tons of error messages in SciTE, and messing up my bookmarks

In the main script (important: #include-once is to avoid inadvertently looping):

#include-once
#include "name_of_the_udf.au3"

 

In every UDF I put these three lines in the top to avoid accidentally executing the UDF (or if I just want to F5 run it in SciTE to check its syntax):

 

#include-once
If @ScriptName  = "name_of_this_udf.au3" Then Exit SetError(1, ConsoleWriteError("! UDF CANNOT BE RUN !" & @CRLF), -99)
#include "name_of_main_script.au3"

 

 

EDIT: if you have your includes in a subdirectory of your main script dir, you just use relative paths instead.

Example:

#include-once
#include "includes/name_of_the_udf.au3"
#include-once
If @ScriptName  = "name_of_this_udf.au3" Then Exit SetError(1, ConsoleWriteError("! UDF CANNOT BE RUN !" & @CRLF), -99)
#include "../name_of_main_script.au3"

 

Edited by Irios

863nP4W.png discord.me/autoit  (unofficial)

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

×
×
  • Create New...