macros

How to implement a Lisp macro system?

I've implemented my own Lisp on top of node.js, I can run s-expressions like this: (assert (= 3 (+ 1 2))) (def even? (fn [n] (= 0 (bit-and n 1)))) (assert (even? 4)) (assert (= false (even? 5))) Now I would like to add macros - the defmacro function - but this is where I'm stuck. I'm wondering how macro systems are implemented in o...

Over reliance on macros

I feel, every time I read a C or C++ program, that half or more of it is just macros. I understand that macros can be cool but they are hard to track, debug, etc. Not to mention that most programming languages do not even define something like macros (although Perl6 will have something of the sort). I personally always have found a way ...

Move from one cell to another and count the number of rows in between two data

I have got one column with 250 rows. The data fed is 0 and 1 randomly in these rows. I need to find the number of row between any two 1's. I need to write a macro for the same.For ex: if my column is as follow: A1 0 B1 2 A2 0 B2 2 A3 0 A4 1 A5 0 A6 0 A7 1 A8...

Possible to abstract this logic with macro?

Hi all, I have thousands of function wrappers which inside actually perform a similar logic like: // a, b, ... are variable length parameters of different type void API_Wrapper(hHandle, a, b, ..) { if (hHandle) return remote_API(hHandle, a, b, ..); else return API(a, b, ..); } I wanna use a macro to reuse the if-else logic so ...

What is the easiest way to record a list of actions of the browser and replay them over and over?

I want to be able to go a specific webpage like:http://something.com then goto: "javascript:playsong();" then click on a button and after a specific amount of time do it again. If you also know how to make a javascript code be run on a page with a firefox plugiin or something that would help too. THankyou. ...

Exporting Entire Contents of an Access DB to Individual XML Files

I have many tables that I needed to frequently export from an MDB file to XML, and I hated going through the built-in wizard for each and every table multiple times. So, I made a macro and thought I'd post it on here. This is a community wiki post, so please add suggestions and other solutions! This will export each table into its own...

What are the advantages of scheme macros?

Why would anyone prefer Scheme macros over Common Lisp macros (and I genuinely want to know too, I'm not trying to be a troll)? My experience as a Lisp newb is that Common Lisp style macros are much easier to learn than Scheme's macros. I have yet to see any advantages to Scheme's macros, but of course that doesn't mean they don't exis...

What does #pragma comment mean?

#pragma comment(lib, "kernel32") #pragma comment(lib, "user32") ...

MS Word macro to fix closest spelling error

I'm trying to create a fairly simple macro in Word 2010 using Visual Basic. All it needs to do is press Alt+F7 to select the closest spelling error, then press Enter to choose the first spelling suggestion, then press Shift+F5 to return to the previous edit point. I tried this: SendKeys "%{F7}" SendKeys "~" SendKeys "+{F5}" but the co...

Unnamed parameters in C

In C, unlike C++, all parameters to a function definition must be named. Instead of quashing "unused parameter" errors with (void)a, or openly using __attribute__((unused)), I've created the following macro: #define UNUSED2(var, uniq) UNUSED_ ## line ## var __attribute((unused)) // squash unused variable warnings, can it be done withou...

What is it about a single namespace that leads to unhygienic macros? (in LISP)

Some claim that a single namespace in LISP leads to unhygienic macros. http://community.schemewiki.org/?hygiene-versus-gensym http://www.nhplace.com/kent/Papers/Technical-Issues.html What precisely is it about having single, dual or multiple namespaces that leads to macro hygiene? ...

Copy Table macro for Microsoft word 2007

Hi I have a simple requirement in MS Office word 2007 document. I needed code behind the macro which copies a Table (formatted one) and paste it everytime when I run this macro. The scenario is as follows:- 1. I will copy a formatted table (with 7-8 rows and 5-6 columns, etc) and store it in a macro as button or shortcut key. 1.Whenev...

how to read outlook 2007 signature

I have written a macro to auto generate mails from the users. I just want to know how i can get the signature of the current user for the same, Thanks in advance ...

Macros as default param for function argument

Hello, I'm writing logger file. I'd prefer to use macros _FUNCTION_ there. I don't like the way like: Logger.write("Message", __FUNCTION__); Maybe, it's possible to make something like: void write(const string &message, string functionName = __FUNCTION__) { // ... } If not, are there any ways to do that stuff not by hands (I mea...

Nested imports in Ant

Let's say I have a.xml which imports b.xml and b.xml imports c.xml. If I define a macro in c.xml called macro-from-c, will it be visible to a.xml? I'm asking this in the context of IntelliJ, which doesn't seem to want to acknowledge the macros I've defined. Thanks ...

Converting C Macros to Actionscript 3

I am trying to convert a macro in C to something that would work similarly in Actionscript. The C macro takes a string, and using ## checks the type against other macros to check that the item's property is of the right type. To clarify, the C: ... #define STACK_NUM 52 ... #define CHECK_TYPE(i, t) \ ( ((i).type == t##_NUM) ) ...

VBA code to get hidden fields

Hi All, Can anyone help me write a macro code which gets hidden field values from a word 2007 file ? Thanks , Francis P. ...

Excel macro - Iteratively copy rows from one sheet to another

There are 3 sheets in a workbook: Sheet1, Sheet2, Sheet3. Sheet1 has the following data: aaa 3 aaa 2 aaa 45 aaa 211 aaa 12 bbbb 3 bbbb 2 bbbb 4 ccc 2 ccc 5 dddd 2 dddd 10 dddd 25 There will be a hash table like this: key values GroupA aaa, bbbb GroupB ccc, dddd How can I load data t...

Emulating 'return' in macro

Is there any standard compliant way to emulate 'return' with macro? Currently, I'm trying to wrapping _alloca function to emulate variable length array on stack (which is supported in C99) with macro in C++. Since the _alloca function manipulates stack pointer, I think inline function isn't suitable solution for this time. Below is the...

What's the point of this kind of macros?

#define NAME(x) TEXT(x) #define TEXT(quote) __TEXT(quote) // r_winnt #define __TEXT(quote) quote // r_winnt The above is from winNT.h, isn't NAME("Virtual Cam") the same as "Virtual Cam",what's the point to use this macro? ...