macros

Windows macro recording tool?

I find it really useful to record temporary keyboard macros to help with day to day programming tasks. For example, sometimes I need to convert some data into one time use SQL INSERT statements, or re-format some ugly SQL (usually generated by SSMS) into something prettier. SQL Server Management Studio doesn't do macros, and the macro ...

Malloc & Init - MACRO

Is it possible to rewrite the following code, so that it would be ISO C compliant ? The following macros are doing a malloc & init for a given type and value. The current code works with the gcc compilers (uses a gcc extension), but it's not standard. If I use -pedantic, I receive warnings. #ifdef __GNUC__ #define NM_CVPTR(type, valu...

'this' pointer in macro and function

Hello guys, I have some code which use 'this' pointer of class which calls this code. For example: Some::staticFunction<templateType>(bind(FuncPointer, this, _1)); Here is I'm calling bind function from boost. But it doesn't matter. Now I have to wrap this code. I made a macro: #define DO(Type, Func) Some::staticFunction<Type>(bind(F...

Number of arguments in macro definition

Hello, I have some templated function which has different number of arguments due to the template-type. This function is wrapped with macro definition. #define SomeTemplate(TemplateType, Arguments) someFunc<TemplateType>(Arguments); Everything is okay until I'm using only 1 argument for function calling. But I need in more. I looked a...

EXCEL-MACR0-VBA SOS

Hey. I urgently need some help on building up a complete table using VBA. I have got data from two seperate sources of data and i need to put them into same table based on one of the category "Car". I've uploaded an example here .http://www.speedyshare.com/files/23058842/abc.xls ...

Is there a way to 'expand' the #define directive?

I have a lot of "stupid" #define in a project and i want to remove them. Unfortunately, i can't do a simple search&replace, since the #define is parametrized. For example: #define FHEADGRP( x ) bool _process_grp##x( grp_id_t , unsigned char ) This is used to generate headers of a couple of functions. I would like to somehow do the sam...

(Embedded) C: void function() or #define FUNCTION()

Hi, im programming embedded devices and I was wondering what to use for a macrofunction, for example an init of some registers. should i make this static/const or define it as a macro? for example, this: #define FPGA_INIT()\ { \ /* Set function and direction of start_code pin*/\ P0SEL &= ~0x04; \ P0DIR |= 0x04; \ FPGA_START_CO...

How to redefine a macro using its previous definition

Suppose I have the following macro: #define xxx(x) printf("%s\n",x); Now in certain files I want to use an "enhanced" version of this macro without changing its name. The new version explores the functionality of the original version and does some more work. #define xxx(x) do { xxx(x); yyy(x); } while(0) This of course gives me red...

How to define a constant conditionally

Hi All, I want to define some constants in my C file. Its assembly code like this: Const1 = 0 Const2 = 0 IF Condition1_SUPPORT Const1 = Const1 or (1 shl 6) Const2 = Const2 or (1 shl 3) ENDIF IF Condition2_SUPPORT Const1 = Const1 or (1 shl 5) Const2 = Const2 or (1 shl 2) ENDIF Could you tell me the simplest w...

Do without USES_CONVERSION macro...

I have this code that uses the USE_CONVERSION macro in a C++ project... I was wondering if this is written well, (not written by me), and if there's any better ways to do it, without the USES_CONVERSION and W2A macros. STDMETHODIMP CInterpreter::GetStringVar(BSTR bstrNamespace, BSTR bstrVar, BSTR *pbstrValue) { USES_CONVERSION; try { ...

excel macro = link between 2 documents

Hello, I am working on a table(in document A) which needs to be referred to another document(document B, not sheet 2 of document A). I used macro and VLOOKUP to link the data and it works perfectly well when both documents are opened. However, once i closed document B, the data on the table cannot be shown with a message " subscript out...

How do I identify redefined macros in C?

I have two large framework libraries, whose header files are included in my project. Either one works flawlessly, but including both causes erratic behaviour (but no error message related to the macro). I assume that they both #define a macro of the same name. What is the most efficient way to identify the problematic macro? ...

Copy and Paste every Nth Row - Macro

I need a macro that will copy a column from one worksheet and paste into another spreadsheet on every 5th row. I've tried using snippets of code, but I haven't found one that I can modify to make this work. Driving me crazy. I'm sure this is pretty easy for those who are more advanced with VB code. Anyone willing to help me out would ...

vba: do something if it is midnight

i will need to run a process once every 24 hours at midnight. it wont matter if it's 12:00:00 or 12:00:03, just as long as it is run once at around midnight. would i need to have a timer control checking what time it is every minute or is there a more sophisticated/simpler way of doing this? what would be the if statement to check whet...

How can I get the text to show in a row over 409 pts high?

My task is to get text to print and display though it is longer than the 409 point row show. The sheet I'm working on is a Destination sheet from a Source sheet that can change often, but generally only 1 of 15 cells present this problem. Cell parameters are fixed so I can't change font or column width. On a spreadsheet I've made a Ma...

Macro-like structures in C# ==OR== How to factor out a function containing 'return'

I never thought I'd have a need for anything this (since macros are bad, right?), but it turns out I do. I find myself repeating the following pattern over and over again in my code, dozens if not hundreds of times: object Function() { this.Blah = this.Blah.Resolve(...); if(this.Blah == null) return null; if(this.Bl...

How to write an 'if' condition that compiles only when DEBUG is #defined?

Hi everyone. I need some help in writing a macro for 'if-condition' which compiles only when a DEBUG flag is defined by the #define directive. Here is an example which illustrates what I want. first piece of code shows the usual way of writing an if condition with a #ifdef. #ifdef DEBUG if( rv == false ) { string errorStr = "error...

VS2008 Resize text editor macro

Hi, I'm using Visual Studio 2008 and I split my text editor into two vertical text editors. I thought it would be useful to have a macro that re-size the active text editor to take up most of the screen but I haven't gotten very far. I get an error whenever I try to change the width oh a text editor. DTE.ActiveWindow.Width = 800 And I...

How to make printf() properly print a binary blob from within a macro?

In a project of mine (which for technical reasons must not depend on any external libraries or third-party sources) I have set up the following test.h: static int rc = 0; #define TESTCASE( x ) if ( x ) {} \ else \ { \ rc += 1; \ printf( "FAIL...

Excel Macro to Generate SQL From Sparsely Populated Sheet?

I have a worksheet that has been sparsely populated with data that needs to go into several relational database tables. The sheet looks like this: A B C D E F G Table_1 Table_2 Table_2 Table_3 Table_3 Table_3 Table_3 Table_3 Table_3 Table_3 Table_3 Ta...