|
Eranga Thennakoon wrote: if(aa.ReverseFind('.') == 13)
{
bb = aa.Left(13);
AfxMessageBox(bb, MB_OK);
}
Even if you have a fixed filename length wouldn't it be better to just use:
<br />
if(aa.ReverseFind('.') != -1)<br />
{<br />
bb = aa.Left(aa.ReverseFind('.'));<br />
AfxMessageBox(bb);<br />
}
It is much more flexible if the filename was changed to another one.
Also, you can just use AfxMessageBox(bb); instead of AfxMessageBox(bb, MB_OK); since the default for AfxMessageBox is the one with OK button anyway.
|
|
|
|
|
Llasus wrote: Even if you have a fixed filename length wouldn't it be better to just use:
Yep, it's better. At the same time I've try another way to do this, but felt so mess. Use Find() to get the last '\' and then read backward to find the name. Try to follow the same way to find '.' and avoid extension. Failed. :->
Llasus wrote: Also, you can just use AfxMessageBox(bb); instead of AfxMessageBox(bb, MB_OK); since the default for AfxMessageBox is the one with OK button anyway.
Thanks pal for the infor. I just used it, because I feel it is completed my code in view. Actually it is useless. I have to type more and more when I used message box. Actually on my testings I used more message boxes to verify my output.
I appreciate your help all the time...
Eranga
|
|
|
|
|
Hi,
for viewing intermediate results I seldom use MessageBox. I prefer either writing to
the console (which is the output pane in Visual Studio while debugging) as printf() does,
and/or writing to a log file. In both cases the advantages are: you don't have to click
OK buttons all the time, and you get to see a lot of intermediate results on consecutive
lines, seems easier to figure out where things start to go wrong.
Anyway, I tend to create a "void log(char*)" function that does the above (and appends
a newline if appropriate).
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- use PRE tags to preserve formatting when showing multi-line code snippets
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
Thanks pal. Actually lots things I have done on MFC. So that's why I used that way to check weather I'm going wrong or not.
I appreciate your help all the time...
Eranga
|
|
|
|
|
Or use TRACE
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
|
|
|
|
|
Eranga Thennakoon wrote: Use Find() to get the last '\' and then read backward to find the name. Try to follow the same way to find '.' and avoid extension. Failed.
Why mess with all of this, where there are existing functions that do it for you? Will your code work with other character sets?
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
I have a mess here. I no it is complicated that this way.
CString::Find()
Thing is that, can I used index to get a sub-string. Basically it searches the sub-string which we define. Then gives ASSERT the application.
What is your comments on my thought.
I appreciate your help all the time...
Eranga
|
|
|
|
|
Can you give the snippet of your code which causes the assert error?
|
|
|
|
|
Actually I don't have a code. I asked this based on MSDN example. I try it coding and let you know.
I appreciate your help all the time...
Eranga
|
|
|
|
|
Eranga Thennakoon wrote: Then gives ASSERT the application
what was your string?
|
|
|
|
|
You mean the CString which I used. It's like this, a path of a file.
F:\Resources\Files\G00166_003_01.txt
I appreciate your help all the time...
Eranga
|
|
|
|
|
Eranga Thennakoon wrote: What is your comments.
Your code is inefficient, and makes many assumptions.
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Check the PathStripPath() function
|
|
|
|
|
Thanks pal. But I feel that ReversFind() more easy, because I can use Mid() to extract any sub-string from the file name.
Thanks again.
I appreciate your help all the time...
Eranga
|
|
|
|
|
I'd strongly recommend using the ShellAPI command that David pointed you to.
What about
c:file.txt?
or all sorts of strange notations for filenames you will hardly ever use, but the shell team have handled for you?
Iain.
|
|
|
|
|
Or what about those that are named file.jpg.exe on machines with "Hide extensions for known file types" turned off? The possibilities are not endless, but there are several of them to consider when rolling your own implementation.
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Some people just like that thunking feeling they experience as they keep banging their head upon the wall ...
I can't wait to see what turds float to the surface the moment a customer passes a network file path into that garbled up code!
I also like the code examples you come across that assume the 'path' starts after the semicolon.
Oh, wait the path "\\Dev\Link\Shared\MyFile.Txt" does not have a semicolon, how can this be
|
|
|
|
|
How about PathFindFileName in shlwapi.dll?
Pax Domini sit semper vobiscum
|
|
|
|
|
Thanks pal. But I think dealing with ReversFind() is so easy.
I appreciate your help all the time...
Eranga
|
|
|
|
|
Does anyone know of any open-source code that will allow me to parse a C++ header file for all the class method signatures?
---
Yours Truly, The One and Only!
web: devmentor.org
Design, Code, Test, Deploy
|
|
|
|
|
Can you more explain about parsing a header file,please?
|
|
|
|
|
i am looking for simple code that will give me a list of all the class method signatures. i want to use these signatures for a tool to generate mock classes for a unit testing tool i have developed.
---
Yours Truly, The One and Only!
web: devmentor.org
Design, Code, Test, Debug
|
|
|
|
|
What part of "parse a C++ header file for all the class method signatures" is troubling you? That's fairly self-explanatory, yes?
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Yeah I see.
BTW(I saw your signature they are nice sentences).
|
|
|
|
|