Welcome to Telelogic Product Support
  Home Downloads Knowledgebase Case Tracking Licensing Help Telelogic Passport
Telelogic DOORS (steve huntington)
Decrease font size
Increase font size
Topic Title: Config file to Buffer
Topic Summary:
Created On: 26-Jun-2006 21:24
Status: Post and Reply
Linear : Threading : Single : Branch
Search Topic Search Topic
Topic Tools Topic Tools
Quick Reply Quick Reply
Subscribe to this topic Subscribe to this topic
E-mail this topic to someone. E-mail this topic
Bookmark this topic Bookmark this topic
View similar topics View similar topics
View topic in raw text format. Print this topic.
 26-Jun-2006 21:24
User is offline View Users Profile Print this message


Louie Landale

Posts: 2070
Joined: 12-Sep-2002

I notice for regular files (DXL chapter General Language Facilities section Files and streams) that you can use command "readFile(NameFile)" to get the entire contents of a file without actually opening and reading explicitely.

I don't see a comperable command for Configuration Files which are in the next section. You need to loop throug each line into a buffer, then combine that into a accumulation buffer adding newline characters after each line.

Is there a single command to read the entire contents of a Config file?

- Louie
Report this to a Moderator Report this to a Moderator
 27-Jun-2006 18:58
User is offline View Users Profile Print this message


Dennis Lockshine

Posts: 113
Joined: 7-Apr-2003

Louie,

You can read an entire regular file or conf file into a buffer with one read and redirect command. You must be sure to create your buffer to a resonable length, otherwise the file will only be read up until the length of the buffer has been reached. This does not address your original question but it should make reading configuration files easier for you. See attached code.

-Dennis
Report this to a Moderator Report this to a Moderator
 27-Jun-2006 21:27
User is offline View Users Profile Print this message


Louie Landale

Posts: 2070
Joined: 12-Sep-2002

I did that. When the buffer was declared too small the data was of course truncated and sometimes give a couple extra garbage characters. When the buffer was declared too big the rest of the buffer was filled with psuedo random stuff from the file. At least it was filled like that somtimes.

Anyway, your solution now seems to be working. But I don't feel good about it. I did change "print tempStringOf(b)" to "print stringOf(buf)" and that seemed to help.

- Louie
Report this to a Moderator Report this to a Moderator
 28-Jun-2006 14:54
User is offline View Users Profile Print this message


Dennis Lockshine

Posts: 113
Joined: 7-Apr-2003

A while ago I did some testing to see if there was indeed a difference between stringOf() and tempStringOf() and came to the conclusion that there was no savings, in either execution time or memory conservation, in using the tempStringOf perm.

-Dennis
Report this to a Moderator Report this to a Moderator
 29-Jun-2006 08:24
User is offline View Users Profile Print this message


Paul Tiplady

Posts: 176
Joined: 28-Oct-2003

If you want to make the buffer just the right size for the stream, you can get the size of the stream (file or config file) using the 'size' perm on the 'Stat' data type - see the chapter on OS interface, 'create (status handle)' perm.

Paul.

-------------------------


Paul dot Tiplady at TRW dot com
TRW Automotive
Report this to a Moderator Report this to a Moderator
 29-Jun-2006 12:58
User is offline View Users Profile Print this message


Reik Schroeder

Posts: 361
Joined: 28-Jul-2003

Hi Dennis,

there is a difference between stringOf() and tempStringOf()!

If you have changed the length of a buffer by using void length(Buffer b, int len) function, you can not use tempStringOf(), because it will still return the uncuted string.

Greetings
Reik Schröder

-------------------------
Evosoft GmbH
for Siemens Industry Sector


Berlin, Germany
Report this to a Moderator Report this to a Moderator
 29-Jun-2006 14:05
User is offline View Users Profile Print this message


Dennis Lockshine

Posts: 113
Joined: 7-Apr-2003

Thanks for clearing that up, Reik. The point I was making was that since there is no time/memory savings for using the tempStringOf() perm that I do not use it, and therefore would not run into that issue.

Thanks,
Dennis
Report this to a Moderator Report this to a Moderator
 29-Jun-2006 14:12
User is offline View Users Profile Print this message


Bruce Tuskey

Posts: 77
Joined: 2-Mar-2004

tempStringOf does not add an entry on the string table. For small programs, or programs that do not do large string compares, there is little advantage. However, in large programs with lots of string handling, tempStringOf is great for use in conditional statements.

-------------------------
Bruce Tuskey
Sr. Principle Engineer
Tuskey@gmail.com

"All that is gold does not glitter, not all those who wander are lost:..." - Gandalf the Grey (JRR Tolkien)
Report this to a Moderator Report this to a Moderator
Statistics
20925 users are registered to the Telelogic DOORS forum.
There are currently 1 users logged in.
The most users ever online was 15 on 15-Jan-2009 at 16:36.
There are currently 0 guests browsing this forum, which makes a total of 1 users using this forum.
You have posted 0 messages to this forum. 0 overall.

FuseTalk Standard Edition v3.2 - © 1999-2009 FuseTalk Inc. All rights reserved.