Search Results

Search found 3836 results on 154 pages for 'argument'.

Page 9/154 | < Previous Page | 5 6 7 8 9 10 11 12 13 14 15 16  | Next Page >

  • Python ctypes argument errors

    - by Patrick Moriarty
    Hello. I wrote a test dll in C++ to make sure things work before I start using a more important dll that I need. Basically it takes two doubles and adds them, then returns the result. I've been playing around and with other test functions I've gotten returns to work, I just can't pass an argument due to errors. My code is: import ctypes import string nDLL = ctypes.WinDLL('test.dll') func = nDLL['haloshg_add'] func.restype = ctypes.c_double func.argtypes = (ctypes.c_double,ctypes.c_double) print(func(5.0,5.0)) It returns the error for the line that called "func": ValueError: Procedure probably called with too many arguments (8 bytes in excess) What am I doing wrong? Thanks.

    Read the article

  • "Invalid Procedure Call or Argument", but only in a compiled or P-Code EXE

    - by Rob Perkins
    I have a VB6 program which I've been maintaining for ten years. There is a subroutine in the program called "Prepare Copy", which looks like this: Public Sub PrepareCopy() Set CopiedShapes = New Collection End Sub Where CopiedShapes is dimmed out as a VB6 Collection. That code is now kicking out a Runtime Error 5 -- Invalid Procedure Call or Argument. It appears from the interstitial debugging code that the error arises between the Public Sub PrepareCopy() and the Set CopiedShapes = New Collection lines. That's right. The VB6 error is happening between two lines of my code. I can think of no other explanation for this. It's behaving this way on my development machine and two client computers. It is only happening in runtime code, and does not appear to make a difference whether I compile it or use P-Code What I'm asking for here is speculation as to what causes this sort of thing to happen.

    Read the article

  • Run batch file when argument contains quotes and spaces (from .NET framework)

    - by turtle
    I have a bat file which sets some environment variables, and then executes a command on the command line. I want to replace the hard coded command with one passed in via a parameter. So: :: Set up the required environment SET some_var=a SET another_var=b CALL some.bat :: Now call the command passed into this batch file %1 The problem is that the command is complex, and doesn't escape cleanly. It looks like this: an.exe -p="path with spaces" -t="some text" -f="another path with spaces" I'm trying to call the .bat from a .NET framework app, using: Dim cmd as String = "the cmd" System.Diagnostics.Process.Start( thebat.exe, cmd ) but I can't seem to get the escapes to work correctly. Can someone tell me how the string cmd should be entetered to get the command passed into the bat file as an argument correctly?

    Read the article

  • How to deal with constructor argument names?

    - by Bane
    Say I have a class that has some properties, like x, y, width and height. In its constructor, I couldn't do this: class A { public: A(int, int, int, int); int x; int y; int width; int height; }; //Wrong and makes little sense name-wise: A::A(int x, int y, int width, int height) { x = x; y = y; width = width; height = height; } First of all, this doesn't really make sense. Second, x, y, width and height become some weird values (-1405737648) when compiled using g++. It does work, however, if I append "a" to the argument names. What is the optimal way of solving these naming conflicts?

    Read the article

  • Why should pop() take an argument?

    - by Stephano
    Quick background I'm a Java developer who's been playing around with C++ in my free/bored time. Preface In C++, you often see pop taking an argument by reference: void pop(Item& removed); I understand that it is nice to "fill in" the parameter with what you removed. That totally makes sense to me. This way, the person who asked to remove the top item can have a look at what was removed. However, if I were to do this in Java, I'd do something like this: Item pop() throws StackException; This way, after the pop we return either: NULL as a result, an Item, or an exception would be thrown. My C++ text book shows me the example above, but I see plenty of stack implimentations taking no arguments (stl stack for example). The Qustion How should one implement the pop function in C++? The Bonus Why?

    Read the article

  • Strange Template error : error C2783: could not deduce template argument

    - by osum
    Hi, I have created a simple function with 2 diffrernt template arguments t1, t2 and return type t3. So far no compilation error. But when Itry to call the function from main, I encounter error C2783. I needed to know If the following code is legally ok? If not how is it fixed? please help! template <typename t1, typename t2, typename t3> t3 adder1 (t1 a , t2 b) { return int(a + b); }; int main() { int sum = adder1(1,6.0); // error C2783 could not deduce template argument for t3 return 0; }

    Read the article

  • i don't know how to work with command argument in asp.net

    - by Depozitul de Chestii
    hey, i'm tryng to pass a parameter with command argument with a link button but the result i get is always "". this is in my aspx page: <% LinkButton1.CommandArgument = "abcdef"; %> <asp:LinkButton ID="LinkButton1" runat="server" OnCommand= "LinkButton1_Click"> and in my aspx.cs i have: protected void LinkButton1_Click(object sender,CommandEventArgs ee) { String id = ee.CommandName.ToString(); } the id is always "" after i press the linkbutton. would appreciate if someone could help me. thanks

    Read the article

  • Removing final bash script argument

    - by ctuffli
    I'm trying to write a script that searches a directory for files and greps for a pattern. Something similar to the below except the find expression is much more complicated (excludes particular directories and files). #!/bin/bash if [ -d "${!#}" ] then path=${!#} else path="." fi find $path -print0 | xargs -0 grep "$@" Obviously, the above doesn't work because "$@" still contains the path. I've tried variants of building up an argument list by iterating over all the arguments to exclude path such as args=${@%$path} find $path -print0 | xargs -0 grep "$path" or whitespace="[[:space:]]" args="" for i in "${@%$path}" do # handle the NULL case if [ ! "$i" ] then continue # quote any arguments containing white-space elif [[ $i =~ $whitespace ]] then args="$args \"$i\"" else args="$args $i" fi done find $path -print0 | xargs -0 grep --color "$args" but these fail with quoted input. For example, # ./find.sh -i "some quoted string" grep: quoted: No such file or directory grep: string: No such file or directory Note that if $@ doesn't contain the path, the first script does do what I want.

    Read the article

  • c, pass awk syntax as argument to execl

    - by Skuja
    I want to run following command in c to read systems cpu and memory usage: ps aux|awk 'NR > 0 { cpu +=$3; ram+=$4 }; END {print cpu,ram}' I am trying to pass it to execl command and after that read its output: execl("/bin/ps", "/bin/ps", "aux|awk", "'NR > 0 { cpu +=$3; ram+=$4 }; END {print cpu,ram}'",(char *) 0); but in terminal i am getting following error: ERROR: Unsupported option (BSD syntax) I would like to know how to properly pass awk as argument to execl?

    Read the article

  • How to define a function which repeats itself when passed an argument

    - by ~unutbu
    Is there an easy way to define a function which repeats itself when passed an argument? For example, I've defined the following function (defun swap-sign () (interactive) (search-forward-regexp "[+-]") (if (equal (match-string 0) "-") (replace-match "+") (replace-match "-")) ) I'd like C-u swap-sign to call swap-sign four times. I've tried (defun swap-sign (&optional num) (interactive) (let ((counter 0) (num (if num (string-to-number num) 0))) (while (<= counter num) (search-forward-regexp "[+-]") (if (equal (match-string 0) "-") (replace-match "+") (replace-match "-")) (setq counter (1+ counter))))) but C-u swap-sign still only runs swap-sign (or perhaps more precisely, the body of the while-loop) once. I'm guessing it is because if num is not the right way to test if num is an empty string. Am I on the right track, or is there a better/easier way to extend swap-sign?

    Read the article

  • Accessing 'data' argument of with() function?

    - by Ken Williams
    Is it possible, in the expr expression of the with() function, to access the data argument directly? Here's what I mean conceptually: > print(df) result qid f1 f2 f3 -1 1 0.0000 0.1253 0.0000 -1 1 0.0098 0.0000 0.0000 1 1 0.0000 0.0000 0.1941 -1 2 0.0000 0.2863 0.0948 1 2 0.0000 0.0000 0.0000 1 2 0.0000 0.7282 0.9087 > with(df, subset(.data, select=f1:f3)) # Doesn't work Of course the above example is kind of silly, but it would be handy for things like this: with(subset(df, f2>0), foo(qid, vars=subset(.data, select=f1:f3))) I tried to poke around with environment() and parent.frame() etc., but didn't come up with anything that worked. Maybe this is really a question about eval(), since that's how with.default() is implemented.

    Read the article

  • fetchedResultsController objectAtIndexPath: i "Passing argument 1 of objectAtIndexPath: makes pointer from integer without cast

    - by cocos2dbeginner
    NSMutableDictionary* dict = [[NSMutableDictionary alloc] init]; id <NSFetchedResultsSectionInfo> sectionInfo = [[self.fetchedResultsController sections] objectAtIndex:0]; for (int i; i<[sectionInfo numberOfObjects]; i++) { NSManagedObject *o = [self.fetchedResultsController objectAtIndexPath:i]; [dict setObject:[[o valueForKey:@"frontCard"] description] forKey:@"frontCard"]; [dict setObject:[[o valueForKey:@"flipCard"] description] forKey:@"flipCard"]; } In this line NSManagedObject *o = [self.fetchedResultsController objectAtIndexPath:i]; i get this warning: warning: passing argument 1 of 'objectAtIndexPath:' makes pointer from integer without a cast

    Read the article

  • What causes VB6 "Run-Time Error '5': Invalid Procedure Call or Argument"

    - by cundh2o
    In VB6, users occasionally receive this error and I am unable to reproduce it. Run-Time Error '5': Invalid Procedure Call or Argument I am referencing the "MSWord 10 Object Library" and sometimes this error occurs at some point after the application has opened MSWord 2002. However, this app has referenced the MSWord 10 Object Library for years, and this error just started occurring in the last few months. I am assuming I have introduced a bug somewhere, but no idea what might be causing it. The error does not occur very often and cannot be reproduced by a user when I am standing there. The error forces the app to totally shut down. Users are running Windows XP

    Read the article

  • How to use a Visual C++ .Net String type as argument in a function

    - by stefangachter
    Probably this is not a difficult question, but I am always a little bit confused on how to treat String type as an argument in Visual C++. I have the following to functions: void function_1(String ^str_1) { str_1 = gcnew String("Test"); } void function_2() { String ^str_2 = nullptr; function_1(str_2); } After calling function_1, str_2 is still equal to null, but what I want to achieve is that str_2 is equal to Test. So, how can I achieve that the content of str_1 is passed to function_2? Thanks for any advice.

    Read the article

  • Create unique file name and fetching it to commandline argument

    - by user343934
    Hi everyone, I am working on python right now and i am little bit stuck in performing some tricks. I have web form with two options- File upload and textarea, i can easily pass file name with file upload options but have problem when it's textarea. Because when i use textarea then first i have to save values passed from textarea to some files and save it on the working directory. After that i can execute commandline argument and pass same saved filename name. For this problem i have to generate unique file first and save the values passed from textarea in it. Can anybody give me some tips to solve my problem. Any algorithms, suggestions and lines of code are appreciated. Thanks for your concern

    Read the article

  • std::make_shared as a default argument does not compile

    - by Mark Bryant
    In Visual C++ (2008 and 2010), the following code does not compile with the following error: #include <memory> void Foo( std::shared_ptr< int > test = ::std::make_shared< int >( 5 ) ) { } class P { void Foo( std::shared_ptr< int > test = ::std::make_shared< int >( 5 ) ) { } }; error C2039: 'make_shared' : is not a member of '`global namespace'' error C3861: 'make_shared': identifier not found It is complaining about the definition of P::Foo() not ::Foo(). Does anybody know why it is valid for Foo() to have a default argument with std::make_shared but not P::Foo()?

    Read the article

  • find: missing argument to -exec

    - by Abs
    Hello all, I was helped out today with a command, but it doesn't seem to be working. This is the command: find /home/me/download/ -type f -name "*.rm" -exec ffmpeg -i {} -sameq {}.mp3 && rm {}\; The shell returns find: missing argument to `-exec' What I am basically trying to do is go through a directory recursively (if it has other directories) and run the ffmpeg command on the .rm file types and convert them to .mp3 file types. Once this is done, remove the .rm file that has just been converted. I appreciate any help on this.

    Read the article

  • Problems with first argument being string when overloading the + operator in C++

    - by Chris_45
    I have an selfmade Stringclass: //String.h String & operator = (const String &); String & operator = (char*); const String operator+ (String& s); const String operator+ (char* sA); . . //in main: String s1("hi"); String s2("hello"); str2 = str1 + "ok";//this is ok to do str2 = "ok" + str1;//but not this way //Shouldn't it automatically detect that one argument is a string and in both cases?

    Read the article

  • unit testing methods with arrays as argument

    - by Ryan
    I am porting over some C++ assembly to VB that performs demodulation of various waveforms. I decided to go the unit test route instead of building a test app to get a feel for how testing is performed. The original demodulation code accepts an array that is the waveform along with some other arguments. How should one go about performing a test on something that has an array as an argument? Is it acceptable to generate fake data in a file and read it in at the beginning of the test? On a side note - The original C++ code was written because we were performing math that we couldn't do in VB6 so we had to cross boundaries between C++ and VB6 and arrays were used. Is there a "better" way of handling large amounts of data in the .NET world that us VB6 programmers may not yet be privy to? Or if we aren't crossing that managed/un-managed boundary, should we be representing our data as objects instead? Thanks all!

    Read the article

  • Misunderstanding function pointer - passing it as an argument

    - by Stef
    I want to pass a member function of class A to class B via a function pointer as argument. Please advise whether this road is leading somewhere and help me fill the pothole. #include <iostream> using namespace std; class A{ public: int dosomeA(int x){ cout<< "doing some A to "<<x <<endl; return(0); } }; class B{ public: B(int (*ptr)(int)){ptr(0);}; }; int main() { A a; int (*APtr)(int)=&A::dosomeA; B b(APtr); return 0; } This brilliant piece of code leaves me with the compiler error: cannot convert int (A::*)(int)' toint (*)(int)' in initialization Firstly I want it to compile. Secondly I don't want dosomeA to be STATIC.

    Read the article

  • foreach invalid argument supplied and mysql fetch array issue

    - by La Myse
    i have this code which i use to print some fields from the database. My problem is that i get this error about foreach invalid argument supplied and a mysql fetch array problem. The code is this: foreach( $checked1 as $key => $value){ echo "<th> $value </th>"; } echo "</tr></thead>"; while($row = mysql_fetch_array($result)){ Where $checked1 is an array $checked1 = $_POST['checkbox']; What's the problem here? Thanks..

    Read the article

  • mysql_close(): supplied argument is not a valid MySQL-Link resource

    - by maxedison
    I'm trying to get the hang of using custom session handlers to store session data in a MySQL database. However, I keep getting the following warning: mysql_close(): supplied argument is not a valid MySQL-Link resource Here's the code I'm using, which I got from here: function _open(){ global $_sess_db; $_sess_db = mysql_connect("localhost", "root", "******"); if ($_sess_db) { return mysql_select_db('style', $_sess_db); } return false; } function _close(){ global $_sess_db; return mysql_close($_sess_db); //error happens here } The full text of the error message ultimately points to the final "return mysql_close($_sess_db);" line. I can confirm that the mysql_connect info does in fact work, and I do have the rest of the session handler functions defined as well. And in case it helps, I get these errors immediately upon page load, without actually calling any of the session handler functions, and without having any current sessions open.

    Read the article

  • Why my shell program wont open the file got as argument in function "cat"

    - by anna karenina
    I included the code below, sorry to bother you with so much code. Argument parsing is ok, i checked it out with watches. I've put some printfs to check out where the problem may be and it seems that it wont open the file cat receives as argument. i called from shell like "cat -b file" #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <string.h> #define TRUE 0 #define FALSE 1 void yes(int argc, char *argv[]); int cat(int argc, char *argv[]); //#include "cat.h" //#include "yes.h" //#include"tee.h" char buf[50],c[10], *p2,*p, *pch; int count; char *matrix[20]; void yes(int argc, char *argv[]) { int i; // if (argc >= 2 && *argv[1] == '-') // { //printf("ERROR!"); //} //if (argc == 1) // { while (1) if (puts("y") == EOF) { perror("yes"); exit(FALSE); } // } while (1) for (i = 1; i < argc; i++) if (fputs(argv[i], stdout) == EOF || putchar(i == argc - 1 ? '\n' : ' ') == EOF) { perror("yes"); exit(FALSE); } //exit(TRUE); } int main(int argc, char *argv[]) { //p=(char *)malloc(sizeof(char)*50); do { fprintf (stderr, "$ "); fgets (buf,50,stdin); p=buf; fprintf (stderr, "Comanda primita de la tastatura: "); fputs (buf, stderr); int i=0,j=0; //strcpy(p,buf); strcpy(c,"\0"); while (buf[i] == ' ') { i++; p++; } if (buf[i] == '#') fprintf (stderr, "Nici o comanda, ci e un comentariu!\n"); else { j=0; while (buf[i] != ' ' && buf[i] != '\n') { i++; j++; } strncpy (c,p,j); fprintf (stderr, "%s\n",c); if (strcmp (c,"yes") == 0) { p2 = p+j+1; pch = strtok (p2," "); count = 0; while (pch != NULL) { //printf ("%s\n",pch); matrix[count] = strdup(pch); pch = strtok (NULL, " "); count++; } yes(count, matrix); fprintf (stderr, "Aici se va executa comanda yes\n"); } else if (strcmp (c,"cat") == 0) { p2 = p+j+1; pch = strtok (p2," "); count = 0; while (pch != NULL) { //printf ("%s\n",pch); matrix[count] = strdup(pch); pch = strtok (NULL, " "); count++; } cat(count,matrix); fprintf (stderr, "Aici se va executa comanda cat \n"); } else if (strcmp (c,"tee") == 0) { //tee(); fprintf(stderr, "Aici se va executa comanda tee\n"); } fprintf (stderr, "Aici se va executa comanda basename\n"); strcpy(buf,"\0"); } } while (strcmp(c, "exit") != 0); fprintf (stderr, "Terminat corect!\n"); return 0; } int cat(int argc, char *argv[]) { int c ; opterr = 0 ; optind = 0 ; char number = 0; char squeeze = 0; char marker = 0; fprintf(stderr,"SALUT< SUNT IN FUNCTIZE>\n"); while ((c = getopt (argc, argv, "bnsE")) != -1) switch (c) { case 'b' : number = 1; break; case 'n' : number = 2; break; case 'm' : marker = 1; break; case 's' : squeeze = 1; break; case 'E' : marker = 1; break; } if (optind + 1 != argc) { fprintf (stderr, "\tWrong arguments!\n") ; return -1 ; } FILE * fd = fopen (argv[optind], "r"); printf("am deschis fisierul %s ",argv[optind]); if (fd == NULL) { printf("FISIER NULL asdasdasdasdasd"); return 1; } char line[1025]; int line_count = 1; while (!feof(fd)) { fgets(line, 1025, fd); printf("sunt in while :> %s",line); int len = strlen(line); if (line[len - 1] == '\n') { if(len - 2 >= 0) { if(line[len - 2] == '\r') { line[len - 2] = '\0'; len -= 2; } else { line[len - 1] = '\0'; len -= 1; } } else { line[len - 1] = '\0'; len -= 1; } } if (squeeze == 1 && len == 0) continue; if (number == 1) { fprintf (stdout, "%4d ", line_count); line_count++; } else if (number == 2) { if (len > 0) { fprintf (stdout, "%4d ", line_count); line_count++; } else fprintf (stdout, " "); } fprintf(stdout, "%s", line); if (marker == 1) fprintf(stdout, "$"); fprintf(stdout, "\n"); } fclose (fd); return 0 ; }

    Read the article

  • Python: some newbie questions on sys.stderr and using function as argument

    - by Cawas
    I'm just starting on Python and maybe I'm worrying too much too soon, but anyways... log = "/tmp/trefnoc.log" def logThis (text, display=""): msg = str(now.strftime("%Y-%m-%d %H:%M")) + " TREfNOC: " + text if display != None: print msg + display logfile = open(log, "a") logfile.write(msg + "\n") logfile.close() return msg def logThisAndExit (text, display=""): msg = logThis(text, display=None) sys.exit(msg + display) That is working, but I don't like how it looks. Is there a better way to write this (maybe with just 1 function) and is there any other thing I should be concerned under exiting? Now to some background... Sometimes I will call logThis just to log and display. Other times I want to call it and exit. Initially I was doing this: logThis ("ERROR. EXITING") sys.exit() Then I figured that wouldn't properly set the stderr, thus the current code shown on the top. My first idea was actually passing "sys.exit" as an argument, and defining just logThis ("ERROR. EXITING", call=sys.exit) defined as following (showing just the relevant differenced part): def logThis (text, display="", call=print): msg = str(now.strftime("%Y-%m-%d %H:%M")) + " TREfNOC: " + text call msg + display But that obviously didn't work. I think Python doesn't store functions inside variables. I couldn't (quickly) find anywhere if Python can have variables taking functions or not! Maybe using an eval function? I really always try to avoid them, tho. Sure I thought of using if instead of another def, but that wouldn't be any better or worst. Anyway, any thoughts?

    Read the article

  • cannot convert 'b2PolygonShape' to 'objc_object*' in argument passing

    - by GONeale
    Hey there, I am not sure if many of you are familiar with the box2d physics engine, but I am using it within cocos2d and objective c. This more or less could be a general objective-c question though, I am performing this: NSMutableArray *allShapes = [[NSMutableArray array] retain]; b2PolygonShape shape; .. .. [allShapes addObject:shape]; and receiving this error on the addObject definition on build: cannot convert 'b2PolygonShape' to 'objc_object*' in argument passing So more or less I guess I want to know how to add a b2PolygonShape to a mutable array. b2PolygonShape appears to just be a class, not a struct or anything like that. The closest thing I could find on google to which I think could do this is described as 'encapsulating the b2PolygonShape as an NSObject and then add that to the array', but not sure the best way to do this, however I would have thought this object should add using addObject, as some of my other instantiated class objects add to arrays fine. Is this all because b2PolygonShape does not inherit NSObject at it's root? Thanks

    Read the article

< Previous Page | 5 6 7 8 9 10 11 12 13 14 15 16  | Next Page >