Home     |     .Net Programming    |     cSharp Home    |     Sql Server Home    |     Javascript / Client Side Development     |     Ajax Programming

Ruby on Rails Development     |     Perl Programming     |     C Programming Language     |     C++ Programming     |     IT Jobs

Python Programming Language     |     Laptop Suggestions?    |     TCL Scripting     |     Fortran Programming     |     Scheme Programming Language


 
 
Cervo Technologies
The Right Source to Outsource

MS Dynamics CRM 3.0

TCL(Tool Command Language) Scripting

iniFile question


I am using the inifile package from tcllib and have a question about
the open routine.  Is it possible to open the ini file in an append
mode?  I would like to always have a header at the beginning of the
file
and using the ::ini::comment comes out at a random location in the
file.  So, if I could write some
data to the beginning of the file and then let the ::ini code append
to that, it would be great.

yep, I could post-process it too, but I was hopeing there was a more
direct approach.

Thanks,

John

On 22 Mai, 22:39, john_hug@mentor.com wrote:
> I am using the inifile package from tcllib and have a question about
> the open routine.  Is it possible to open the ini file in an append
> mode?  

man inifile:
::ini::open file ?mode?
Opens an INI file and returns a handle that is used by other commands.
Mode has the same types as the open command. The default mode is r+.

So just specify "a" as mode :)

On May 23, 3:18 am, suchenwi <richard.suchenwirth-

bauersa@siemens.com> wrote:
> On 22 Mai, 22:39, john_hug@mentor.com wrote:> I am using the inifile package from tcllib and have a question about
> > the open routine.  Is it possible to open the ini file in an append
> > mode?  

> man inifile:
> ::ini::open file ?mode?
> Opens an INI file and returns a handle that is used by other commands.
> Mode has the same types as the open command. The default mode is r+.

> So just specify "a" as mode :)

Not sure what version of tcllib youre using but mine says:

Mode has the same types as the const open command, with the exception
that mode "a" is not supported. The default mode is "r+".

Append mode is not supported since opening a file reads the existing
contents so its kind of naturally an append. The files are not really
meant to be human readable, its a way to programatically save and read
data.

to the original poster: are you using v0.2? Comments should appear
just above their related section or key, however the sections may be
in a random order.

On May 23, 3:18 am, suchenwi <richard.suchenwirth-

bauersa@siemens.com> wrote:
> On 22 Mai, 22:39, john_hug@mentor.com wrote:> I am using the inifile package from tcllib and have a question about
> > the open routine.  Is it possible to open the ini file in an append
> > mode?  

> man inifile:
> ::ini::open file ?mode?
> Opens an INI file and returns a handle that is used by other commands.
> Mode has the same types as the open command. The default mode is r+.

> So just specify "a" as mode :)

Not sure what version of tcllib youre using but mine says:

Mode has the same types as the const open command, with the exception
that mode "a" is not supported. The default mode is "r+".

Append mode is not supported since opening a file reads the existing
contents so its kind of naturally an append. The files are not really
meant to be human readable, its a way to programatically save and read
data.

to the original poster: are you using v0.2? Comments should appear
just above their related section or key, however the sections may be
in a random order.

On 23 Mai, 17:49, aar@gmail.com wrote:

> Not sure what version of tcllib youre using but mine says:

> Mode has the same types as the const open command, with the exception
> that mode "a" is not supported. The default mode is "r+".

> Append mode is not supported since opening a file reads the existing
> contents so its kind of naturally an append. The files are not really
> meant to be human readable, its a way to programatically save and read
> data.

> to the original poster: are you using v0.2?

My inifile is 0.1 as came with ActiveTcl 8.4.9.
On 23 Mai, 17:49, aar@gmail.com wrote:

> Not sure what version of tcllib youre using but mine says:

> Mode has the same types as the const open command, with the exception
> that mode "a" is not supported. The default mode is "r+".

> Append mode is not supported since opening a file reads the existing
> contents so its kind of naturally an append. The files are not really
> meant to be human readable, its a way to programatically save and read
> data.

> to the original poster: are you using v0.2?

My inifile is 0.1 as came with ActiveTcl 8.4.9.
On 23 Mai, 17:49, aar@gmail.com wrote:

> Not sure what version of tcllib youre using but mine says:

> Mode has the same types as the const open command, with the exception
> that mode "a" is not supported. The default mode is "r+".

> Append mode is not supported since opening a file reads the existing
> contents so its kind of naturally an append. The files are not really
> meant to be human readable, its a way to programatically save and read
> data.

> to the original poster: are you using v0.2?

My inifile is 0.1 as came with ActiveTcl 8.4.9.
On 23 Mai, 17:49, aar@gmail.com wrote:

> Not sure what version of tcllib youre using but mine says:

> Mode has the same types as the const open command, with the exception
> that mode "a" is not supported. The default mode is "r+".

> Append mode is not supported since opening a file reads the existing
> contents so its kind of naturally an append. The files are not really
> meant to be human readable, its a way to programatically save and read
> data.

> to the original poster: are you using v0.2?

My inifile is 0.1 as came with ActiveTcl 8.4.9.
On 23 Mai, 17:49, aar@gmail.com wrote:

> Not sure what version of tcllib youre using but mine says:

> Mode has the same types as the const open command, with the exception
> that mode "a" is not supported. The default mode is "r+".

> Append mode is not supported since opening a file reads the existing
> contents so its kind of naturally an append. The files are not really
> meant to be human readable, its a way to programatically save and read
> data.

> to the original poster: are you using v0.2?

My inifile is 0.1 as came with ActiveTcl 8.4.9.
On May 23, 9:31 am, suchenwi <richard.suchenwirth-

I am the original poster and I also have version 0.1 of inifile. And
to
answer another comment, yes my comments appear just before the section
they are tied too and yes, the file is written in a seemingly random
order.

I just want the header at the beginning of the file so that we can
see
what version of our tool created the file and potentially use it to
determine
whether it is a valid INI file or not.  I have a bug report that one
of our
QA folks has tried feeding out INI file reader (a wrapper around the
tcllib
inifile stuff) many different types of text files and does not get an
error.

Any way, I guess extra processing on my part is the answer to my
original
question.

Thanks,

John

On May 23, 9:31 am, suchenwi <richard.suchenwirth-

I am the original poster and I also have version 0.1 of inifile. And
to
answer another comment, yes my comments appear just before the section
they are tied too and yes, the file is written in a seemingly random
order.

I just want the header at the beginning of the file so that we can
see
what version of our tool created the file and potentially use it to
determine
whether it is a valid INI file or not.  I have a bug report that one
of our
QA folks has tried feeding out INI file reader (a wrapper around the
tcllib
inifile stuff) many different types of text files and does not get an
error.

Any way, I guess extra processing on my part is the answer to my
original
question.

Thanks,

John

Theres no real reason it needs to be at the beginning of the file

witness:

set f [ini::open myfile.ini]
if {![ini::exists $f main] || ![string match {*Tool Version 1.4*}
[ini::comment $f main]]} {
return -code error "Incompatible ini file version"

}

On May 23, 2:58 pm, john_hug@mentor.com wrote:

aar@gmail.com wrote:
> Theres no real reason it needs to be at the beginning of the file

> witness:

> set f [ini::open myfile.ini]
> if {![ini::exists $f main] || ![string match {*Tool Version 1.4*}
> [ini::comment $f main]]} {
> return -code error "Incompatible ini file version"
> }

Or...

[Version]
ToolVersion=1.4

I mean, really, comments are for the part that *isn't* machine readable. :-)

--
   Darren New / San Diego, CA, USA (PST)
     His kernel fu is strong.
     He studied at the Shao Linux Temple.

Add to del.icio.us | Digg this | Stumble it | Powered by Megasolutions Inc