473,327 Members | 2,103 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

External File access Question

I'm attempting to get a commercial adaptation of a rail traffic-control simulation model to interact with a home-brewed program duplicating the dispatcher's thinking, previously written (without any I/O interface) in BASIC a few years ago, now being redeveloped in C++.

I've been learning C++ for a couple of months; have no problem with commonly-used programming functions, what little I've scraped off the 'Net makes a reference to "high-level file access"; we could use a reference more attuned to general orientation if anyone can suggest one.

The commercial program has a fully-developed external I/O interface using a set of text files which reside in the same folder as the application (O/S is Windows XP Pro).

I can generate commands, which should cause changes in settings on the commercial application when recognized, but am not familiar with the technique to enter them on the input file, which apparently can't be relocated to my program.

UPDATE

Since the previous post I have been able to send text to the destination file, but only when that file resides on a 3.5" diskette.

Attempts to re-orient the output to a file on the hard disk by changing the destination from 'c' to 'a' were unsuccessful, whether the destination file resides in a separate folder or not

To further elaborate:

the command

outFile.open ("a:mydata.out");

will write the text specified as "mydata" to a diskette

But the command

outFile.open ("c:mydata.out"};

won't create similar output on the hard disk, nor will the command

outFile.open {"c:myfolder/mydata.out);

write that output to a specified folder

the only preprocessor direcives in use are "iostream","fstream" and "iomanip", if this is a factor.

Thank you for your help
Oct 14 '07 #1
5 1629
weaknessforcats
9,208 Expert Mod 8TB
If you are using an fstream, you must open it as an injout or ouput file. And , if output, say where the writing starts. At the beginning?? Appended to the end??

Also, if you have in input file, then it cannot be created. If it was, then it would be an output file.

You might post a little more of your code.
Oct 15 '07 #2
Thank you for pointing me in the right direction; I'll add some more specific details.

The program is structured as follows, with actual starements numbered (CAPITALIZED TEXT does not represent actual code)

//PREPROCESSOR INFO//
//NAMESPACE//
//MAIN//

(1) infstream inFile;
(2) ofstream outFile;

declare/create files

(3) inFile.open ("a.testa.txt");
(4) outfile.open ("a.results.out");

open I/O files

(5) outFile<<fixed<<showpoint;
(6) outFile<<setprecision(2);

decimal manipulators

(7) outFile<<"LABEL"<<SAMPLEID<<endl;
(8) outFile<<"LABEL"<<INPUTDATA<<endl;

repeats/verifies inputted data

//CALCULATION OF OUTPUTTED DATA//

(9) outFile<<"LABEL"<<RESULTS<<endl;

writes calculated value to file

(10) inFile.close();
(11) outFile.close();

closes files

//END OF PROGRAM STRUCTURE//

As originally written above, the program read data from a diskette and wrote the results to that diskette as an OUT file.

When an empty NotePad text file, designated 'results' was prepositioned on the diskette and specified as above, the program had no difficulty writing to the file.

However, when the same flie was moved to the hard disk and the code changed to 'outFile.open("c.results.out")', no output of any kind was generated, whether the destination file 'results' resided in a separate folder or not.

multiple 'outFile.open' statements to both 'c' and 'a' also generated no output.

The files appear to open and close normally, so it would appear that the issue requires further specification of the file stream variables, associating them more directly with the I/O sources/devices.

The destination text file must reside in the same folder as the application for which it is intended, and is "wiped clean" every time new input is sent.

Again, my thanks for any help you can offer.

regards, Eddie Sand
Oct 21 '07 #3
weaknessforcats
9,208 Expert Mod 8TB
You may have to specify the path to the file when you open it.

You may have to specify where the reading or writing is to start. There are defaults that may not be the ones you want.

The location of the file does not affect reading or writing.
Oct 22 '07 #4
RRick
463 Expert 256MB
Have you tried adding the root '\' to the file name? You will need this for the path name.

Instead of using C:xxx use C:\xxx.
Oct 22 '07 #5
Thanks to you both; the missing slash turned out to be the answer. I'm sure I'll have more issues as this project advances.

HISTORICAL FOOTNOTE:

Until the development of the higway and air networks after World War II, there was a small market for fiction centered around the railroads. Eddie Sand, a creation of Saturday Evening Post stringer Harry Bedwell, was probably the best-remembered fictional character from that era, an itinerant "boomer" telegraph operator in the mold of Hemmingway's Nick Adams.
Oct 24 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: Scott Allen | last post by:
Hello, I'm new to C++ development and I'm trying out figure out the cause of an 'unresolved external symbol' error that I'm receiving when compiling. Here is some history on what I'm doing: I...
1
by: Chuck Mendell | last post by:
I am having problem with external javascripts. My OS is XP Pro. I am told to create an external javascript using a .js extension. (I did that) The external .js is very simple, containing: ...
4
by: intl04 | last post by:
How do I create a data input form in Access that is external to the Access database to which it's connected (if that's possible, which I believe it is)? For example, if someone clicks on an Access...
1
by: Aged | last post by:
Hi I have asked several groups now for advise but I feel I must be confusing either them or myself, but anyway here goes! Below is code taken from the "OnClick" function of a command button...
4
by: Alfonso Morra | last post by:
Ok, this is a bit of a quick hack. I have a flag set in another file (the default value of the flag is 0. In certain files, access to the flag symbol is not available - I want to know if unresolved...
5
by: snicks | last post by:
I'm trying to exec a program external to my ASP.NET app using the following code. The external app is a VB.NET application. Dim sPPTOut As String sPPTOut = MDEPDirStr + sID + ".ppt" Dim p As...
4
by: fmaxwell | last post by:
Dear Group I have a very frustrating problem. I have been trying to make it more difficult to access external javascript files by using PHP sessions. This works beautifully locally (both in...
10
by: Stefan Weber | last post by:
Hi, I'm trying to access the JavaScript code contained in a <scripttag via its "text" attribute. This works well, if the code is embedded in the HTML page. However, when the code is in an...
0
debasisdas
by: debasisdas | last post by:
This thread contains some useful tips for using External tables. USING EXTERNAL TABLE ======================= 1.THE TABLE POINTS TO EXTERNAL FILE. IF DATA IS ALTERED IN THE EXTERNAL FILE,DATA...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.