Sign in to follow this  
Followers 0
NTKBO

Help reading INI for variables

6 posts in this topic

Hello again, still working on my first script.

I have an INI file with one section "[Locations]" and two keys "Newsreader" & "FoldersLoc"

[Locations]
Newsreader = C:\Program Files\Communications\Usenet\Auto\NewsBin\V5 and Up\nbpro.exe
FoldersLoc = F:\Downloads\Newsbin\~Folders.bat

My goal is to be able to move this script (once compiled) to any directory needed, keeping it's INI file with it. To this end, I do not wish to hard code the INI folder's path, so I created a Variable for this:

Dim $g_szVersion , $BatPath , $News , $Val , $Param ,$Path
$Path = '"'&@ScriptDir & "\NZButil.ini"&'"'
MsgBox(4096, "Variable Check", "$Path: "&$Path); test $Path is correct

This seems to get the correct path.

In my main section, I can't seem to retrieve the "Newsreader" key nor "FoldersLoc" key:

Note: I've tried it with quotes in the "iniRead" and without (niether seem to work).

$News = iniRead ( $Path , "Locations", "Newsreader" , "Newsreader Not Found" )
$Param = $CmdLine[1]
MsgBox(4096, "Paramiters sent", "Result: "&$News&" "&$Param)
;$Val=RunWait ( $News & ' "' & $Param & '"') <- Will be actual line after testing
$BatPath = IniRead ( "$Path", "Locations", "FoldersLoc" , "Not Found" )
MsgBox(4096, "Batch command:", "Result: "&$BatPath&"")
;Run($BatPath)<- Will be actual line after testing

I know I'm missing SOMETHING.

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

$BatPath = IniRead ( "$Path", "Locations", "FoldersLoc" , "Not Found" )

should be

$BatPath = IniRead ( $Path, "Locations", "FoldersLoc" , "Not Found" )

(u had quotes around the variable)

--hope this helps

Edited by cdkid

AutoIt Console written in C#. Write au3 code right at the console :D_FileWriteToLineWrite to a specific line in a file.My UDF Libraries: MySQL UDF Library version 1.6 MySQL Database UDF's for AutoItI have stopped updating the MySQL thread above, all future updates will be on my SVN. The svn location is:kan2.sytes.net/publicsvn/mysqlnote: This will still be available, but due to my new job, and school hours, am no longer developing this udf.My business: www.hirethebrain.com Hire The Brain HireTheBrain.com Computer Consulting, Design, Assembly and RepairOh no! I've commited Scriptocide!

Share this post


Link to post
Share on other sites

i think the problem is your quotes in $path...it works without them

;$Path = '"'&@ScriptDir & "\NZButil.ini"&'"'
$Path = @ScriptDir & "\NZButil.ini"
msgbox(0, "", $Path)
$newsreader = IniRead($path, "Locations", "Newsreader" , "Newsreader Not Found" )
msgbox(0, "", $newsreader)

and what was mentioned above


Andrew Calcutt

Http://www.Vistumbler.net

Http://www.TechIdiots.net

Its not an error, its a undocumented feature

Share this post


Link to post
Share on other sites

$BatPath = IniRead ( "$Path", "Locations", "FoldersLoc" , "Not Found" )

should be

$BatPath = IniRead ( $Path, "Locations", "FoldersLoc" , "Not Found" )

(u had quotes around the variable)

--hope this helps

It is helpfull to know the quotes aren't needed, but the first instance:

$News = iniRead ( $Path , "Locations", "Newsreader" , "Newsreader Not Found" )

Did not have quotes, but still didn't work. :lmao:

Thank you for your help!

Share this post


Link to post
Share on other sites

i think the problem is your quotes in $path...it works without them

;$Path = '"'&@ScriptDir & "\NZButil.ini"&'"'
$Path = @ScriptDir & "\NZButil.ini"
msgbox(0, "", $Path)
$newsreader = IniRead($path, "Locations", "Newsreader" , "Newsreader Not Found" )
msgbox(0, "", $newsreader)

and what was mentioned above

That was the ticket!

$ACalcutt= :lmao:

Thank to both you, and cdkid !

AutoIt seems to be all about putting useful features in when authors refuse!!

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

i was refering to this

$Path = '"'&@ScriptDir & "\NZButil.ini"&'"'

should be

$Path = @ScriptDir & "\NZButil.ini"

(not sure if you saw my other post befire posting the one above)

edit: i see you noticed :-D

Edited by ACalcutt

Andrew Calcutt

Http://www.Vistumbler.net

Http://www.TechIdiots.net

Its not an error, its a undocumented feature

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