|
I just want to make a small comment on the MyFunc() { style:
IT SUCKS!
Having said that, if you still want to make it happen, the easiest way is to do it for ALL opening braces. Here are the steps I would follow:
1. Loop through every opening brace (not inside a comment or quoted string)
2. Select from the beginning of the line to the brace.
3. If the selection only contains blankspace,
- Delete it, and
- Backspace to the previous line.
4. Go back to step 2 until step 3 fails.
Remember to account for comments and quoted strings. Check the macro's code to see how I do it.
Regards,
Alvaro
Insanity: doing the same thing over and over again and expecting different results. - Albert Einstein
|
|
|
|
|
Alvaro Mendez wrote:
I just want to make a small comment on the MyFunc() { style:
IT SUCKS!
I agree.
|
|
|
|
|
Alvaro Mendez wrote:
IT SUCKS!
I agree, it really sucs!!!
Best regards,
Alexandru Savescu
|
|
|
|
|
Hi
I read posts about deleting files. It also happened to me. However, when I reopened Visual Studio, everything worked great.
Probably this is something similar to the problem when Visual studio looses clipboard.
And also a different problem, I could not format the following code properly
#pragma warning(disable : 4786)
#pragma warning(disable : 4503)
#include <iostream.h>
int main()
{
if (abc) test();
else test3();
A test;
test.i =5;
cout << test.nick << endl;
return 0;
}
Igor Proskuriakov
|
|
|
|
|
Thanks for the excellent work.
I have found a problem in nested switch statement. It seems that lost the nesting depth.
The code bellow is my unfinished working code.
Note: notice that the spaces are lost in mail, I have replaced "tab" character to "+".
Also, If I want to keep the style as shown in original, how do I do?
Thanks,
// ====== Original ===========================================
BOOL CALLBACK
BioDataProc (HWND hdlg, UINT msg, WPARAM wp, LPARAM lp)
{
switch(msg)
{
case WM_INITDIALOG:
PostMessage(hdlg, WM_USER, 0, 0);
return TRUE;
case WM_COMMAND:
switch(LOWORD(wp))
{
case IDM_BIO1:
case IDM_BIO2:
break;
}
break;
case WM_NOTIFY:
switch(((NMHDR FAR*)lp)->code)
{
case PSN_APPLY:
{
}
return TRUE;
case PSN_HELP:
DisplayHelp();
break;
}
break;
case WM_USER:
break;
case WM_ACTIVATE:
}
return FALSE;
}
// ====== After MakeSelectedCodeNicer =====================
BOOL CALLBACK
BioDataProc(HWND hdlg, UINT msg, WPARAM wp, LPARAM lp)
{
+switch (msg)
+{
++case WM_INITDIALOG:
+++PostMessage(hdlg, WM_USER, 0, 0);
+++return TRUE;
++case WM_COMMAND:
+++switch (LOWORD(wp))
+++{
+++case IDM_BIO1:
+++case IDM_BIO2:
++++break;
+++}
+++break;
+++case WM_NOTIFY:
++++switch (((NMHDR FAR*)lp)->code)
++++{
++++case PSN_APPLY:
+++++{
+++++}
+++++return TRUE;
++++case PSN_HELP:
+++++DisplayHelp();
+++++break;
++++}
++++break;
++++case WM_USER:
+++++break;
++++case WM_ACTIVATE:
+}
+return FALSE;
}
|
|
|
|
|
I use this macro to reformart some files,but when run to this line the marco behave unconventionally.Who can help me ?
if (ads_entsel("\nSelect baseline: ",ent1,pt) == RTNORM)
if you want test,you can new a text file and run the macro to test.In my machine ,the line is like the following(after I cancel the macro):
if (ads_entsel("\n选择基线: ",ent1 ,pt) == RTNORM)
Thanks a lot!
|
|
|
|
|
if (ads_entsel("\nselect baseline :",ent1 ,pt) == RTNORM)
there are hundreds of blanks in "ent" and ",pt)==RTNORM),but in html this not show
|
|
|
|
|
I'm a chinese,I find when the prompt is use english there is no problem...but if if I use chinese language,when I run the reformat marco,the error occur...
|
|
|
|
|
I played a bit with it, the following code is deleted instead of reformatted!
int test()
{
int s;
for (s=0;s<2;s++)
{
test();
if (t==1)
{
test = 3;
}
}
}
This is no actual code, I've just typed a few lines.
Greetings,
Thomas
|
|
|
|
|
Deleted ha? That's a new one! I took this "not actual" code, copied it to a new file inside Visual C++, ran the macro, and guess what? It got reformatted beautifully.
Have you tried recording and running your own macros to see if you see the same behavior. It seems like something that only you're experiencing.
Regards,
Alvaro
|
|
|
|
|
I propose this utility here, because I think it may be of interest for some users.
It does a similar job as this one, except it is an external program, so its aim is quite different.
Check Artistic Style at http://astyle.sourceforge.net/
It seems it still have some bugs, but it is open source, so you can make it work the way you want...
|
|
|
|
|
I did look at Artistic Style, it is quite good, but not strict enough for me, e.g. it does not remove unnecessary spaces.
If you compare code of those two utilities, you may find that VBscript is much easier to understand.
Ideal utility is GNU indent, but it does not handle C++. Under ideal, I assume that you can configure almost everything, and when you add or remove any spaces or tabs and run the program once again, you shall have the same results.
Igor Proskuriakov
|
|
|
|
|
It does not move a block to the first column if the first character of the block is not at first column. This may be useful for copy-paste -- stealing others' code.
By the way, I hardly use formatting tools. It seems that Edit->Advanced->Format Selection is quick enough for me. At least it removes the indents that should not be there.
Has some one compare this tool with Smart Format that comes with MS studio?
|
|
|
|
|
I ran this macro on a large file. Visual C++ ran out of memory.
I was prompted to open a new instance of VC for each large file. I ran the large file again. It came up with the same problem. But the worst part is that when I tried to open up VC again - it came up with an acces violation on the strart-up screen. I will need to reload Visual C++.
|
|
|
|
|
Reload Visual C++? Do you mean reinstall it?
If that's the case, then it's definetely the first one I've come across. Try just rebooting your machine or something. You shouldn't need to reinstall VC... unless its registry settings got messed up somehow. Wow, that's one nasty VC bug, ha?
I have been able to run the macro on very large files once per VC session. After that I just close VC, open up a new session, and I can run it fine on another large file. If you can't even do that on your file, then perhaps it's way to huge even for one session. Try breaking it up.
Regards,
Alvaro
|
|
|
|
|
Yes - I Had to do a clean reinstall! Not even reinstalling sp3 helped.
This is realy a great utility. We want to use it in team development where every programmer has his own style.
I think that this will maybe work better as an add -in dll.
Send me your ideas on this - maybe we can work together ?
|
|
|
|
|
Hmmm, I wonder if these problems still occur when the script is executed through an add-in instead of the VBScript interpreter...
Anyway, I've never written an add-in before but I imagine it's not difficult. The problem is time, and right now I have very little of it to put into this type of effort.
Also, I wonder if a tool already exists that allows individual programmers to reformat code to their own tastes. That would be a nice one to have.
Regards,
Alvaro
|
|
|
|
|
Alvaro,
You really should invest the time to make this an add-on. As a VB macro it's great for small files but I've had to reinstall 3 times in the past few months with it. I see other people have that problem and I'm hoping an add-on would solve the problem. Also, it can still run out of memory. I had a source file that was about 2500 lines long and it couldn't handle it. As an add-on, you could specify the different indent styles and tab sizes and whatever else you can throw in there.
Well, I'm off to uninstall and reinstall VS but it's a pain. BTW, I didn't experience the crash after out of memory problem with my source, I just fired up Visual Studio this morning and I got the out of memory error on startup. It was working fine last night and I haven't done anything to the machine since then. Oh well.
Keep up the excellent work on the macro but I would really like to see it as an add-on which will hopefully correct these few problems.
Bil Simser
Calgary, Alberta
bsimser@home.com
|
|
|
|
|
The same thing happend to me!
I also ran the macro on a large file and got a message like "Undo buffer full".
After that Visual Studio came up with a runtime error. With every restart VS
came up with a runtime error again. A complete reinstall doesn't fix the problem.
I had to remove VS from my machine did a new install.
Best regards
Holger
|
|
|
|
|
right now this macro will format switches like:
switch (x)
{
case 1:
{
break;
}
case 2:
break;
}
i like to do this:
switch (x)
{
case 1:
{
break;
}
case 2:
break;
}
but i can't get it to work with my mods. anyone out there know how i can get it to work?
|
|
|
|
|
Nice tool, but I sometimes get a type mismatch error in row 393 like '[string: "127,"]'.
kind regards
|
|
|
|
|
The following code:
TemplatedClass<type> myInstance;
gets reformatted as:
TemplatedClass < type> myInstance;
Robin Summerhill
|
|
|
|
|
And this message board doesn't cope well with less-than's
The first line should read TemplatedClass<type> myInstance;
|
|
|
|
|
Same error occurs with string such as "<", which becomes " < " (and these quotes are string delimiters, not for visual enhancement here ). Applies also to '<'.
Best regards,
Thomas
I am a signature virus!
Help me spread and copy me to your sig!
|
|
|
|
|
I'm not sure, but I think I may have already addressed this issue on a previous update.
If it's still happening, please let me know with an example.
Regards,
Alvaro
Insanity: doing the same thing over and over again and expecting different results. - Albert Einstein
|
|
|
|