macro
In software development, a macro is a sequence of instructions or declarations grouped under a specific designation ( macro name) in order to be able to execute these (instead of individual instructions, usually at several points in the program) with just one simple call. All instructions of the macro are automatically executed at the point in the program at which the macro was coded.
Macros are a variant of subroutines and can (depending on the implementation ) also be called with parameters . A distinction is made between system macros (such as OPEN for opening files and PRINT for printing) and macros created by users - for example, to carry out checking or calculation functions such as the validity check for the international bank account number (IBAN).
Macros are e.g. It is used, for example, in spreadsheets, word processing and databases. Working with these programs is made easier and faster because a sequence of commands that is frequently used can be called with the help of a macro. Depending on the software type, macros can also be called up using a key key or with the help of a menu name.
Usually programs are coded in one of the programming languages (e.g. assembler , BASIC , Pascal ). It is also possible to use your own programming language within a software (e.g. Microsoft Office ). The programming language can be used in relation to software (e.g. programming in Microsoft Excel with VBA ) or for programming in general (e.g. solving a mathematical problem).
etymology
The word macro is borrowed from the synonym English. macro , an abbreviation of macroinstruction , literally something like "large command" ( Greek , macros means "large" or "wide").
Macros in programming
A macro in programming is a small piece of program code that is replaced by a larger piece of program code by an interpreter or preprocessor . This makes it possible to simplify frequently recurring program structures with abbreviations or to replace literal constants with semantic names.
- Programs that replace strings with other strings are called macroprocessors . The definition of a character string to be replaced is called a macro. Well-known macro processors are the C or C ++ preprocessor , the Unix program m4 and the typesetting programs troff and TeX . In Macro Assembler such a macro processor is used to define recurring structures easier.
- In programming languages such as Lisp , macros are metaprograms that are first converted into executable program code during translation . Macros are used there to map recurring program structures: Every developer can implement new control structures , design patterns , OOP systems, etc. directly in the language if necessary ( syntax abstraction ). In programming languages without macros, this would require changes to the language definition.
Macros in application programs
Here it is not the programmers but the software users who can efficiently combine certain work steps using macros.
- In Windows , automation of the user interface is called a “macro”. Many application programs (for example those of the Microsoft Office group such as Word, Excel, PowerPoint or Outlook) allow the recording of typical command sequences and operating steps as macros (see macro recorder ). Most Microsoft application programs use the Visual Basic for Applications (VBA) programming language as the recording language . In the application programs of the Microsoft Office group, the recorded VBA macro code can be viewed and further processed in a VBA development environment integrated in the application itself using the Visual Basic Editor. The VBA macro code in Microsoft Office applications is very similar to the Visual Basic programming language. VBA is particularly characterized by the possibility of direct access to the application-specific objects. Microsoft Excel allows recorded VBA code to be packaged and passed on as an add-in. According to the definition mentioned above (replacement of little text with a lot of text), VBA macros are actually not macros, but independent small programs that require the VBA interpreter as a runtime environment .
- In Microsoft Access , a special type of programming in tabular form is referred to as a “macro”, although these macros can also be combined with VBA.
- In some CAD programs, prefabricated parts that can be loaded from a library are called macros. An architect does not have to redraw every wash basin, an electrical planner can fall back on ready-made switches and sockets. This meaning of macro for a block is in contrast to the other meanings according to which a macro is generally something executable.
See also
literature
- M. Campbell-Kelly: An Introduction to Macros . Macdonald & Co. (Publishers) Ltd., London, 1973, ISBN 0-356-04388-6 .
- AJ Cole: Macro Processors . Cambridge University Press, London, 1981, ISBN 0-521-24259-2 .
Web links
Individual evidence
- ↑ Duden Sachlexikon Informatik, 'Makrobefehl', ISBN 3-411-05232-5 .