Can CFile set/get the text file font type?
-
I wanna save some value into the a txt type file. for example, I save the value in *.txt file as follow,if the font is not matching, the columns/lines maybe become curve,sach as: 90 91 92 93 94 95 96 97 98 99 9A 9B 9C 9D 9E 9F A0 A1 A2 A3 A4 A5 A6 A7 A8 A9 AA AB AC AD AE AF B0 B1 B2 B3 B4 B5 B6 B7 B8 B9 BA BB BC BD BE BF 1>How can I set the text file display font in my code? 2>How can I get the exact single vaule that saved before?
-
I wanna save some value into the a txt type file. for example, I save the value in *.txt file as follow,if the font is not matching, the columns/lines maybe become curve,sach as: 90 91 92 93 94 95 96 97 98 99 9A 9B 9C 9D 9E 9F A0 A1 A2 A3 A4 A5 A6 A7 A8 A9 AA AB AC AD AE AF B0 B1 B2 B3 B4 B5 B6 B7 B8 B9 BA BB BC BD BE BF 1>How can I set the text file display font in my code? 2>How can I get the exact single vaule that saved before?
zeus_master wrote:
2>How can I get the exact single vaule that saved before?
Use
fprintf
to write andfscanf
to read.
Nibu thomas Software Developer
-
I wanna save some value into the a txt type file. for example, I save the value in *.txt file as follow,if the font is not matching, the columns/lines maybe become curve,sach as: 90 91 92 93 94 95 96 97 98 99 9A 9B 9C 9D 9E 9F A0 A1 A2 A3 A4 A5 A6 A7 A8 A9 AA AB AC AD AE AF B0 B1 B2 B3 B4 B5 B6 B7 B8 B9 BA BB BC BD BE BF 1>How can I set the text file display font in my code? 2>How can I get the exact single vaule that saved before?
I don't understand what you mean... If I pasted the lines you posted in a txt file and I open it with notepad, all columns are well aligned. A file is just 'data' (binary or text) and it cannot contain font information (or the only way to do that is to have your own file format and your own program that will read the file).
-
I wanna save some value into the a txt type file. for example, I save the value in *.txt file as follow,if the font is not matching, the columns/lines maybe become curve,sach as: 90 91 92 93 94 95 96 97 98 99 9A 9B 9C 9D 9E 9F A0 A1 A2 A3 A4 A5 A6 A7 A8 A9 AA AB AC AD AE AF B0 B1 B2 B3 B4 B5 B6 B7 B8 B9 BA BB BC BD BE BF 1>How can I set the text file display font in my code? 2>How can I get the exact single vaule that saved before?
-
I wanna save some value into the a txt type file. for example, I save the value in *.txt file as follow,if the font is not matching, the columns/lines maybe become curve,sach as: 90 91 92 93 94 95 96 97 98 99 9A 9B 9C 9D 9E 9F A0 A1 A2 A3 A4 A5 A6 A7 A8 A9 AA AB AC AD AE AF B0 B1 B2 B3 B4 B5 B6 B7 B8 B9 BA BB BC BD BE BF 1>How can I set the text file display font in my code? 2>How can I get the exact single vaule that saved before?
If you want to display the lines with straight columns, then you have to use a monospaced font (where all characters has got the same width), such as "Courier New" or "System" In a text file, you can't choose what font to use when the file is viewed. If you need to do that, try a .rtf, .doc or a .pdf file.
-
I don't understand what you mean... If I pasted the lines you posted in a txt file and I open it with notepad, all columns are well aligned. A file is just 'data' (binary or text) and it cannot contain font information (or the only way to do that is to have your own file format and your own program that will read the file).
please see my code below: BYTE regdata[5][0x10][0x10]; BOOL CxxDlg::OnInitDialog() { CDialog::OnInitDialog(); // Add "About..." menu item to system menu. // IDM_ABOUTBOX must be in the system command range. ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX); ASSERT(IDM_ABOUTBOX < 0xF000); CMenu* pSysMenu = GetSystemMenu(FALSE); if (pSysMenu != NULL) { CString strAboutMenu; strAboutMenu.LoadString(IDS_ABOUTBOX); if (!strAboutMenu.IsEmpty()) { pSysMenu->AppendMenu(MF_SEPARATOR); pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu); } } // Set the icon for this dialog. The framework does this automatically // when the application's main window is not a dialog SetIcon(m_hIcon, TRUE); // Set big icon SetIcon(m_hIcon, FALSE); // Set small icon // TODO: Add extra initialization here BYTE h,i,j; for (h=0x00;h<5;h++) { for (i=0x00;i<0x10;i++) { for (j=0x00;j<0x10;j++) { regdata[h][i][j]=(BYTE)(i*0x10)+j; } } } return TRUE; // return TRUE unless you set the focus to a control } void CxxDlg::OnButtonSave() { // TODO: Add your control notification handler code here CString buf; CString buf1=" "; BYTE h,i,j; for (h=0x00;h<5;h++) { buf1.Format("\r\n\r\nBank%x: \r\n-----",h); buf +=buf1; for (j=0x00;j<0x10;j++) { buf1.Format("-%02X-",j); buf +=buf1; } for (i=0x00;i<0x10;i++) { buf1.Format("\r\n-%02X- ",i); buf +=buf1; for (j=0x00;j<0x10;j++) { buf1.Format("%02X ",regdata[h][i][j]); buf +=buf1; } } } CFileDialog fdlg(FALSE,"PJ",NULL,OFN_OVERWRITEPROMPT, "text File(*.txt)|*.txt|map file(*.map)|*.map|All files(*.*)|*.*||",this); fdlg.m_ofn.lpstrTitle="Data saving"; if (fdlg.DoModal()==IDOK) { m_strCurFile=fdlg.GetPathName(); CStdioFile csfile(m_strCurFile,CFile::modeCreate|CFile::modeReadWrite|CFile::typeText); csfile.WriteString(buf); csfile.Close(); } } I saved the values in *.txt or *.map file, but when it was opened by notepad with the defaut font, the columns becomed unaligned. So I want to know that is there any way to set the font view of the files? or they are only related with operating system? As the code above, I saved the value of array regdata[5][0x10][0x10] as hex-string in the *.txt file. how can I read the value back to regdata[5][0x10][0x10] one-by-one?:((
-
If you want to display the lines with straight columns, then you have to use a monospaced font (where all characters has got the same width), such as "Courier New" or "System" In a text file, you can't choose what font to use when the file is viewed. If you need to do that, try a .rtf, .doc or a .pdf file.