![]() |


|
|||||||
| Hardware & Software Discussion Hardware and Software discussion and troubleshooting. Tweakers and Overclockers welcome! |
![]() |
|
|
Thread Tools |
|
|
#1 (permalink) |
|
Join Date: Jul 2005
Location: Ottawa Valley
Posts: 6,154
|
Visual Studio macros help?
I'm taking a shot in the dark here, but I figure maybe someone in this community has worked with VB macros in Visual Studio and can help me.
I am working on a simple macro, but I've never worked with VB or the macro editor in any way besides the most basic changes to other people's macros. I have lots of long arrays in C++ code initialized like this a[0] = &blah1; a[1] = &blah7; a[2] = &blah13; ... a[49] = &blahblah985; And sometimes (like right now), I need to make a change to the list, where I insert or remove an element. When I do that, I need to renumber every element in the array after the point where I make the change. So I figured I would dig into the macro editing of VS and make a simple macro which would renumber my array. - select block of text - fire off renumber macro - hooray So... I need to find the identifier "a", then for every occurrence of a[n], I need to replace the existing n with the right value. Hm... I may have found my answer already, but if anyone here is a pro and wants to give me the easy solution, I'm listening. ![]()
__________________
Peace through fear... since 1947! |
|
|
|
|
|
#3 (permalink) |
|
Join Date: Jul 2005
Location: Ottawa Valley
Posts: 6,154
|
Re: Visual Studio macros help?
True, if I weren't dealing with more than 10k lines of existing code. Many of the arrays are also overlapped because it makes the code easier to understand.
Code:
a[0] = &moo; a[1] = &bdefn; //bdefn points to b[] b[0] = &tralala; b[1] = &omg; b[2] = NULL; a[2] = &fubar; a[3] = NULL; ![]() I have almost solved my problem except that my search for ^:b*{:i}\[:z\] isn't giving me the right results. (that's a line starting with 0 or more blanks, then an identifier, then [, then an integer, then ]) gah... it's the weekend... I need to turn this off now...
__________________
Peace through fear... since 1947! |
|
|
|
|
|
#4 (permalink) |
|
Join Date: May 2003
Location: Ottawa, Canada
Posts: 4,633
|
Re: Visual Studio macros help?
I don't always try to do a search and replace with a single regex. I usually do several just because it's easier for me to understand and figure out. That might be easier instead of thinking of one regex to complete the entire job.
|
|
|
|
|
|
#5 (permalink) |
|
Join Date: Jul 2005
Location: Ottawa Valley
Posts: 6,154
|
Re: Visual Studio macros help?
Ya, but this is just one simple find. I just have problems because MS doesn't use the same regex syntax from one place to the next. I tested that string in the normal find/replace and it worked fine.
__________________
Peace through fear... since 1947! |
|
|
|
|
|
#6 (permalink) |
![]() Join Date: Aug 2005
Location: Columbia, SC
Age: 29
Posts: 935
|
Re: Visual Studio macros help?
Can't help, but maybe you can find some help here
|
|
|
|
| Sponsored links | |
|
|
|
|
|
#7 (permalink) | |
|
Join Date: Jul 2005
Location: Ottawa Valley
Posts: 6,154
|
Re: Visual Studio macros help?
Quote:
I am very close. So close that I might break down and use some of my own time to get it. In a week, I might not be using Visual Studio anymore, but I will have that little bit of knowledge in my pocket to use next time.
__________________
Peace through fear... since 1947! |
|
|
|
|
|
|
#8 (permalink) |
![]() Join Date: Aug 2005
Location: Columbia, SC
Age: 29
Posts: 935
|
Re: Visual Studio macros help?
Yeah I know the feeling, I spent most of my day trying to convince our DB server that CSV files really can have commas inside a quote-delimited field. There are lots of workarounds, but I wanted to make it work my way :-)
VB macros is just one of those things I think goes against all that is right and good in the world. |
|
|
|
|
|
#9 (permalink) |
|
Join Date: May 2003
Location: Ottawa, Canada
Posts: 4,633
|
Re: Visual Studio macros help?
If the regex system in Visual Studio is weird, you can always open the file in another editor that has regex that does make sense.
You could also try matching all characters up to an equal sign instead of specifically spaces, identifier, square brackets, etc. |
|
|
|
|
|
#10 (permalink) |
|
Join Date: Dec 2006
Location: Auburn, Alabama, USA
Age: 22
Posts: 259
|
Re: Visual Studio macros help?
Use vi, heh. Recently read an article about it doing just what you need.
__________________
![]()
|
|
|
|
| Sponsored links | |
|
|
|
|
|
#11 (permalink) |
|
Join Date: Jul 2005
Location: Ottawa Valley
Posts: 6,154
|
Re: Visual Studio macros help?
Ya, I figure it would take me about a few minutes to come up with a script in another language, but that's cheating.
![]() Cool vi stuff. I have used it for years but I still don't know half of the functionality. Too little room in my head.
__________________
Peace through fear... since 1947! |
|
|
|
|
|
#12 (permalink) |
|
Join Date: May 2003
Location: Ottawa, Canada
Posts: 4,633
|
Re: Visual Studio macros help?
If you can figure it out using another language or any other method, it's not cheating. It's getting the job done. Don't think you have to restrict yourself to certain tools just because you'll learn something. You'll learn something by using the right tools for the job.
|
|
|
|
|
|
#13 (permalink) | |
|
Join Date: Jul 2005
Location: Ottawa Valley
Posts: 6,154
|
Re: Visual Studio macros help?
Quote:
__________________
Peace through fear... since 1947! |
|
|
|
|
|
|
#14 (permalink) | |
|
Join Date: May 2003
Location: Ottawa, Canada
Posts: 4,633
|
Re: Visual Studio macros help?
Quote:
![]() Go for it with the vi editor. Unless... you've got too little room in your head right now. ![]() |
|
|
|
|
|
|
#15 (permalink) |
![]() Join Date: Jul 2005
Location: Half Moon Bay, CA, USA
Age: 42
Posts: 840
|
Re: Visual Studio macros help?
you could do something like
Code:
i=0; a[i++] = &something; a[i++] = &tra; ib=0; b[ib++] = &xxx b[ib++] = null etc. Ideally you'd put the initialization data in an external config file.
__________________
Gigabyte P35-DS3R, 2GB, 8800GTS 640MB, Core2Duo E8400 |
|
|
|
| Sponsored links | |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
|
|

