|
What we do here at work is to add "metadata" in the file, but still we always read the entire file into CStrings.
You can do something like:
"#value1|value2|...|valuen#" Where # = beginning - end and the | is a delimiter.
Note that 1 character is 1 byte long, this means you can load about 13000 lines (1 line ~ 80 characters) for each MegaByte of memory. Normally you have about 512 Mb, not to mention virtual memory.
Point is, it's really no problem loading the file into memory. The reading takes time, but as you may have noticed, Word, Excel, Notepad, ... all take some time to load their text.
"If I don't see you in this world, I'll see you in the next one... and don't be late." ~ Jimi Hendrix
|
|
|
|
|
hi V.
I'm sorry keeping on bothering you.
I agree with you, it is ok to load the whole data to memory.
But I need to write data back and close the file at every editchange, because the file will be accessed by another class.
Fortunately, I have only 8 data need to handle, the speed is compltely fine with me.
My tesk is like this:
I use MFC to make a dialog.
I have serveral tabs with about 8 spins on each of them. and I add these tabs on a base dailog.
I send the spin value out on a master query(I'm slave on the bus. I cann't send data out on my own. I need to wait the query command.)
So I decide to store the tabs spin values in several files(every tab has it's own file), and open a serial port on the base port.
When the user change the spin value, he only change the file, but doesn't send it out.
When the master polling, I send the file data to master.(the polling speed is faster than the user's finger to click spin, of course)
Will my idea work?
One more ask
V. wrote:
"#value1|value2|...|valuen#"
if I make my file like this:
10
15
20
when I fread them, CString will treat 10 to be one byte, or treat 1 as one byte and 0 as teh second byte?
Many thanks for your help beforehan.
slow-witted chauteen
|
|
|
|
|
Well actually it depends on which coding you use, but 90% of all uses are ASCII which (in modern times) takes 1 byte per character. A character is not only a, b, c, ... or 0-9, but also a space, tab, return ,...
so 10 would be 2 bytes. (a byte stands for BY EIGHT, 8 bits) (and 1 byte for return and I even think 1 byte for the new line, but I'm not sure the fread will read them)
For your idea, yes it will work I think, but I would consider putting them in 1 file, this is however just a detail.
My experience is that the boss will not tire himself too much by checking how you did it, he just wants it working (no matter what dirty tricks )
good luck.
"If I don't see you in this world, I'll see you in the next one... and don't be late." ~ Jimi Hendrix
|
|
|
|
|
Are there good WMI samples, articles, books ?
I need to work with system objects, like users and directories...
So need any links and names.
Language C++,
but others is interesting also.
Thanks you.
|
|
|
|
|
There are quite a few samples / articles on this site. Type WMI into the search and go from there.
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fuity and sweet. I'm jelly, what am I? - David Williams (Little Britain)
|
|
|
|
|
Hello,
I'm working at a machine where where the VC++ batch file for setting the PATH environment variables isn't available and I don't have access to the CD today. Can anybody remind me exactly what variables are set?
Cheers,
John
p.s.
or even just paste the script would be brilliant!
|
|
|
|
|
The file vcvars32.bat, located in the C:\Program Files\Microsoft Visual Studio\VC98\Bin folder, looks like:
@echo off
rem
rem Root of Visual Developer Studio Common files.
set VSCommonDir=C:\Program Files\MICROS~3\Common
rem
rem Root of Visual Developer Studio installed files.
rem
set MSDevDir=C:\Program Files\MICROS~3\Common\msdev98
rem
rem Root of Visual C++ installed files.
rem
set MSVCDir=C:\Program Files\MICROS~3\VC98
rem
rem VcOsDir is used to help create either a Windows 95 or Windows NT specific path.
rem
set VcOsDir=WIN95
if "%OS%" == "Windows_NT" set VcOsDir=WINNT
rem
echo Setting environment for using Microsoft Visual C++ tools.
rem
if "%OS%" == "Windows_NT" set PATH=%MSDevDir%\BIN;%MSVCDir%\BIN;%VSCommonDir%\TOOLS\%VcOsDir%;%VSCommonDir%\TOOLS;%PATH%
if "%OS%" == "" set PATH="%MSDevDir%\BIN";"%MSVCDir%\BIN";"%VSCommonDir%\TOOLS\%VcOsDir%";"%VSCommonDir%\TOOLS";"%windir%\SYSTEM";"%PATH%"
set INCLUDE=%MSVCDir%\ATL\INCLUDE;%MSVCDir%\INCLUDE;%MSVCDir%\MFC\INCLUDE;%INCLUDE%
set LIB=%MSVCDir%\LIB;%MSVCDir%\MFC\LIB;%LIB%
set VcOsDir=
set VSCommonDir=
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
Thanks very much David,
John
|
|
|
|
|
I have a data file which was written in a text ascii format, I would like to generate a report, describe the filename, date, etc, also extract some data and presented them in a curve, the data should also be listed in a table.
I was used doc/view to realize it, but it looks not very fancy, especially I have to draw the table line by line. Any good idea?
Thanks.
Nelson L.
|
|
|
|
|
Create an MDI project and instead of drawing your own table, try Codeproject's own MFCGrid in one of the views. It's quite easy to use IMO.
John
|
|
|
|
|
how to use them
my problem is as follow
i hav got a matrix ,the user wil enetr the value in the matrix & i hav 2 pic the value from txtboxes.
I Think It will Work
Alok Gupta
visit me at http://www.thisisalok.tk
|
|
|
|
|
ON_COMMAND_RANGE is used when you want to call the same function for several buttons or events.
I don't understand what you want to do ??
|
|
|
|
|
Hello:
I am writting a Date Class, and I want to overload operator - that can take a Date object, I wrote the code, but I felt it is stupid, Please help me:
***************************************************************************
int Date::days[] = {0, 31, 28, 31, 30, 31, 30,
31, 31, 30, 31, 30, 31};
int Isbigger(int year, int right_year)
{
int bigger;
bigger = year > right_year?year:right_year;
returen bigger;
}//get the bigger value of two
int Issmaller(int year, int right_year)
{
int smaller;
smaller = year < right_year? year:right_year;
return smaller;
}//get the smaller value of two
int Date::operator -(Date right)
{
int subday;
int subyear;
if (year == right.year)
{
subyear = 0;
if(month == right.month)
{
subday = Isbigger(day, right.day) - Issmaller(day,right.day); //if the same year and same month, just subtract the date;
}
else if(month != right.month) //if same year different month,
{
subday = (days[month] - day) + right.day); //get the days in beginning and ending month,
for(i = (Isbigger(day,right.day) - 1); i >issmaller(day,right.day) ; i++)
{
subday += days[i]; //then plus the intermedia month,
}
}
}
else //not in the same year
{
int yearDifference;
yearDifference = Isbigger(year,right.year) - 1;
subyear = yearDifference * 365;
if(month == right.month)
{
subday = Isbigger(day, right.day) - Issmaller(day,right.day); //if the same year and same month, just subtract the date;
}
else if(month != right.month) //if same year different month,
{
subday = (days[month] - day) + right.day); //get the days in beginning and ending month,
for(i = (Isbigger(day,right.day) - 1); i >issmaller(day,right.day) ; i++)
{
subday += days[i]; //then plus the intermedia month,
}
}
subday += subyear;
}
return subday;
}
Thank You So Much
|
|
|
|
|
In some programs they convert the date to a number. (eg. like CTime class) then you can detect real easy is bigger or smaller and just substract or add them.
I would take in account that in the year 2004 february has 29 days... leap years.
good luck.
"If I don't see you in this world, I'll see you in the next one... and don't be late." ~ Jimmy Hendrix
|
|
|
|
|
Hello,
Think it goes something like this, but you should check on web ...
if year is divisible by 4 then
....if year is not divisible by 100 then
.........it's a leap year
....else
.........if year is divisible by 400 then
...............it's a leap year
.........endif
....endif
endif
John
|
|
|
|
|
Hello,
This mightn't be exactly what your asking but you should make the '-' operator a 'friend' rather than a class member. It means you can use it like the built-in subtraction operator instead of call a method.
See http://guinness.cs.stevens-tech.edu/~asatya/courses/cs765IT/C++_overview/lect10_1.pdf
John
|
|
|
|
|
Hello,
my MFC dialog based app uses a freeware activex I found on the net.
To use it, the relative ocx file must be registered in the system.
Is there a way to make the app do itself without the user having
to run regsvr32 c:\..... ?
i.e. to register at execution and unregister on close app?
Thanks for the precious help.
Marco.
|
|
|
|
|
Does ALU inside the cpu handle floating point?
or cpu will let the FPU handle it? For example,
when we declare float, or double?
Another newbie's question:
When we do assambly language, we will specify
which register to use, so my question is: do
we need to have to specify when to use cache?
or the cpu will just simply decide when to use
cache itself?
|
|
|
|
|
Is my question too dump? seriously
|
|
|
|
|
Hello everyone!
I'm not quite sure, if this is the correct message board for this thread, but i'm working with C++ so I posted this thread here.
I've created an Win32 Application, which checks if the .net Framework is installed on the system. If not, the program will automatically start to install the .net Framework in the background.
Is there any way to run a Windows Installer Package in the background (command line, etc.)??
For example I have myinstaller.msi or dotnetfx.exe!
How can I solve my problem???
Thank you for helping me!
|
|
|
|
|
You can execute the EXE file with CreatePRocess() and either wait for it to finish or not.
You can run MSIEXEC to run MSI files. You can wait, or not, for the setup to finish.
Now, I have not installed .NET so many times to know if it usually requires a reboot or not. If it usually requires a reboot, then you might as well launch its setup and exit, since the machine will probably have to be restarted anyway.
|
|
|
|
|
Thank you for the tip!
I understand the MSIEXEC.
Blake Miller wrote:
CreatePRocess()
But that's the thing I don't understand.
I'm just a newbie, so could you give me a few lines of code, please?!?!
|
|
|
|
|
Check out this article on starting another program from your current program:
http://www.codeproject.com/threads/CreateProcessEx.asp
You need to call CreateProcess to start the MSIEXEC program which will run the MSI file you use to install .NET
|
|
|
|
|
I want to write a function in VC++ which will create a table(in a new mdb file) in MsAccess and also fill the table with values in the same function. As for creating the database i have to use msadox.dll and for populating database i have to use msado15.dll. But if i import both these dlls i get the following error.
< error C2011: 'DataTypeEnum' : 'enum' type redefinition >
This is probably due to DataTypeEnum being defined in both msadox.tlh and msado15.tlh.
Is there any way in which i can use both the dlls
or any other way i can create and populate the table in same function.
Note :(I got to create database in Access 2000)
With Regards,
Kaustubh
|
|
|
|
|
I did come across this conflict a while back when I needed to use ADO, ADOX and JRO (JET compression).
Try this:
<font color=green>
#pragma warning(push)
#pragma warning(disable:4146)
#import "C:\Program Files\Common Files\system\ado\msadox.dll"
#import "C:\Program Files\Common Files\System\ado\msado15.dll" rename ("EOF","ADOEOF")
using namespace ADODB;
#pragma warning(pop)
I Dream of Absolute Zero
|
|
|
|
|