macros

How to call an existing LibreOffice python macro from a python script

折月煮酒 提交于 2020-01-17 02:24:33
问题 Currently I call an existing existing LibreOffice macro with this: def OnLOtimestamp(self): try: pid= Popen(['lowriter '"'"'vnd.sun.star.script:fs2TimeStamp.py$fs2_TimeStamp?language=Python&location=user'"'"],shell=True).pid except OSError, e: self.notify_show("Timestamp Error",str(e)) self.ma2.SetLabel("Macro timestamp") self.database['Time_stamp'] = self.database['Time_stamp'] + 1 The key bit being the Popen call, where the macro name is fs2TimeStamp.py and the function is fs2_TimeStamp but

do{}while(0) - macro safety

寵の児 提交于 2020-01-16 14:53:13
问题 We know that multiline macros have to be inclosed in a do while(0) loop for them to be safely included anywhere in the code. For example this is 100% safe: #define swap( a , b ) \ do \ { \ int t = a ; \ a = b ; \ b = t ; \ } \ while(0) I would like to know if it is also safe to have a macro with a part of the code outside of the loop, and if it isn't, in what circumstances could problems occur. #define swap( a , b ) \ int t ; \ //should be in the same scope where the macro was called and

Smooth Mouse Movement using mouse_event with set delay C++

断了今生、忘了曾经 提交于 2020-01-16 12:05:00
问题 I'm coding a mouse macro. It needs to meet certain points on the screen in a set delay between each point. For exammple, it must move (x 14, y 30) in 132ms. The issue I'm having is mouse_event jumps to that exact position so I need to include some sort of smoothing method so that it moves smoothly to each point. (the smoother the movement is the better the macro). Currently I am using this method of smoothing each movement. This works well but it has its limitations for example if it needs to

Create new txt/html file for each row in OOO Calc spreadsheet

谁都会走 提交于 2020-01-16 01:51:05
问题 I would like to create a new txt file (html file really) from each row of a Calc spreadsheet. I have found a few answers that do this from an Excel spreadsheet but they do not work with Calc. I do not have Excel. I am using OOO 4. I tried this Excel macro in Calc but get an error - Range is an unknown data type. Researching this seems to say that Excel macros won't work well in OOO Calc. I had found something saying if I enabled 'Executable Code' in Options, Excel macros may work, but that

c++ loop macros

為{幸葍}努か 提交于 2020-01-16 01:07:35
问题 I use macros to code unrolled loops like this: (silly example) #define foreach_small_prime(p, instr) { \ int p; \ p = 2; instr; \ p = 3; instr; \ p = 5; instr; \ p = 7; instr; \ } foreach_small_prime(pp, cout << pp); int sum = 0; foreach_small_prime(pp, { sum += pp; if (sum >= 10) cout << sum << endl; }); But in some cases I might use for construct: #define foreach_small_even(ii) for(int ii = 0; ii < 20; ii += 2) int sum = 0; foreach_small_even(pp) { sum += pp; if (sum >= 10) cout << sum <<

Type mismatch in scala quasiquote of macro definition: “type mismatch; found : field.NameType required: c.universe.TermName”

烂漫一生 提交于 2020-01-15 12:18:06
问题 I asked a longer question, but it seems it's too much code for people to sort through so I've created this question to focus on one smaller, specific problem I'm facing regarding use of macros in Scala. Consider the following code snippet: val tpe = weakTypeOf[T] val companion = tpe.typeSymbol.companionSymbol val fields = tpe.declarations.collectFirst { case m: MethodSymbol if m.isPrimaryConstructor => m }.get.paramss.head val toMapParams = fields.map { field => val name = field.name val

Using Scala reflection in Scala macros

孤人 提交于 2020-01-15 11:26:12
问题 I'm trying to use Scala macros in order to generate some code, more specifically I would like the macro to generate a function that instantiates an abstract class. For example, if this is the abstract class: abstract class Person { val name: String val age: Int } So the macro will be something like this: def m = macro _m def _m(c: Context): c.Expr[Any] = { import c.universe._ c.Expr(c.parse(""" (_name:String, _age:Int) => new Person{ val name = _name val age = _age } """)) } So far so good,

String comparison in preprocessor conditions in C

梦想与她 提交于 2020-01-15 06:52:21
问题 I am passing a compiler option in makefile called DPATH , which is something like DPATH=/path/to/somefile . Based on this, I have to write a macro such that:- #if "$(DPATH)"=="/path/to/x" #error no x allowed #endif How do I compare DPATH with the string in a preprocessor conditional test? 回答1: It is not possible to do this in the preprocessor. #if can only evaluate integer expressions making no reference to functions or variables. All identifiers that survive macro expansion are replaced by

How can I read in multiple excel files in SPSS using a macro?

会有一股神秘感。 提交于 2020-01-15 05:28:29
问题 I'm trying to write a Macro to import 15 files, all in the same format. The name format is the "monyy PSF Extract". So I can use the code below to read in the 1 file for Nov11. I've tried to find a way of using the macro to read in also the other 14 files. I can't seem to make it work. I'm new to SPSS - I knew how to do this in SAS. I also want to set the dataset created to be named monyy. I will also want to rename some variables as original_name_monyy. Can someone help me on this please?It

How to indent a block of text in an m4 macro

久未见 提交于 2020-01-15 04:56:27
问题 Is there a good way to uniformly indent a block of text in an m4 macro? In other words, the macro define(`mytext',dnl This is a piece of text that I would like to indent) mytext generates This is a piece of text that I would like to indent I'd like to have a way to indent the whole block of text to a specified amount. 回答1: How about patsubst: patsubst(mytext,`^', ` ') 来源: https://stackoverflow.com/questions/29026753/how-to-indent-a-block-of-text-in-an-m4-macro