macros

Running Libreoffice BASIC macro from python

半腔热情 提交于 2021-01-29 00:17:41
问题 I've a macro in LibreOffice BASIC and I want to run it from my python program. I've found some threads in which they use this code: import os import win32com.client if os.path.exists("excelsheet.xlsm"): xl=win32com.client.Dispatch("Excel.Application") xl.Workbooks.Open(Filename="C:\Full Location\To\excelsheet.xlsm", ReadOnly=1) xl.Application.Run("excelsheet.xlsm!modulename.macroname") ## xl.Application.Save() # if you want to save then uncomment this line and change delete the ", ReadOnly=1"

Running Libreoffice BASIC macro from python

匆匆过客 提交于 2021-01-29 00:13:42
问题 I've a macro in LibreOffice BASIC and I want to run it from my python program. I've found some threads in which they use this code: import os import win32com.client if os.path.exists("excelsheet.xlsm"): xl=win32com.client.Dispatch("Excel.Application") xl.Workbooks.Open(Filename="C:\Full Location\To\excelsheet.xlsm", ReadOnly=1) xl.Application.Run("excelsheet.xlsm!modulename.macroname") ## xl.Application.Save() # if you want to save then uncomment this line and change delete the ", ReadOnly=1"

How to do define-for-syntax in typed racket?

混江龙づ霸主 提交于 2021-01-28 19:37:58
问题 This works #lang racket (begin-for-syntax (define (foo n) (+ n 3))) So I would also expect this to work #lang typed/racket (: foo : Real -> Real) (define-for-syntax (foo n) (+ n 3)) But if fails with ; :: undefined; ; cannot reference an identifier before its definition After that I tried each of the following in turn in typed/racket (define-for-syntax (foo (n : Real)) : Real (+ n 3)) (begin-for-syntax (: foo (-> Real Real)) (define (foo n) (+ n 3))) (begin-for-syntax (define (foo (n : Real))

generate a name for macro with another macro (c preprocessor) [duplicate]

只谈情不闲聊 提交于 2021-01-28 12:31:56
问题 This question already has answers here : Macro-producing macros in C? (6 answers) Closed 5 years ago . I can generate name for a function using an macro which is taken from C pre-processor defining for generated function names . #define POSTFIX _ABC //_ABC should be mentioned only there #define PROTOTYPENAME(symbol) symbol ## POSTFIX #define PROTOTYPENAMED(sym) PROTOTYPENAME(sym) int PROTOTYPENAMED(Function)(int a, int b, int c); Above would result as int Function_ABC(int a, int b, int c); If

generate a name for macro with another macro (c preprocessor) [duplicate]

馋奶兔 提交于 2021-01-28 12:18:54
问题 This question already has answers here : Macro-producing macros in C? (6 answers) Closed 5 years ago . I can generate name for a function using an macro which is taken from C pre-processor defining for generated function names . #define POSTFIX _ABC //_ABC should be mentioned only there #define PROTOTYPENAME(symbol) symbol ## POSTFIX #define PROTOTYPENAMED(sym) PROTOTYPENAME(sym) int PROTOTYPENAMED(Function)(int a, int b, int c); Above would result as int Function_ABC(int a, int b, int c); If

Can I make expressions constexpr?

牧云@^-^@ 提交于 2021-01-28 11:16:46
问题 I recently wrote some code which prints a function result to cout . The result could have been evaluated at compile time, but it wasn't: #include <algorithm> #include <iostream> constexpr unsigned int gcd(unsigned int u, unsigned int v) { // ... } int main() { std::cout << gcd(5, 3) << std::endl; } For whatever bizarre reason, this compiles to: ( clang -O3 -std=c++17 ) main: push r14 push rbx push rax mov edi, 5 mov esi, 3 call gcd(unsigned int, unsigned int) mov esi, eax ... See Compiler

Generate TYPECASE with macro in Common Lisp

家住魔仙堡 提交于 2021-01-28 10:51:58
问题 I have a list of two element sublists which will change and grow in the course of the program. I want to write a macro which takes a key and generates a case dynamically like: ;; This is the List for saving CASE clauses (setf l '((number 2) (symbol 3))) ;; and i want to have the following expansion (typecase 'y (number 2) (symbol 3)) I could have a macro which only refers to the global l : (defmacro m (x) `(typecase ,x ,@l)) which would expand correctly (m 'y) ;expands to (TYPECASE 'Y (number

Declare a variable and add it to an array at compile time

别说谁变了你拦得住时间么 提交于 2021-01-28 03:21:31
问题 I'd like to get a C macro (or several) that could serve two purposes: Declare a const variable. Add that variable to an array. I.e , if I have this typedef struct { int port; int pin; } pin_t; A macro like this #define DEFINE_PIN(name, port, num) should expand to something like this #define NAME port, num const pin_t[] = { {NAME} }; And each definition should append the new defined variable to the array. I know that a #define cannot expand to #define s but is just an illustration. What I want

How do I concatenate two string macros in C?

不打扰是莪最后的温柔 提交于 2021-01-28 01:06:47
问题 I am trying to implement VERSION macro for my program, that is to be changed under certain circumstances. macro VERSION is defined via Makefile (git info is put there) and is a string. Now I have a set of #define'd switches and I want VERSION to reflect which of them are on. This looks now like the follows (main.h): #define COMPLEX_DEPOSITION // This is switch. later in code it is used in #ifdef...#endif construction. #ifdef COMPLEX_DEPOSITION #define CD "_COMP_DEP" // this is the string I

Common Lisp macro let-curry - not working

谁说我不能喝 提交于 2021-01-27 18:35:33
问题 I found myself calling lots of methods whose first argument is a complex object from a given class. Whilst with-slots and with-accessors are useful, generic methods cannot be bound in this way. So I thought: if we could locally curry any functions, slots + accessors + generic functions + functions could all be addressed with the same construct. Example of code I want to clean up: (defun clox-string (scanner) "Parse string into a token and add it to tokens" (loop while (and (char/= #\" (peek