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: Open a File present in Windows Directory
Topic Summary: Open a File present in Windows Directory
Created On: 24-Sep-2008 06:58
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.
 24-Sep-2008 06:58
User is offline View Users Profile Print this message


Irfaan Jamal

Posts: 30
Joined: 13-Feb-2008

Hello All,

I would like to open a file which is existing in a windows directory path. For example, if I want to open C:\Temp\Main.html from DXL then how can I open it?

Thanks & Regards
Irfan
Report this to a Moderator Report this to a Moderator
 24-Sep-2008 07:17
User is offline View Users Profile Print this message


Pekka Mäkinen

Posts: 276
Joined: 18-Mar-2004

Open a Stream to read from file "c:\\temp\\main.html", example in DXL help:

Files and streams example program
This example creates a temporary file, writes some data to it, saves it, renames it, reads from the new file, and then deletes it:

// file (Stream) DXL example
/*
example file I/O program
*/
string filename = tempFileName // get a scratch
// file
print "Writing to " filename "\n"
Stream out = write filename
out << 'x' "" // write a char (via a string)
out << 1.001 "\n" // a real (must be last
// thing on line)
out << 42 "\n" // an int (has to be last thing on line)
out << "hello world\na second line\n"
// a string
close out // write a file to read back in again
string oldName = filename
filename = tempFileName // get a new file name
renameFile(oldName, filename) // move the file we wrote earlier
print "Reading from " filename "\n"
Stream input = read filename
char c // declare some variable
real r
int i
input >> c
input >> r
input >> i
print c " " r " " i "\n" // check data type read/writes
string str // do rest line by line
while (true) {
input >> str // read a line at a
// time
if (end of input) break
print str "\n" // str does not
// include the newline
}
print readFile filename // read the whole lot
// into a string
close input
deleteFile filename // delete the file

-------------------------
Pekka.Makinen@softqa.fi
SoftQA Oy -http://www.softqa.fi/
Report this to a Moderator Report this to a Moderator
 24-Sep-2008 07:43
User is offline View Users Profile Print this message


Irfaan Jamal

Posts: 30
Joined: 13-Feb-2008

Thanks for your reply.

I think you have mis understood my question. Or maybe my statement was confusing.

My question was to open a file in a window. Not to read the contents of the file in the stream.

Well, I achieved it by using activateURL.

But the activateURL will just work for HTML pages I guess.

Any idea how to open an existing TextFile/WordFile/ExcelFile in a new window?

the system command can be used. but is there any other way?

Thanks & Regards
Irfaan
Report this to a Moderator Report this to a Moderator
 24-Sep-2008 21:23
User is offline View Users Profile Print this message


Louie Landale

Posts: 2070
Joined: 12-Sep-2002

You can use the 'system' command to open files in Windows. I've got lots of DXL that does this:

system("Notepad.exe " NameTextFile).

In your case with an HTM file, I suppose you'd need to do this:

system("explorer.exe " NameHTMFile)

These work so long as the executable (notepad) is in the 'path', in this case c:\Windows. Other files such as WinWord.exe will need to be located on the machine and put into the system command; that's actually rather difficult since it can be in different locations on different systems.

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