Click here to Skip to main content
16,016,022 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionSimple Serial port programming in VC++ Pin
pavanbabut31-Oct-06 16:21
pavanbabut31-Oct-06 16:21 
AnswerRe: Simple Serial port programming in VC++ Pin
NiceNaidu31-Oct-06 19:14
NiceNaidu31-Oct-06 19:14 
AnswerRe: Simple Serial port programming in VC++ Pin
flippydeflippydebop31-Oct-06 20:17
flippydeflippydebop31-Oct-06 20:17 
GeneralRe: Simple Serial port programming in VC++ Pin
pavanbabut1-Nov-06 5:14
pavanbabut1-Nov-06 5:14 
GeneralRe: Simple Serial port programming in VC++ Pin
pavanbabut1-Nov-06 15:33
pavanbabut1-Nov-06 15:33 
QuestionSetForegroundWindow and flash taskbar Pin
LiYS31-Oct-06 15:36
LiYS31-Oct-06 15:36 
AnswerRe: SetForegroundWindow and flash taskbar Pin
Nibu babu thomas31-Oct-06 20:26
Nibu babu thomas31-Oct-06 20:26 
QuestionFile I/O w/ Unicode Dialog [modified] Pin
aquawicket31-Oct-06 13:55
aquawicket31-Oct-06 13:55 
I've been racking my brain all day with this... Just can't get things going..
I need to be able to read and write variables to a file..

I've got one example to work.. But the reading I get back are box characters...
This prolly has to do with the fact that my progam is in UNICODE mode.
I'm just trying to read and write in a CSV file. (comma seperated values).
But anything that is capable of reading and writing variables to a file would be great..




Example:


// Open the text file we want
CFile cfFile (L"C:\\TextFile.txt", CFile::modeNoTruncate | CFile::modeRead);

CArchive ar (&cfFile, CArchive::load); // Load its contents into a CArchive

// Initialise the variable which holds each line's contents
CString strLine = L"";
if(!ar.ReadString(strLine))
// Read the first line of the CArchive into the variable
return; // Failed, so quit out

do // Repeat while there are lines in the file left to process
{
if(strLine.GetLength() == 0) // If the line is empty, skip it
continue;

CString strText = strLine; // A line of the file

// Initialise the variables that will hold the values
CString strItemName = L"";
CString strPicPath = L"";
CString strSoundPath = L"";

// Extract the first value, and place it in the strItemName variable
AfxExtractSubString(strItemName, strText, 0, ',');
// Extract the second value, and place it in the strPicPath variable
AfxExtractSubString(strPicPath, strText, 1, ',');
// Extract the third value, and place it in the strSoundPath variable
AfxExtractSubString(strSoundPath, strText, 2, ',');

// Do something with these values in the variables

}while(ar.ReadString(strLine));




If I display strItemName, strPicPath or strSoundPath after reading the file... I get blocks..
any ideas?



-- modified at 22:34 Tuesday 31st October, 2006
AnswerRe: File I/O w/ Unicode Dialog Pin
Mark Salsbery31-Oct-06 16:19
Mark Salsbery31-Oct-06 16:19 
GeneralRe: File I/O w/ Unicode Dialog Pin
aquawicket31-Oct-06 16:32
aquawicket31-Oct-06 16:32 
GeneralRe: File I/O w/ Unicode Dialog Pin
Mark Salsbery31-Oct-06 17:12
Mark Salsbery31-Oct-06 17:12 
GeneralRe: File I/O w/ Unicode Dialog Pin
aquawicket31-Oct-06 18:16
aquawicket31-Oct-06 18:16 
GeneralRe: File I/O w/ Unicode Dialog Pin
Mark Salsbery31-Oct-06 18:51
Mark Salsbery31-Oct-06 18:51 
GeneralRe: File I/O w/ Unicode Dialog Pin
aquawicket1-Nov-06 4:53
aquawicket1-Nov-06 4:53 
GeneralRe: File I/O w/ Unicode Dialog Pin
aquawicket1-Nov-06 5:03
aquawicket1-Nov-06 5:03 
GeneralRe: File I/O w/ Unicode Dialog Pin
Mark Salsbery1-Nov-06 5:14
Mark Salsbery1-Nov-06 5:14 
QuestionStrange error with File I/O Pin
Anthony Mushrow31-Oct-06 10:26
professionalAnthony Mushrow31-Oct-06 10:26 
QuestionRe: Strange error with File I/O Pin
David Crow31-Oct-06 10:28
David Crow31-Oct-06 10:28 
AnswerRe: Strange error with File I/O Pin
Anthony Mushrow31-Oct-06 10:49
professionalAnthony Mushrow31-Oct-06 10:49 
QuestionRe: Strange error with File I/O Pin
David Crow31-Oct-06 10:54
David Crow31-Oct-06 10:54 
GeneralRe: Strange error with File I/O Pin
Anthony Mushrow31-Oct-06 10:56
professionalAnthony Mushrow31-Oct-06 10:56 
GeneralRe: Strange error with File I/O Pin
Christian Graus31-Oct-06 11:02
protectorChristian Graus31-Oct-06 11:02 
GeneralRe: Strange error with File I/O Pin
led mike31-Oct-06 11:13
led mike31-Oct-06 11:13 
GeneralRe: Strange error with File I/O Pin
Anthony Mushrow31-Oct-06 11:54
professionalAnthony Mushrow31-Oct-06 11:54 
GeneralRe: Strange error with File I/O Pin
Christian Graus31-Oct-06 15:53
protectorChristian Graus31-Oct-06 15:53 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.