Sign in to follow this  
Followers 0
Jeff987

functions 'read from file' at runtime...?

5 posts in this topic

#1 ·  Posted (edited)

I would like to read a file, text or ini to get functions to perform...

this way I could change the actions after the main code is compiled...

I have this as an example, before I build it into my real project I'm working on.

what I started with is a method to populate a combo box and then select the function that was selected. this works. I had tried this with the first script as the gui and the functions in an include...

I realize that this embeds it into the .exe when compiled.

So I'm not sure how to go about this if its even possible...

the batches.au3 is what I would like to be able to fileinstall() and edit after compile. It will be mostly batch type operations, but might need to change here or there over time

#include 
#include "batches.au3"
#include 
Local $ii = "", $iii = ""
#region - GUI Create
Opt("GuiOnEventMode", 1)
GUICreate("test")
GUISetOnEvent($GUI_EVENT_CLOSE, "Terminate")
Local $fx_combo = GUICtrlCreateCombo("", 25, 25)
For $i = 0 To UBound($fx_fx) - 1
If $fx_list[$i] == "" Then ContinueLoop
If $i == 0 Then
$ii = $fx_list[$i]
ContinueLoop
Else
$ii &amp= "|" & $fx_list[$i]
EndIf
Next
GUICtrlSetData($fx_combo, $ii, $fx_list[0])
GUICtrlCreateButton("Click to ...", 226, 23)
GUICtrlSetOnEvent(-1, "_combo")
Func _combo()
$iii = GUICtrlRead($fx_combo)
Local $iiii = ($fx_fx[_ArraySearch($fx_list, GUICtrlRead($fx_combo))])
Execute($iiii & '()')
EndFunc   ;==>_combo

#endregion - GUI Create

GUISetState(@SW_SHOW)
HotKeySet("{ESC}", "Terminate")

While 1
Sleep(100)
WEnd

Func Terminate()
Exit 0
EndFunc   ;==>Terminate

here's the batches.au3 
#include "Constants.au3"
Global $fx_list[20] = ['Dir','Get Dir (X)','Set AutoLogon','Change Password','Set Services','','','','','','','','','','','','','','']
Global $fx_fx[20] = ['_dir','_getDir()','_AutoLogon()','_Password()','_svcs()','','','','','','','','','','','','','','','']

Func _dir()
Local $sReturn =Run(@ComSpec & ' /c ' & 'Dir')
if @error then MsgBox(-1,"error","screwed up",5)
MsgBox(-1,"Dir", $sReturn)
EndFunc
Func _getDir($dir=@WorkingDir)
Global $iPID = Run(@ComSpec & ' /c dir '&$dir, @SystemDir, @SW_HIDE, $STDOUT_CHILD + $STDERR_CHILD), $sReturn = ''
_while()

EndFunc

Func _while()
While 1
$sReturn &= StdoutRead($iPID)
If @error Then
ExitLoop
EndIf
WEnd
;ConsoleWrite($sReturn & @LF)
EndFunc
Edited by Jeff987

Share this post


Link to post
Share on other sites



Your code is hard to follow, but from your description, I would recommend using an ini file. You can't embed something permanently and be able to edit it after it is embeded. If you want to change things later, it must be in a separate file. Ini files are perfect for that.


RAID Calculator | Software Installer

The truth has been suppressed since the dawn of time.

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

I'm not to certain, but I think you might be able to do something with embedded files

say for example you use a file from resource, you might be able to replace that resource

after compilation.

Sorry I don't know how to use files from resource, and am no 100% that you can do

what I described.

Edited by JohnOne

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Share this post


Link to post
Share on other sites

so maybe I try to say I want to read a text or an ini.

$variable=filereadline("somefile",1)

where $variable will be equal to Consolewrite("test" &@CR)

Can this be made to work

_func()

Func _func()

execute($variable)

endFunc

Share this post


Link to post
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
Sign in to follow this  
Followers 0