![]() |
Telelogic DOORS (steve huntington) | ![]() |
new topic :
profile :
search :
help :
dashboard :
calendar :
home
|
||
Latest News:
|
|
Topic Title: Config file to Buffer Topic Summary: Created On: 26-Jun-2006 21:24 Status: Post and Reply |
Linear : Threading : Single : Branch |
![]() |
![]()
|
![]() |
|
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 |
|
![]() |
|
![]() |
|
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 |
|
![]() |
|
![]() |
|
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 |
|
![]() |
|
![]() |
|
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 |
|
![]() |
|
![]() |
|
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 |
|
![]() |
|
![]() |
|
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 |
|
![]() |
|
![]() |
|
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 |
|
![]() |
|
![]() |
|
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) |
|
![]() |
Telelogic DOORS
» DXL Exchange
»
Config file to Buffer
|
![]() |
FuseTalk Standard Edition v3.2 - © 1999-2009 FuseTalk Inc. All rights reserved.