|
something like this ??
(3 [1 [(2 0 3) | (4 [(0 1) | (1 2)])] | (2 1 1 0) | (4 2 3 2)])
|
|
|
|
|
Could you possibly employ the use of a FSM?
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
DavidCrow wrote: Could you possibly employ the use of a FSM
there is only one FSM. and he works for nobody.
|
|
|
|
|
_AnShUmAn_ wrote: A_____B______C_____D_____E
3_____1______2_____0_____3
_____________4_____0_____1
___________________1_____2
______2______1_____1_____0
______4______2_____3_____2
so as explained in the table above the valid entries should be 31203,31412,32110,34232.
I'm missing one value. I guess the correct entries should be 31203,31401, 31412,32110,34232. Am I right?
Further:
1.
The underscore characters, are they present in the string?
2.
_AnShUmAn_ wrote: A_____B______C_____D_____E
Does this line have any significance, or did you just put it there for clarification?
Alcohol. The cause of, and the solution to, all of life's problems - Homer Simpson
|
|
|
|
|
kakan wrote: I'm missing one value
I just gave a few examples about how the values could be entered by the user. Yes what you is correct.
kakan wrote: The underscore characters, are they present in the string?
NO the underscore signs are not present in the string. I just entered them to show the alignment to the codeproject member's.
kakan wrote: A_____B______C_____D_____E
I just put this line for clarification.
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
OK, one more question:
The "shorter" lines, are they left justified, or are they padded with blanks?
<code>
Like this (padded with blanks):
"31203"
" 401"
" 12"
" 2110"
" 4232"
Or like this (left justified):
"31203"
"401"
"12"
"2110"
"4232"
</code>
I'm working on a solution.
-- modified at 1:43 Tuesday 7th November, 2006
-- modified at 1:44 Tuesday 7th November, 2006
Alcohol. The cause of, and the solution to, all of life's problems - Homer Simpson
|
|
|
|
|
Hello again. I didn't receive an answer to my last question, but I made a solution that covers both cases.
You will have to adjust the code for Unicode if you want it.
And possibly adjust the code to ATL/STL if you want it.
Here goes:
The func:
<code>
void get(CString csIn, CString &csOut)
{
static CString csLast = "";
int lastLen = csLast.GetLength();
// Ignore and remove leading blanks in csIn.
while(csIn.GetAt(0) == ' ') csIn.Delete(0);
int inLen = csIn.GetLength();
if(inLen >= lastLen) {
// New, bigger value, save it.
csLast = csIn;
lastLen = csLast.GetLength();
}
int copyChars = lastLen - inLen;
if(copyChars > 0) {
csOut = csLast.Left(copyChars);
}
else csOut = "";
csOut += csIn;
csLast = csOut; // Save the last value for next time.
}
</code>
The main:
<code>
CString csRet;
get("31203", csRet); // csRet becomes "31203"
get(" 401", csRet); // csRet becomes "31401"
get(" 12", csRet); // csRet becomes "31412"
get(" 2110", csRet); // csRet becomes "32110"
get(" 4232", csRet); // csRet becomes "34232"
</code>
Alcohol. The cause of, and the solution to, all of life's problems - Homer Simpson
|
|
|
|
|
Thanks for your time and effort both in helping me to find out the solution. I will give it a try and let you know if there is still some problem that needs to be dealt with.
Thanks once again.
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
Your'e welcome, I'm glad if I can be of assistance to you.
And I can't resist a challenge...
Probably, there are things that must be fixed, this is a quick hack.
But I think the main idea works.
Good luck.
Kakan
Alcohol. The cause of, and the solution to, all of life's problems - Homer Simpson
|
|
|
|
|
kakan wrote: // Ignore and remove leading blanks in csIn.
while(csIn.GetAt(0) == ' ') csIn.Delete(0);
What's wrong with CString::TrimLeft() ?
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
There is nothing wrong with TrimLeft (i hope).
I agree, it's a better choice. But I didn't have the time to tidy up the code. I'm at work, and wanted to help out...
Alcohol. The cause of, and the solution to, all of life's problems - Homer Simpson
|
|
|
|
|
Hi all,
I am currently involved in a migration project from one reporting tool to another. The tool I am migrating reports from displays a large number of items in a window similar to a list box with no option to cut and paste so I currently have to copy them by hand and type them back into the new reporting tool.
The reporting tool API does not have an object that will allow me to access the information so I was wondering if I could get Windows to output the items to a text file as it was displaying them on the screen.
I downloaded the WindowDump utility from
http://msdn.microsoft.com/msdnmag/issues/02/08/EscapefromDLLHell/
in the hope that it would extract the information for me but unfortunately it indicated that the window I was looking at was not the ListBox class but a List class, which I'm assuming is a custom class with no associated Windows functions that will allow me to retrieve information from it.
I then attempted to use windows subclassing to intercept the messages from the List class but discovered that SetWindowLong could not be used on a window outside the application using it.
Can anyone tell me if what I want to do is possible and give me some direction on how to pursue my investigation from here?
Many thanks,
Lep
|
|
|
|
|
Leprechaun78 wrote: ...a window similar to a list box...
Does it respond to listbox messages?
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Nope, the WindowDump utility extracts information from the ListBox class. It didn't retrieve the information from this Window, but it provided the class (List), handle, process, styles etc.
|
|
|
|
|
Leprechaun78 wrote: ...the ListBox class.
Where is this class defined? How would WindowDump even know that an application was usng such a class, let alone have access to it?
Leprechaun78 wrote: ...the class (List), handle, process, styles etc.
I've not heard of a class having a handle and a style. These sound like window properties.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
My terminology is probably incorrect, I don't have a lot of experience of programming in Windows (or anything else!), apologies for that. I thought a window was an instance of a class?
WindowDump uses GetClassName to extract the class name. This is an example of the output:
Class: List
Title:
ID: 0
hWnd: 0x00010d9a
Styles: WS_CHILD
Control Styles:
Dimension: (208,329) 95 x 125
State: Visible Enabled
If the class was a list box WindowDump would retrieve the contents using
SendMessage(hWnd, LB_GETTEXT, iPos, (LPARAM)szLine)
I'm wondering if there is a similar way to access the contents of a custom class?
|
|
|
|
|
Leprechaun78 wrote: My terminology is probably incorrect...
It sounds as though you are confusing a Windows class (e.g., BUTTON, EDIT, LISTBOX, STATIC, COMBOBOX) with a C++ class.
Leprechaun78 wrote: I'm wondering if there is a similar way to access the contents of a custom class?
Yes, but the target control would need to respond to the message for you to get anything from it.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Ok, I'll investigate ways of checking the properties of a C++ class. My thinking is that the application is passing the information to the operating system for it to display, so I want the operating system to output that information somewhere other than the screen (i.e. a text file). Do you think this is possible?
|
|
|
|
|
Leprechaun78 wrote: Do you think this is possible?
Most things are, but that does not necessarily mean they are easy. While intercepting video output is likely doable, it would certainly not be trivial.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
I'll keep investigating. Thanks for your thoughts
|
|
|
|
|
I saw the puzzling class defination in the reference--
http://msdn2.microsoft.com/en-us/library/efk30beh(VS.80).aspx[^]
My question comes from the below line
***********************
CPrimeTest() : m_pCalcNext( new CEvent( FALSE, FALSE ) ) , m_pCalcFinished( new CEvent( FALSE, FALSE ) ) , m_pTerminateThread( new CEvent( FALSE, FALSE ) ) , m_iCurrentPrime( 0 ). If so, why not put them in the body of the class defination.
*******************************
-- How to explain it.
-- Can we treat 'm_pCalcNext', 'm_pCalcFinished' 'm_pTerminateThread' and 'm_iCurrentPrime' as four member variables of public type of the class
<br />
<br />
CPrimeTest { <br />
public: <br />
<br />
{ <br />
CWinThread* pThread; <br />
pThread = ::AfxBeginThread( PrimeCalcProc, this, 0, 0, CREATE_SUSPENDED, NULL); <br />
pThread->m_bAutoDelete = FALSE; <br />
pThread->ResumeThread(); <br />
for( UINT i = 0; i < 10; i++ ) <br />
{ <br />
m_pCalcNext->SetEvent(); <br />
::WaitForSingleObject( m_pCalcFinished->m_hObject, INFINITE ); <br />
TRACE( "The value of m_iCurrentPrime is: %d\n", m_iCurrentPrime ); <br />
} <br />
::WaitForSingleObject( pThread->m_hThread, INFINITE ); <br />
delete pThread; } <br />
<br />
~CPrimeTest() <br />
{ <br />
delete m_pCalcNext; <br />
delete m_pCalcFinished; <br />
delete m_pTerminateThread; <br />
} <br />
private: <br />
BOOL IsPrime( INT ThisPrime ) <br />
{ <br />
if( ThisPrime < 2 ) return FALSE; <br />
for( INT n = 2; n < ThisPrime; n++ ) <br />
{ <br />
if( ThisPrime % n == 0 ) <br />
<br />
return FALSE; <br />
} <br />
return TRUE; <br />
} <br />
INT NextPrime( INT ThisPrime ) <br />
{ while( TRUE ) <br />
{ if( IsPrime( ++ThisPrime ) ) <br />
{ return ThisPrime; } } } <br />
static UINT __cdecl PrimeCalcProc( LPVOID lpParameter ) <br />
{ CPrimeTest* pThis = static_cast<CPrimeTest*>( lpParameter ); <br />
VERIFY( pThis != NULL ); VERIFY( pThis->m_pCalcNext != NULL ); <br />
VERIFY( pThis->m_pCalcFinished != NULL ); <br />
VERIFY( pThis->m_pTerminateThread != NULL ); <br />
CSyncObject* pWaitObjects[] = { pThis->m_pCalcNext, pThis->m_pTerminateThread }; <br />
CMultiLock MultiLock( pWaitObjects, 2L ); <br />
while( MultiLock.Lock( INFINITE, FALSE ) == WAIT_OBJECT_0 ) <br />
{ <br />
pThis->m_iCurrentPrime = NextPrime( pThis->m_iCurrentPrime ); <br />
pThis->m_pCalcFinished->SetEvent(); <br />
} <br />
::AfxEndThread( 0, FALSE ); <br />
return 0L; <br />
} CEvent* m_pCalcNext; <br />
CEvent* m_pCalcFinished; <br />
CEvent* m_pTerminateThread; <br />
};<br />
<br />
<br />
<br />
<br />
|
|
|
|
|
cy163@hotmail.com wrote: Can we treat 'm_pCalcNext', 'm_pCalcFinished' 'm_pTerminateThread' and 'm_iCurrentPrime' as four member variables of public type of the class
Why public ? They are private pointers which are instancied in the constructor (at the line you don't understand). Each of this pointers is a pointer to a CEvent class, and a CEvent class require two parameters for its constructor (I didn't look in detail, but it seems by seing the line you posted).
In fact this part of the line: m_pCalcNext( new CEvent( FALSE, FALSE ) ) is more or less equal to m_pCalcNext = new CEvent(FALSE,FALSE); in the body of the constructor.
So what do you don't understand exactly ?
|
|
|
|
|
Cedric Moonen wrote: is more or less equal to
I'm not sure that I agree with your analysis.
m_pCalcNext( new CEvent(FALSE,FALSE))
is calling a constructor of whatever class m_pCalcNext is. The code posted is using the C++ Initialization List to call constructor of non-pointer member variables, and the same for the others.
led mike
|
|
|
|
|
led mike wrote: is calling a constructor of whatever class m_pCalcNext is
m_pCalcNext is a pointer to a CEvent object.
So this line: m_pCalcNext( new CEvent(FALSE,FALSE)) creates a new instance of the CEvent class, the same way as m_pCalcNext = new CEvent(FALSE,FALSE);
The difference is that here it is in the initialization list and not in the constructor body (that's why I said more or less).
|
|
|
|
|
Cedric Moonen wrote: m_pCalcNext is a pointer to a CEvent object.
Ahhh , didn't look at the link... my bad. Here is one for GWB.... "I was wrong" ... hear that GWB it's not that hard to do you [bleep][bleep][bleep][bleep].
led mike
|
|
|
|