is there a way to write macros with a variable argument list in visual C++?
As far as I know, in gcc you can write something like: #define DBGPRINT(fmt...) printf(fmt); Is there a way to do that in VC++? ...
As far as I know, in gcc you can write something like: #define DBGPRINT(fmt...) printf(fmt); Is there a way to do that in VC++? ...
The $args variable should, by definition, contain all arguments passed to a script function. However if I construct a pipeline inside my function, the $args variable evaluates to null. Anyone knows why? See this example: function test { 1..3 | % { echo "args inside pipeline: $args" } ; echo "args outside pipeline: $args" } This is th...
I get the feeling this is probably something I should know but I can't think of it right now. I'm trying to get a function to build a list where the name of the list is an argument given in the function; e.g. def make_hand(deck, handname): handname = [] for c in range(5): handname.append(deck.pop()) return handname ...
In order to extend my "grep" emulator in Perl I have added support for a -r switch which enables recursive searching in sub-directories. Now the command line invocation looks something like this: perl pgrep.pl -r <directory> <expression> Both -r and the directory arguments are optional (directory defaults to '.'). As of now I simply c...
On a regular basis, I validate my function arguments: public static void Function(int i, string s) { Debug.Assert(i > 0); Debug.Assert(s != null); Debug.Assert(s.length > 0); } Of course the checks are "valid" in the context of the function. Is this common industry practice? What is common practice concerning function argumen...
So basically I am trying to check the arguments that are passed into the script. If it has three arguments and the third argument is a 1, then I want it to continue. I also want it to continue if it has four arguments and the third argument is not a 1. So basically I thought that I could just do... if ([ $# -ne 3 ] and [ "$3" -ne "2"...
I'd like to wrap a MyBatScript.bat script inside a MyTest.exe. Then I'd like to invoke MyTest.exe with arguments, thus: MyTest.exe arg1 arg2 format of passing arguments can be different if need be. I'd like arg1 and arg2 to be passed on to MyBatScript.bat as %1 and %2 and MyBatScript.bat executed. How Can I do this? Thanks! ...
I am using gdb to debug a program, and I want to have the output of the command $(perl -e 'print "A"x20') as my argument. How can I do that? This way the argument would be very flexible. ...
Hi all, I'd like to be able to declare an array as a function argument in C++, as shown in the example code below (which doesn't compile). Is there any way to do this (other than declaring the array separately beforehand)? #include <stdio.h> static void PrintArray(int arrayLen, const int * array) { for (int i=0; i<arrayLen; i++) p...
I am working with VMD (a molecular dynamics visualization package) and I want to open VMD from a Perl script, run a Tcl script, print the output to a log file, then close VMD and return to the Perl script. The ordinary syntax to do this is: system("vmd -dispdev text -eofexit < program.tcl > LOG"); which breaks down as follows, as best...
This somewhat parallels a semi-frequent discussion on /.. What languages are recommended for someone to learn, based on their concepts, to become a programmer; for instance, many on /. note how object oriented programming seems to them to have 'corrupted' the minds of programmers, and that yes it's a great tool, but only if used appropri...
I get this error when I use this code for people to input data. The submit form won't be listed cause it's not useful in this circumstance: function some_more_custom_content() { $output="<BR>"; ob_start(); if ($_REQUEST['code'] != "") { $code = $_REQUEST['code']; $query="INSERT INTO `fc` (`code`,`datetime`) values ('" . mysq...
Hi, I can find many examples on how to get arguments in a console application, but I can't seem to find an example of how to get arguments in a windows form application. I would like to following things. whenever I open a jpg file, windows launches my application. I would like to know path and name of the jpg file from my application...
I hit a snag today... I wanted to define a small templated helper class: template<class T> CMyClass { public : CMyClass() { size_t iSize = sizeof(T); } // Allowed. size_t GetElementSize() const { return sizeof(T); } // C2027. }; and of course, it wouldn't compile (C2027). My question was, is it possible to get the size of t...
I have a function whose input argument can either be an element or a list of elements. If this argument is a single element then I put it in a list so I can iterate over the input in a consistent manner. Currently I have this: def my_func(input): if not isinstance(input, list): input = [input] for e in input: ... I a...
How can I, in Windows, use the output of a script/command as an argument for another script? (A pipe | will not work here, since that other script doesn't read from the standard input) Too clarify: I have AnotherScript that needs an argument arg, e.g.: AnotherScript 12 now I want the argument (12 in the example) to come from the outp...
Yeah, read properly. In the last time I saw different patterns of argument validation in JavaScript (functions) and wondered which of them would be best-practice. At first I'll show two example code snippets. The first shows an (in my words) "immediate" argument/condition validation and the second one a "delayed" validation. Each of them...
1 import sys 2 3 class dummy(object): 4 def __init__(self, val): 5 self.val = val 6 7 class myobj(object): 8 def __init__(self, resources): 9 self._resources = resources 10 11 class ext(myobj): 12 def __init__(self, resources=[]): 13 #myobj.__init__(self, resources) 14 ...
Say I'm writing a script and I want to require a --host switch (with value of course) but if the --host switch isn't specified I want the option parsing to fail. I can't seem to figure out how to do that. The docs seem to only specify how to make the argument value mandatory, not the switch itself. ...
I'm trying to pass a string argument to a target function in a process. Somehow, the string is interpreted as a list of as many arguments as there are characters. This is the code: import multiprocessing def write(s): print s write('hello') p = multiprocessing.Process(target=write, args=('hello')) p.start() I get this output:...