Jump to content

INI file functions


Recommended Posts

Is there a reason why file handles are not acceptable for INIRead and INIWrite functions?

;;This works

$output = IniRead("C:\Windows\avrack.ini", "Settings", "Volume", "")
MsgBox(0, "test", $output & @CRLF & @ERROR)

;;This doesn't
$file = FileOpen("C:\Windows\avrack.ini", 0)
$output = IniRead($file, "Settings", "Volume", "")
$output = IniRead("C:\Windows\avrack.ini", "Settings", "Volume", "")
MsgBox(0, "test", $output & @CRLF & @ERROR)
FileClose($file)

Writing AutoIt scripts since

_DateAdd("d", -2, _NowCalcDate())
Link to comment
Share on other sites

Is there a reason why file handles are not acceptable for INIRead and INIWrite functions?

;;This works

$output = IniRead("C:\Windows\avrack.ini", "Settings", "Volume", "")
MsgBox(0, "test", $output & @CRLF & @ERROR)

;;This doesn't
$file = FileOpen("C:\Windows\avrack.ini", 0)
$output = IniRead($file, "Settings", "Volume", "")
$output = IniRead("C:\Windows\avrack.ini", "Settings", "Volume", "")
MsgBox(0, "test", $output & @CRLF & @ERROR)
FileClose($file)

<{POST_SNAPBACK}>

Why do you need the handle for read an INI file?

Simply, just compare the documentation: About IniRead page says :

IniRead ( "filename", "section", "key", "default" )

not like FileRead , the syntax is:

FileRead ( filehandle or "filename", count )

Mainly, IniRead wasn't designed for use file handles.
Link to comment
Share on other sites

Is there a reason why file handles are not acceptable for INIRead and INIWrite functions?

because IniRead() and IniWrite() are not implemented to accept a file handle. See source code script_file.cpp AutoIt_Script::F_IniRead.

Cheers

Kurt

__________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *

Link to comment
Share on other sites

I know according to the help file that one says that file handles are permitted the other does not. My question is, Why not?

If I can start learning more advanced C++ programming techniques, I might try to work on that code (just a wee bit).

Writing AutoIt scripts since

_DateAdd("d", -2, _NowCalcDate())
Link to comment
Share on other sites

I know according to the help file that one says that file handles are permitted the other does not.  My question is, Why not?

If I can start learning more advanced C++ programming techniques, I might try to work on that code (just a wee bit).

<{POST_SNAPBACK}>

The INI functions wrap underlying INI-related Windows API calls. Unless you are prepared to write your own INI reading/writing code and re-implement all of it, there is no point (or sense) in making the INI functions accept a file handle.
Link to comment
Share on other sites

I know according to the help file that one says that file handles are permitted the other does not.  My question is, Why not?

<{POST_SNAPBACK}>

Writing to an INI file is similar to writng to registry. Both IniWrite and RegWrite are more related to each other then as to FileWrite. You cannot have a handle for RegWrite? So IniWrite should not have one.
Link to comment
Share on other sites

Well to further concrete the idea of INI and Registry being related...

Before the Registry there were INI files. They became very numerous, and Micro$oft wanted a central place to configure applications. They came up with what is known to us today as the Registry.

*Disclaimer* Micro$oft may not have come up with the 'registry' idea, but they are certainly using it.

JS

AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

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