Jump to content

[UNSOLVED] #include in IF conditionally run statement


Fr33b0w
 Share

Recommended Posts

  • Moderators

Fr33b0w,

AutoIt runs all directives (such as #include) before running the code, so the file is always included.

Can you explain in more detail why you need to conditionally include this file? Then we might be able to offer some sensible workarounds.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

First of all, hi Melba23. You always give nice and practical help to people arround here so thank you for that.

I made a search GUI which is not piece of art for sure but it works for me. Since I do not code for a living (i would be already starve to death if I did) my scripts are very basic ones. And I have a problem when I am reading my old scripts because code is clattered...  Anyway I made just a gui for search (but now I am using it also to get lines of text in clipboard for furthure use when I write something.

 

Idea was to separate part of code which will be standard GUI with buttons and everything from a code which would be connected to a search and which i could easily change since the idea was 1 search - 1 file with code. So... 

 

Func z001()
#include <search\001\001.au3>
EndFunc
Func z002()
#include <search\002\002.au3>
EndFunc
Func z003()
#include <search\003\003.au3>
EndFunc
Func z004()
#include <search\004\004.au3>
EndFunc
Func z005()
#include <search\005\005.au3>
EndFunc
Func z006()
#include <search\006\006.au3>
EndFunc
Func z007()
#include <search\007\007.au3>

...


Func z157()
#include <search\157\157.au3>
EndFunc
Func z158()
#include <search\158\158.au3>
EndFunc
Func z159()
#include <search\159\159.au3>
EndFunc
Func z160()
#include <search\160\160.au3>
EndFunc

 

Its very basic GUI with 160 buttons which will execute whatever is in a file...

 

I will give you an example for that:

 

#cs
www.youtube.com (less then 4min and date)
#ce

$iMenustate = GUICtrlRead($edit1) ; return the state of the menu item
$search=GUICtrlRead($edit1, $GUI_READ_EXTENDED)
$ssearch=StringSplit($search," ")
$searchadd=""
For $i = 1 To $ssearch[0]
$searchadd=$searchadd&$ssearch[$i]&"+"
Next
$searchadd=StringTrimRight($searchadd,1)
ShellExecute('https://www.youtube.com/results?sp=CAISAhgBUBQ%253D&q=' & $searchadd & '')

second line is what will appear as a button name (between #cs and #cs) so i dont have to include that in main script also

it reads whatever is written in edit field in main script and then combine other data with it. Since other web pages have different search codes I did it like this so I can search one expression on many different pages with just a press of a button. "Space" is a splitter if there is more then one word to search and it is replaced by a "+" because it usually is like that (sometimes it could be a "&" character. Then it trimms a last char. In this case there is no need to add anything after the searching data part but sometimes there is site that demands some data after that so i should add that after

$searchadd & '')

Anyway I hope you know what am I doing in order to help me because I am not :)

Link to comment
Share on other sites

Anyway...   I dont really need a help because my idea was to use separated small files for every search and not to cut and paste in main script whenever i want to change order of buttons or what buttons will do.  problem is that I always must have 160 files or script would brake. And all files must have same names... I have 001.au3 to 160.au3. If there is no need for a button function I would put a zero byte file (123.au3 for example). What do you think?

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...