Go to Post Those kids are different! They seem more mature, respectful, and intelligent than most adults. They can actually think instead of just spitting out facts. They are obviously getting a real education. - Amber H. [more]
Home
Go Back   Chief Delphi > Technical > Programming > C/C++
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
 
 
Thread Tools Rating: Thread Rating: 2 votes, 5.00 average. Display Modes
Prev Previous Post   Next Post Next
  #1   Spotlight this post!  
Unread 02-09-2013, 02:44 PM
mrklempae mrklempae is offline
Registered User
no team
 
Join Date: Jan 2013
Location: Montana
Posts: 19
mrklempae is an unknown quantity at this point
Printing to a text file

We have an application where we need to print large amounts of data to a text file, but can't figure out what we're doing. We're trying to save a log of the values sent to the motor controllers (I know 1500 may be a bit excessive, but it's for a reason). First we made text files "RIGHT" and "LEFT" (and eventually tried "right" and "left") and added them to our project (screenshot attached). We considered comma separated value data in one text file on two separate lines, but two separate text files seemed easier to use. This is the code we're using:
Code:
//imported #include <fstream>
//leftdrive, rightdrive, and myrobot(leftdrive, rightdrive) are already initilized
int counter;
while (IsOperatorControl())
{
	float driverLeftY = driverXbox->GetRawAxis(2);
	float driverRightY = driverXbox->GetRawAxis(5);
	myRobot->TankDrive(-driverLeftY, driverRightY);
	ofstream left;
	ofstream right;
	left.open ("LEFT.txt");
	right.open ("RIGHT.txt");
	while (counter <= 1500) //while (samples <= 1500)
	{
	    right << RightDrive->Get() << "," << endl; 
            left << LeftDrive->Get() << "," << endl;
	    counter++;
	    Wait(0.01);
	}
	left.close();
	right.close();					
}
When we check the text files, there is no change. Has anyone else tried utilizing text files in their code?
Attached Thumbnails
Click image for larger version

Name:	ProjectExplorerCap.PNG
Views:	35
Size:	11.5 KB
ID:	13882  
Reply With Quote
 


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 10:24 AM.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi