Jass Posted May 11, 2009 Share Posted May 11, 2009 Hey peoples, I want to declare some variables in an external textfile which has to be read from my compiled script. The background is that I want to write a script for a simple file backup for our customers. Because from machine to machine the install dirs are different I want my customers to insert the dirs into a textfile where all variables I need in my script are declared. After some testing I now know that my textfile will be completely inserted into the exe-file after compiling and because of this it's not possible to edit the variables after compiling my script. Is there a possibility to include an external file to my script but only the way that the compiled one will use the textfile itself instead of include it into my script? Thanks in advance. Dennis Link to comment Share on other sites More sharing options...
lordicast Posted May 11, 2009 Share Posted May 11, 2009 Help file helps ;check help for filewrite,fileread,fileopen $file = FileOpen(@ScriptDir & "\test.txt", 0) If $file = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf $chars = FileRead($file, 1) FileClose($file) If @error = -1 Then ExitLoop MsgBox(0, "Txt file contains: ", $chars);$chars is you variable from file While 1 Sleep(100) Wend [Cheeky]Comment[/Cheeky] Link to comment Share on other sites More sharing options...
DaRam Posted May 11, 2009 Share Posted May 11, 2009 You are better of using INI files to do this (store varying info.). Use built in AutoIt function IniRead to read it at runtime. Link to comment Share on other sites More sharing options...
TurionAltec Posted May 11, 2009 Share Posted May 11, 2009 Look into ini files and iniread. make a file called "values.ini" [programs] Office=C:\Program Files\Microsoft Office Firefox=C:\Program Files\Mozilla Firefox Then in your program $Officelocation=iniread("values.ini","programs","Office","") $Firefoxlocation=iniread("values.ini","programs","Firefox","") You can also use inireadSection if you wanted, but this may be easier. Link to comment Share on other sites More sharing options...
Jass Posted May 12, 2009 Author Share Posted May 12, 2009 (edited) Ok thanks a lot for the information. @lordicast: I was searching in the helpfile but didn't know the keyword "fileopen". Edit: iniread works great, thank you! Edited May 12, 2009 by Jass Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now