macros

Is there a method to swap the left and right hand sides of a set of expressions in Visual Studio?

I have a decent sized set of data that needs to be stored in an active record. In order to prepopulate the form fields on the page, I have already written the following code: Device device = new Device(DeviceID); // device is simply the active record txtDeviceName.Text = device.Name; txtNotes.Text = device.Notes; txtHostName.Text = dev...

Macros in SQL Server Management Studio

Is there any way to implement text editing macros in SSMS? I would, e.g. like to convert the the code as shown below, but with a key-press, not a long-winded regex search and replace. This: INSERT INTO [TABLE] ([fieldOne] ,[fieldTwo]) VALUES (<fieldOne, datetime,> ,<fieldTwo, real(24,0)) Must become this: INSE...

What is the worst real-world macros/pre-processor abuse you've ever come across?

What is the worst real-world macros/pre-processor abuse you've ever come across (please no contrived IOCCC answers *haha*)? Please add a short snippet or story if it is really entertaining. The goal is to teach something instead of always telling people "never use macros". p.s.: I've used macros before... but usually I get rid of the...

Macros and Visual C++

I'm trying to get a better understanding of what place (if any) Macros have in modern C++ and Visual C++, also with reference to Windows programming libraries: What problem (if any) do Macros solve in these situations that cannot be solved without using them? I remember reading about Google Chrome's use of WTL for Macros (amonst other t...

What are C macros useful for?

I have written a little bit of C, and I can read it well enough to get a general idea of what it is doing, but every time I have encountered a macro it has thrown me completely. I end up having to remember what the macro is a and substitute it in my head as I read. The ones that I have encountered that were intuitive and easy to understa...

Visual Studio 2003, Macro, Process.Attach not working always

I'm using Visual Studio 2003, and I have a macro similar to this: Dte.Debugger.DetachAll() For Each proc As EnvDTE.Process In DTE.Debugger.LocalProcesses If proc.Name.IndexOf("ehexthost.exe") <> -1 Then proc.Attach() End If Next The first time use the macro, it works fine. Each subsequent time,...

Making row ranges adjust

In my Excel spreadsheet, I've got a cell that is =SUM(C6:C19). If I go to C20 and add a row, that formula will not adjust. I want it to change to =SUM(C6:C20) ...

emacs lisp, can you create interactive functions in a macro?

I'm trying to write a macro in emacs lisp to create some 'helper functions' Ultimately, my helper functions will be more useful that what I have here. I realize that there may be better/ more intuitive ways to accomplish the same thing (please post) but my basic question is why won't this work/ what am I doing wrong (defmacro deftext (...

C macro pitfalls

Duplicate: Good Programming Practices for Macro Definitions (#define) in C C (and by extension C++) macros are laden with pitfalls and practical problems when not implemented properly. Take, for example, the macro #define cube(x) x*x*x What is wrong with it? Where will it fail? When can unexpected results be returned? What is ...

Visual Studio Macro to Paste similar to String.Format

I'd like to be able to cut/copy a string like "<strong>{0}</strong>" for example. I'd like to then select some code such as "Hello, World" and then invoke a macro which will result in "<strong>Hello, World</strong>". How could you do this? Update: WHY do I want to do this? I could just make a macro or shortcut to add something specif...

Outlook automatically change reminder based on category

I need to automate Outlook so that when a user sets a certain category on an appointment, it automatically sets the reminder time based on the category. For example, the user has an "On site meeting" category and an "Off site meeting" category. He wants the reminder time to automatically change to 15 minutes for an on site meeting and ...

How to highlight calculated fields in an Excel spreadsheet?

Is there a simple way to do this, via macro or otherwise? By calculated field I mean a field that is computed from other fields, versus raw entered values. By highlight I mean colored differently. I need this to better understand a large spreadsheet from a client. ...

Macro expansion in C++

How can I define a macro (or a workaround for this) where the parameter is at the beginning of the line? #define SINGLETON_IMPLEMENTATION(className) \ ##className* ##className::instance_ = NULL; This give a compiler warning (GCC 3.2.3): " '##' cannot appear at either end of a macro expansion" ...

C/C++: How to make a variadic macro (variable number of arguments)

I want to write a macro in C that accepts any number of parameters, not a specific number e.g. #define macro( X ) something_complicated( whatever( X ) ) where X is any number of parameters I need this because whatever is overloaded and can be called with 2 or 4 parameters. I tried defining the macro twice, but the second definiti...

Macro to save active Sheet as new workbook, ask user for location and remove macros from the new workbook

Hi everybody, I have a Workbook with three WorkSheets: Product , Customer, Journal. What I need is a macro assigned to a button within each one of the above Sheets. If the button is clicked by the user, then the active sheet should be saved as a new workbook with the following naming convention: SheetName_ContentofCellB3_DD.MM.YYYY wh...

$macro substitution - ExpandString limitations

I am trying to implement macro replacement based on this discussion. Basically it works, but seems the ExpandString have some limitatoins: main.ps1: $foo = 'foo' $text = [IO.File]::ReadAllText('in.config') $ExecutionContext.InvokeCommand.ExpandString($text) | out-file 'out.config' in.config (OK): $foo in.config (Error: "Encountere...

c++ conditional macro evaluation

I have a symbol defined globally that needs to be conditionally undefined for a given subset of my source files. All of the files that require special treatment are already wrapped in pre- and post-inclusions: pre.h: #undefine mysymbol // [1] post.h: #define mysymbol MY_SYMBOL_DEFINITION // [2] My problem is that the pre.h and pos...

Changing a querytable source twice in the same macro fails

I have an Excel spreadsheet featuring a macro that updates the connection string for a couple of query tables, refreshes them, and then saves a copy of the file. (i.e., "Extract the data for x client into this table, and this one, then save the file so I can send it.") I'd like to expand its capabilities so that it can do this a series...

Need help rewriting a C macro as a function

Hi, I need some help rewriting the following line in a more type safe way and rewriting it as a function, however the fact that this code is defined inside a function is making it hard for me to think of a clever way of doing it because apparently it would involve declaring several arguments. #define CHECK(id) if(table->cells[id]) isgoo...

C style: Macros or preprocessor?

I've written a library to match strings against a set of patterns and I can now easily embed lexical scanners into C programs. I know there are many well established tools available to create lexical scanners (lex and re2c, to just name the first two that come to mind) this question is not about lexers, it's about the best approach to "...