|
I have done some UNIX shell programming and there is a language called awk that is really useful for parsing non uniform strings separated by a delimiter.
I am trying to parse strings like the following lines of data
COMP R7002 06R55199D30 RES sm_r0402 4.58 2.996 2 180
COMP R7003 06R55161B15 RES sm_r0402 4.708 2.65 2 0
COMP C3023 21R55169G21 CAP sm_c0402 0.791 3.659 2 180
COMP C3024 21R55169G21 CAP sm_c0402 0.706 3.588 2 0
COMP U3000 51R44976U01 LM3477MM sm_soic8_gt099_026_xa 0.563 3.64 2 0
as you can see they are not completely uniform.
I can write a loop looking at each char and then chop up the string into variables, I was just wondering if there was an faster (and easier) way
CString str;
CString tmpstr;
for(int i=0; i < m_objRawData.GetUpperBound(); i++)
{
str = m_objRawData.GetAt(i);
if(str.Left(4) == "COMP")
{
while(str.GetLength() > 0)
{
tmpstr = str.SpanExcluding(" ");
str.TrimLeft(tmpstr + " ");
}
}
}
|
|
|
|
|
Thanks for clarifying. I think strtok may be what you want.
Example
/* STRTOK.C: In this program, a loop uses strtok
* to print all the tokens (separated by commas
* or blanks) in the string named "string".
*/
#include <string.h>
#include <stdio.h>
char string[] = "A string\tof ,,tokens\nand some more tokens";
char seps[] = " ,\t\n";
char *token;
void main( void )
{
printf( "%s\n\nTokens:\n", string );
/* Establish string and get the first token: */
token = strtok( string, seps );
while( token != NULL )
{
/* While there are tokens in "string" */
printf( " %s\n", token );
/* Get next token: */
token = strtok( NULL, seps );
}
}
Output
A string of ,,tokens
and some more tokens
Tokens:
A
string
of
tokens
and
some
more
tokens
Christian
As I learn the innermost secrets of the around me, they reward me in many ways to keep quiet.
Men with pierced ears are better prepared for marriage. They've experienced pain and bought Jewellery.
|
|
|
|
|
I have never had this problem with VC, but anyhow today I was trying to debug a code and I place a breakpoint within a function in the view file and when I try to debug it, it prompts with the release message that the breakpoint is not valid. Any idea why this would happen in debug mode?
|
|
|
|
|
Try clean and rebuild all in debug mode. Check if you have put the break points in the proper files. There is a chance that you have put the break point in a copy of your actual file.
|
|
|
|
|
[ Returning to MFC-land after a year long journey into Java. Please forgive my feeble brain... ]
I have a dialog (CMyDialog) that doesn't have a title bar. I override OnNcHitTest() to return HTCAPTION, which allows me to move the dialog by dragging its client area.
CMyDialog contains a modeless child dialog (CMyChildDialog) within it. The child dialog happens to contain a couple of static text controls that are asynchronously updated based on some events in the universe.
Q: How do I allow CMyDialog to be dragged when I initiate the drag from within CMyChildDialog? (I don't want to override CMyChildDialog::OnNcHitTest() because I don't want the child dialog to be movable within its parent.)
Thanks,
/ravi
"There is always one more bug..."
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
|
Sorry, I should've RTFM. Many thanks!
/ravi
"There is always one more bug..."
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
A cleaner way is to override WM_LBUTTONDOWN:
void CSomeDlg::OnLButtonDown(UINT nFlags, CPoint point)
{
PostMessage ( WM_NCLBUTTONDOWN, HTCAPTION, MAKEPOINTS(point.y << 16 | point.x) );
} That way you don't have to handle any special messages in the child dialogs.
--Mike--
http://home.inreach.com/mdunn/
A recent survey reports that 1/4 of all internet users in England surf for porn.
The other 3/4 just didn't want to admit it.
|
|
|
|
|
MAKEPOINTS gives a compiler error. It works without this macro.
void CSomeDlg::OnLButtonDown(UINT nFlags, CPoint point)
{
PostMessage ( WM_NCLBUTTONDOWN, HTCAPTION, (point.y << 16 | point.x) );
}
|
|
|
|
|
I'm already overriding the LButtonDblClick handler, so I'd prefer not to override OnLButtonDown as it can cause conflicts.
Trivia: I'm also overriding OnNcRButtonUp to display a context menu, since OnContextMenu() no longer works since the OS thinks I'm always on the caption bar. I considered just adding a caption bar and menus, but that would ruin the flavor of the app (it looks like a toolbar).
/ravi
"There is always one more bug..."
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
Hi,
I am currently trying to save a CBitmap to disc. And Have the following questions.
Is A CBitmap Always A DIB?
Is A HBITMAP Always A DIB?
Does anyone know any good resources for saving CBitmaps to disc?
I have been looking at the routines, on codeguru.com wrote the following code using them. All i get though is a blank bitmap.
HBITMAP testbmp;
testbmp= (HBITMAP) LoadImage(0,"C:\\orginal.bmp",IMAGE_BITMAP, NULL, NULL, LR_LOADFROMFILE);
CBitmap test;
test.Attach(testbmp);
WriteDIB( "C:\\two.bmp", DDBToDIB(test,BI_RGB,NULL));
The second parameter of DDBToDib is the compression, and the third is the palette, if no palette, is provided the default is used.
Anyone any clues where i am going wrong, all i get is a blank bitmap. I am using a 24bit BMP but tried tried with others.
Thanks Again
Richard
|
|
|
|
|
Is A CBitmap Always A DIB?
No.
Is A HBITMAP Always A DIB?
No.
Check the DIBLOOK sample in your VC++ help for bitmap-saving code.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
Is A CBitmap Always A DIB?
Is A HBITMAP Always A DIB?
It's usually a DDB.
Does anyone know any good resources for saving CBitmaps to disc?
Plenty on the site. Look around.
I have been looking at the routines, on codeguru.com wrote the following code using them. All i get though is a blank bitmap.
HBITMAP testbmp;
testbmp= (HBITMAP) LoadImage(0,"C:\\orginal.bmp",IMAGE_BITMAP, NULL, NULL, LR_LOADFROMFILE);
This is not a DIB - you didn't specify LR_CREATEDIBSECTION.
CBitmap test;
test.Attach(testbmp);
WriteDIB( "C:\\two.bmp", DDBToDIB(test,BI_RGB,NULL));
The second parameter of DDBToDib is the compression, and the third is the palette, if no palette, is provided the default is used.
Anyone any clues where i am going wrong, all i get is a blank bitmap. I am using a 24bit BMP but tried tried with others.
I'd suggest that the problem is the flag I've pointed out. You also need when creating bitmaps to create a DIBSection. A DIBSection is a DIB that can be selected into a DC and attached to a CBitmap. There are good DIBSection wrappers here and on paintlib.de
Christian
As I learn the innermost secrets of the around me, they reward me in many ways to keep quiet.
Men with pierced ears are better prepared for marriage. They've experienced pain and bought Jewellery.
|
|
|
|
|
I need convert a integer in range 0-9999 to string in format of
4 bytes ,
for example:
34 -> "0034"
What can I do ???
|
|
|
|
|
use CSting.Format(, sprintf, or itoa (all documented in the help files)
|
|
|
|
|
char string[1024];
sprintf(string, "%04d", 1);
printf("%s", string); // 0001
|
|
|
|
|
Hi ,
I'm using hebrew enabled Win2K and when I enter my username in some dialog
the CEditBox shows some strange symbols ( gibrish - not english and not hebrew ).
I want to set somehow input language of this edit box to english - totally independant from system language.
I've searched MSDN , read this forum , tried this :
1)
// save the old locale
LCID oldLCID = GetThreadLocale();
2) SetThreadLocale(
MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT));
3) // set the old LCID one back
SetThreadLocale(oldLCID);
It didn't work and BTW it's only supported in Win NT
tried to play with nCharSet setting it to
ANSI_CHARSET 0
DEFAULT_CHARSET 1
SYMBOL_CHARSET 2
SHIFTJIS_CHARSET 128
OEM_CHARSET 255
etc.
Nothing worked.
Any help will be much appreciated !
Thanks,
Leon
|
|
|
|
|
Is there a way in VC++ to determine the drive name (volume label) for floppy drives, hard drives, CD-Rom drives, and network drives?
Thanks.
P.S. I tried GetVolumeInformation() and it works for the Floppy Disk 'A:', the Hard disk 'C:', and for the CD-Rom 'D:', but not for the network drives. Also, is there any way to determine if there is a diskette in the Floppy drive without trying to access it?
|
|
|
|
|
For network drives, use the WNetGetConnection function:
char cName[50];
DWORD dwLen = 50;
DWORD dwRes = WNetGetConnection("F:", cName, &dwLen);
dwRes will return NO_ERROR (0) if all is ok, and the drive's UNC name will be loaded into
cName. Any other value in dwRes indicates a failure. Use GetLastError() to determine the type of error.
Hope this helps.
|
|
|
|
|
Hi.
I'm beginner in MSMQ programming.
I have problem:
my workstation(NT4, WS, SP6, Independet Client of MSMQ) don't logon on domain with ActiveDirectory and MSMQ.
I use MSMQ API.
When I do MQOpenQueue(...) - result this function MQ_ERROR_SERVICE_NOT_AVAILABLE(Cannot connect to the Queue Manager).
Help me, please. I must Open Queue!!!
P.S. I'm sorry, but my English not good.
iLYA
Russian Software Developer
|
|
|
|
|
I've been tasked with developing an application that will automatically log a user off of a Novell Network after some number of time (say an hour). Right now, I'm thinking about simply monitoring the computer for inactivity (no keyboard or mouse events), but that doesn't seem right. I'd rather monitor for a lack of network activity, and if there is none after an hour, then I need to log the user off automatically. Which libraries and functions should I be checking out to develope this app? Thanks in advance for any suggestions.
Jamie Nordmeyer
Portland, Oregon, USA
|
|
|
|
|
If you have any smb-stations on the network, they will broadcast their presence sometimes. I would go for mouse/keyboard
|
|
|
|
|
Does anyone know of any software copanies or positions in the Portland/Salem, Oregon USA area that are currently hiring??
Thanks ~
|
|
|
|
|
Better question, are there any software companies in the entire US hiring?
I was actually thinking about this the other day. Does anyone know of any positions that have been filled in the last couple of months. I spent some time chatting with a recruiter I've known for awhile. He has been very fustrated by companies posting positions then pulling them after candidates have been submitted, or interviewing a few and then not returning emails or phone calls.
|
|
|
|
|
I started my current job on June 18. It has nothing to do with COM, XML, ASP, or anything close to being web-enabled. They just needed someone that could do MFC and C++.
Here's a little feedback on "recruiters". I don't really care for them. They are NOT genuinely concerned with getting you the best job to fit your skillset. They are concerned with getting you the best paying job, whether you are qualified or not. If they're just recruiters, they get a fee based on your hire salary. If they're from someplace like RHI or Maxim Group, they get at LEAST 95% of your salary as a fee for as long as you're contracted out.
They are NOT concerned with anything but how much money they're going to make off of you. They rip off companies who are desperate for qualified help and that would be be much better off financially by placing ads and going through the interview process themselves.
Maybe a good kind of company to have available is someone that merely conducts testing and first (and maybe even second) interview for potential employees, and pass on those who seem to be the best qualified. Charge a one-time fee on a per-interview process, and move on. That way, the company looking for the employee doesn't have to pay their existing high-dollar employees (managers and senior programmers) to conduct interviews themselves until a viable candidate has been weeded out of the stack.
|
|
|
|
|