freestyler's Profile User Rating: -----

Reputation: 1 Apprentice
Active Posts:
28 (0.04 per day)
31-March 12
Profile Views:
Last Active:
User is offline Apr 08 2013 10:48 AM

Previous Fields

Dream Kudos:
Icon   freestyler has not set their status

Posts I've Made

  1. In Topic: Reading comma separated values to and from an array

    Posted 19 Feb 2013

    View PostSkydiver, on 19 February 2013 - 03:55 PM, said:

    The code you posted above uses operator <<, but the errors you are showing us is with regards to operator >>. Are you sure you are posting the lines around line 59 from your code?

    Thanks for catching that. I tried about twenty different changes while I was in the process of writing this, hoping I would get lucky and not have to send it. This is the actual error I was given:


    C:/WindRiver/workspace/BuiltinDefaultCode/BuiltinDefaultCode.cpp: In member function `virtual void DefaultRobot::Autonomous()':
    C:/WindRiver/workspace/BuiltinDefaultCode/BuiltinDefaultCode.cpp:56: error: no match for 'operator<<' in 'frontleft << w'
    C:/WindRiver/workspace/BuiltinDefaultCode/BuiltinDefaultCode.cpp:57: error: no match for 'operator<<' in 'frontright << x'
    C:/WindRiver/workspace/BuiltinDefaultCode/BuiltinDefaultCode.cpp:58: error: no match for 'operator<<' in 'backleft << y'
    C:/WindRiver/workspace/BuiltinDefaultCode/BuiltinDefaultCode.cpp:59: error: no match for 'operator<<' in 'backright << z'

    It's the same error I get when I get rid of "endl". It compiles when I switch "<<" to ">>", but I won't be able to test for a few hours. Even in the event that it does work, I still don't understand how it knows to stop at the end of one line during one loop cycle and then pick up from there and get the next line during the next cycle. I never realized how valuable file I/O could be until now. Thank you all for the help I've received!
  2. In Topic: Reading comma separated values to and from an array

    Posted 19 Feb 2013

    Based on what I saw in the example, I would get to the next line by using file<<variable<<endl which would store the line in the variable and then go to the next line. This is what I just tried, and there is about 900 lines of errors (WindRiver :P ).
    while (counter < cycles) //cycles == 120
    						if (Timer::GetPPCTimestamp() >= waitTimeout) 
    							frontleft << w << endl;
    							dsLCD->PrintfLine((DriverStationLCD::Line) 0, "FLEFT: %f", w); //text file for front left front motor controller
    							waitTimeout += 0.1;
    The most prevalent being


    C:/WindRiver/workspace/BuiltinDefaultCode/BuiltinDefaultCode.cpp:59: error: no match for 'operator>>' in '((std::basic_istream<char, std::char_traits<char> >*)(&frontleft))->std::basic_istream<_Elem, _Traits>::operator>> [with _Elem = char, _Traits = std::char_traits<char>](((float&)(&w))) >> std::endl'
    c:/windriver/gnu/3.4.4-vxworks-6.3/x86-win32/lib/gcc/../../../x86-win32/include/c++/3.4.4/istream:133: note: candidates are: std::basic_istream<_Elem, _Traits>& std::basic_istream<_Elem, _Traits>::operator>>(std::basic_istream<_Elem, _Traits>&(*)(std::basic_istream<_Elem, _Traits>&)) [with _Elem = char, _Traits = std::char_traits<char>]
    c:/windriver/gnu/3.4.4-vxworks-6.3/x86-win32/lib/gcc/../../../x86-win32/include/c++/3.4.4/istream:139: note: std::basic_istream<_Elem, _Traits>& std::basic_istream<_Elem, _Traits>::operator>>(std::basic_ios<_Elem, _Traits>&(*)(std::basic_ios<_Elem, _Traits>&)) [with _Elem = char, _Traits = std::char_traits<char>]
    c:/windriver/gnu/3.4.4-vxworks-6.3/x86-win32/lib/gcc/../../../x86-win32/include/c++/3.4.4/istream:146: note: std::basic_istream<_Elem, _Traits>& std::basic_istream<_Elem, _Traits>::operator>>(std::ios_base&(*)(std::ios_base&)) [with _Elem = char, _Traits = std::char_traits<char>]
    c:/windriver/gnu/3.4.4-vxworks-6.3/x86-win32/lib/gcc/../../../x86-win32/include/c++/3.4.4/istream:153: note: std::basic_istream<_Elem, _Traits>& std::basic_istream<_Elem, _Traits>::operator>>(std::_Bool&) [with _Elem = char, _Traits = std::char_traits<char>]
  3. In Topic: Reading comma separated values to and from an array

    Posted 18 Feb 2013

    I still don't see how I would implement that to get to the next line. Thank you very much, though! That was the first actual somewhat successful test. I've been trying for a while...
  4. In Topic: Reading comma separated values to and from an array

    Posted 18 Feb 2013

    Hello! It's been a while since I have been here. I haven't made many changes (this is basically just a fun programming project; lower priority). THe only real change I have made Is have separating the values by line (thanks jimblumberg) to simplify the reading process when I eventually figure that out (no searching for commas or guessing the number of characters to take). My original plan was to put the entire file of data into one array and use a for{} loop to cycle through the data, but instead I'm just attempting to read line by line in real time (is this a good idea?). In a recent update, compatibility for fstream has been added to the system, so we're attempting to switch back to that. This is our writing code (which works flawlessly):
    if (counter <= cycles) //cycles = 1500
    					if (Timer::GetPPCTimestamp() >= waitTimeout) //state machine
    						frontright << FrontRightDrive->Get() << "\n"; 
    						frontleft << FrontLeftDrive->Get() << "\n";
    						backright << BackRightDrive->Get() << "\n"; 
    						backleft << BackLeftDrive->Get() << "\n";
    						dsLCD->PrintfLine((DriverStationLCD::Line) 0, "Recording...");						
    						dsLCD->PrintfLine((DriverStationLCD::Line) 1, "Loops: %d/%d", counter, cycles);
    						waitTimeout += 0.01;

    Our reading code should look something this:
    				if (toggle->Get() == 0)
    					ifstream frontleft;
    					ifstream frontright;
    					ifstream backleft;
    					ifstream backright; ("FLEFT.txt"); ("FRIGHT.txt"); ("BLEFT.txt"); ("BRIGHT.txt");
    					for (int a = 0; a < cycles; a++)
    						if (Timer::GetPPCTimestamp() >= waitTimeout) 
    							FrontLeftDrive->Set(std::getline(frontleft, a));
    							FrontRightDrive->Set(std::getline(frontright, a));
    							BackLeftDrive->Set(std::getline(backleft, a));
    							BackRightDrive->Set(std::getline(backright, a));
    							waitTimeout += 0.01;

    but we get the error


    error: no matching function for call to `getline(std::ifstream&, int&)'
    I'm not sure how else to get the line from the file (and I'm not sure what exactly the line is considered... a string, etc). Any help would be appreciated! Thanks!
  5. In Topic: Reading comma separated values to and from an array

    Posted 12 Feb 2013

    Okay so I can now store data to two different text files. It's not exactly what I wanted to do (store data in one file on two lines), but it works.
    	void OperatorControl(void)
    		DriverStationLCD *driverStationLCD = DriverStationLCD::GetInstance();
    		FILE *leftoutput = fopen("/left.txt", "w");  //The file written can be viewed with a web browser by visiting ""
    		FILE *rightoutput = fopen("/right.txt", "w");
    		//int counter = 0;
    		while (IsOperatorControl())
    			float driverLeftY = driverXbox->GetRawAxis(2);
    			float driverRightY = driverXbox->GetRawAxis(5);
    			float left = LeftDrive->Get();
    			float right = RightDrive->Get();
    			fprintf(leftoutput, "%f,", left);
    			fprintf(rightoutput, "f,", right);
    			myRobot->TankDrive(-driverLeftY, driverRightY);
    			driverStationLCD->PrintfLine((DriverStationLCD::Line) 0, "Left: %f", left);
    			driverStationLCD->PrintfLine((DriverStationLCD::Line) 1, "Right: %f", right);

    The output of each file looks like this

    All I have left to do is figure out how to put the entire length of data into an array (actually two arrays, at the same time, which I have absolutely no idea how to do). I haven't been programming for long, and prior to this I have never needed to use text files for I/O. I'll post it here if I ever figure it out. Thanks!

My Information

Member Title:
New D.I.C Head
Age Unknown
Birthday Unknown

Contact Information



freestyler hasn't added any friends yet.


freestyler has no profile comments yet. Why not say hello?