|
Thanks. I had been using MSN for my search engine and I wasn't getting too much. You reminded me that I hadn't used google in a while. I got a few more links there.
I like Bob Powell but in one of the links his comment is, 'To cure the "problem" buy more RAM'. One of my machines has 4GB and nothing else is running except the services so I'm guessing that isn't the problem.
I would agree with some comments that they're probably "soft" page faults mostly but there are enough (or an occasional hard fault gets mixed in there) that it definitely slows my calculations down once the excessive page faults kick in.
I changed the code to "chunk" the calculations which has made it less common to pass the threshold that triggers the massive faulting but I haven't been successful at completely eliminating it and my code is now something not even a mother would be proud of. :: Hack, Hack, Hack ::
|
|
|
|
|
I want to connect to a HUB_SWITCH who has some computers,and recive TCP packets.But i want use only RX wires(recive packets without have any TX wire).Can i do this and implement it in C++ (DOS OS)?
modified on Monday, December 1, 2008 11:12 AM
|
|
|
|
|
You cannot implement IPv4-TCP without both TX/RX pairs. If you are designing a system to meet military or industrial standards where the regulations state "Device Communication should be read-only" then I would suggest serial RS-232 with the TX wires physically cut.
Btw this should probably have been posted in the Hardware forum[^].
Best Wishes,
-David Delaune
|
|
|
|
|
Hi
i have requirement like doing 10 steps to complete task
After completion of one only i can enter into another
I used nested if- else to do that like
if (true)
{
if (true)
{
if (true)
{
return true;
}
else
{
}
}
else
{
}
}
else
{
}
is there any better way to handle these type of situation
Thanks in Advance
----------------------------
KRISHNA KUMAR T M
|
|
|
|
|
Yes
switch(i)
{
case 0:
break;
case 1:
break;
default:
break;
}
|
|
|
|
|
How about:
if (expression1 &&
expression2 &&
expression3 &&
expression4 &&
...) ...
else
or an uglier aproach:
try {
if (!expression1) throw 1;
if (!expression2) throw 2;
if (!expression3) throw 3;
...
} catch (int where)
{
}
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
|
|
|
|
|
The argument is "are guard clauses in methods okay?" And how do you handle resource cleanup if one of the guard clauses fail? I haven't seen a convincing consensus either way.
A specific example: Let's say you have 10 resources to allocate (like opening files, networks, etc) -- for brevity here, let's just use four resources. All resources have to be allocated for the method to continue.
So what we are trying to avoid is something like this (yuck):
isMethodSuccessful = false;
resource1 = OpenMyFile(myFile);
if (resource1 == SUCCESS)
{
resource2 = OpenSomeNetworkConnection(networkID)
if (resource2 == OKAY)
{
resource3 = CreateNewFile(outputFile);
if (resource3 == SUCCESS)
{
resource4 = ConnectToSomething(mySomething);
if (resource4)
{
isMethodSuccessful = true;
}
else
{
DeleteFile(resource3);
CloseNetwork(resource2);
CloseFile(resource1);
}
}
else
{
CloseNetwork(resource2);
CloseFile(resource1);
}
}
else
{
CloseFile(resource1);
}
return (isMethodSuccessful);
}
Guard clauses will convert that mess into something like this:
resource1 = OpenMyFile(myFile);
if (resource1 != SUCCESS)
{
return failure;
}
resource2 = OpenSomeNetworkConnection(networkID)
if (resource2 != OKAY)
{
CloseFile(resource1);
return failure;
}
resource3 = CreateNewFile(outputFile);
if (resource3 != SUCCESS)
{
CloseNetwork(resource2);
CloseFile(resource1);
return failure;
}
resource4 = ConnectToSomething(mySomething);
if (!resource4)
{
DeleteFile(resource3);
CloseNetwork(resource2);
CloseFile(resource1);
return failure;
}
return (success);
...which is far from ideal (i.e. more yuck). So what's the best code logic in this situation?
|
|
|
|
|
For instance, the C language goto statement allows to handle well the above scenario.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Actually, your "yuck" example is much better than the "more yack" one. The former is just yacky, and the later is dangerous (think introducing changes to the function and remembering to copy/paste all the resource cleanup).
The only robust and non-yacky way to handle this situation is use of The RAII programming idiom[^]
In this case, the destructors will make sure that all your resources are freed at the end of the scope - even if you throw an exception.
|
|
|
|
|
|
Usually this can be handled (as already suggested) with try-catch blocks or (using plain C ) with the (in)famous goto .
You may also schedule a set of operation to be invoked inside a loop (for instance with an array of function pointers) and use break to interrupt the iteration whenever needed (i.e. on any operation failure).
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
krishnakumartm wrote: is there any better way to handle these type of situation
Yes, like:
if (ret)
ret = foo1();
if (ret)
ret = foo2();
if (ret)
ret = foo3();
if (ret)
ret = foo4(); If any of the function calls fail, none of the remaining ones will execute.
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
Tons of COM examples and winsock examples use this approach in methods which would normally result in deep nested branch statements...
void CSomeClass::SomeMethod(void)
{
if (FALSE) { return; }
// got here 1
if (FALSE) { return; }
// got here 2
if (FALSE) { return; }
// got here 3
// ...
}
|
|
|
|
|
if (true)
{
if (true)
{
if (true)
{
return true;
}
else
{
}
}
else
{
}
}
else
{
}
Do you need to do something in each else block?
if yes than follow the same, else you can use
if((condition1)&&(condition2)&&(condition3))
return true;
else
return false;
|
|
|
|
|
Hi
in my application i am using extern to make application's theApp to access by other
is there any problem if use extern
Thanks in advance
----------------------------
KRISHNA KUMAR T M
|
|
|
|
|
I doubt there're any problems using extern for that but you could also use AfxGetApp(), i think that is the preferred method.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
|
|
|
|
|
Hi thanks for reply
already iam using AfxGetApp()
i don't know wether can i able to declare like that or not
----------------------------
KRISHNA KUMAR T M
|
|
|
|
|
Pardon?
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
|
|
|
|
|
You may declare it wherever you need, for instance suppose you application class name is
CMyApp then you probably have, in your MyApp.cpp source file some lines like the following
CMyApp theApp;
if you need it inside, say, MyView.cpp , then you write, somewhere at the top of the file
#include "MyApp.h"
extern CMyApp theApp;
If you need to reach it globally in your project then just declare it (i.e. write extern CMyApp theApp; ) inside your main header file, MyApp.h (that in turn is usually included by all of the source files).
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
In a CDialogBox that has a button as first control, I want the button to show a focus rectangle when I launch the dialogbox.
Now the focus rectangle doesn't show until I press the ALT or TAB-key for example.
You can test this behaviour by creating a new dialogbox in the resoure editor (with an 'OK' and 'Cancel'-button only) and launch it.
How can I change this behaviour?
Actually: If you create a new MFC AppWizard project that is Dialog based, the AppWizard creates a dialogbox that shows a focus rectangle on the OK-button... That's the behaviour that I want!!!
Thanks for your help!
FYI: I'm using Visual C++ 5.0.
|
|
|
|
|
J. Landsheer wrote: Now the focus rectangle doesn't show until I press the ALT or TAB-key for example...How can I change this behaviour?
Does it have anything to do with what control is first in the Z-order?
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
|
To answer myself (and maybe some others who have a similar problem):
It's a Win2000/WinXP-feature that when a dialogbox is invoked by the mouse (for example by clicking a menu item in the parent window) all accelerator cues and focus rectangles in the dialogbox are disabled (until you touch the ALT- or TAB-key).
However: when you invoke the dialogbox by the keyboard (for example by touching ALT+I on a menu item 'Invoke Dialogbox'), accelerator cues and focus rectangles in the dialogbox are enabled!!!
You can control this i.m.h.o. useless feature from the Desktop Control Panel, under Appearance, Effects, "Hide underlined letters for keyboard navigation until I press the Alt key".
Another way to do it, is to handle the WM_UPDATEUISTATUS message yourself:
make a MESSAGE_MAP-entry 'ON_WM_UPDATEUISTATE()' and let the 'OnUpdateUIState(UINT p1, UINT p2)' do nothing.
If Class-Wizard doesn't support the WM_UPDATEUISTATE-message, you have to define it yourself:
#define WM_UPDATEUISTATE 0x0128<br />
<br />
#define ON_WM_UPDATEUISTATE() \<br />
{ WM_UPDATEUISTATE, 0, 0, 0, AfxSig_vww, \<br />
(AFX_PMSG)(AFX_PMSGW) \<br />
(static_cast< void (AFX_MSG_CALL CWnd::*)(UINT, UINT) > (OnUpdateUIState)) },<br />
|
|
|
|
|
Hi i have one object name in one view
how to give gray color to the name of the object
|
|
|
|
|
Member 4655685 wrote: how to give gray color to the name of the object
What are you trying to give color to?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|