Jump to content

extended help using #include


norax
 Share

Recommended Posts

im writing a script that will essentially #include specific files like plugins to the main script.

here is what i have so far, im having a problem with using 2 or more different "plugins" it will only keep including the data from when it loaded the first time even tho the file is rewritten properly. if i restart it works fine untill i try a different plugin again. any thoughts?

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIListBox.au3>
#include <WindowsConstants.au3>
#Include <File.au3>

$Form1 = GUICreate("Plugin Loader", 396, 138, 192, 124)
$List1 = GUICtrlCreateList("", 0, 0, 297, 136)
$Button1 = GUICtrlCreateButton("Launch Plugin", 304, 0, 91, 25)
$Button2 = GUICtrlCreateButton("Add Plugin", 304, 32, 91, 25)
$Button3 = GUICtrlCreateButton("Remove Plugin", 304, 56, 91, 25)
GUISetState(@SW_SHOW)

$plugins = ""
$plugint = IniRead("config.ini", "Plugins", "Plugint", "")

$0 = 1
While $0 <= $Plugint
    $plug = IniRead("config.ini", "Plugins", "Plugin" & $0, "")
    $plugins = $plugins & " " & $plug
    GUICtrlSetData($List1, $plug)
    $0 += 1
WEnd

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            $plugname = GUICtrlRead($List1) & ".e2s"
            BufferScript($plugname)

    EndSwitch
WEnd

Func BufferScript($plugname)
    $0 = 1
    FileDelete("plugtemp.e2s")
    While $0 <= _FileCountLines($plugname)
        FileWrite("plugtemp.e2s", FileReadLine($plugname, $0) & @CRLF)
        $0 += 1
    WEnd
    #include "plugtemp.e2s"
EndFunc

heres the config file

[Plugins]
Plugint=2
Plugin1=WinRefresh
Plugin2=EditScript

to test make a file with .e2s as extension and put anything for code in it ie: msgbox(0,"1","1"). and a config file that is setup similar to the above. ty in advanced

Edited by norax
Link to comment
Share on other sites

#include

That weird character at the start makes it a "compiler directive". Includes are not conditional thereby. Whatever is in the include will literally be copied in the script at the location of the include line before the script executes.

If you want to use #include for plugins you have to have everything as au3's and restart for any change.

Link to comment
Share on other sites

#include

That weird character at the start makes it a "compiler directive". Includes are not conditional thereby. Whatever is in the include will literally be copied in the script at the location of the include line before the script executes.

If you want to use #include for plugins you have to have everything as au3's and restart for any change.

would any other function be more suitable?
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...