Search Results

Search found 9134 results on 366 pages for 'variadic functions'.

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

  • Handy SQL Server Functions Series (HSSFS) Part 2.0 - Prelude to Parsing Patterns Properly

    - by Most Valuable Yak (Rob Volk)
    In Part 1 of the series I wrote about 2 lesser-known and somewhat undocumented functions. In this part, I'm going to cover some familiar string functions like Substring(), Parsename(), Patindex(), and Charindex() and delve into their strengths and weaknesses. I'm also splitting this part up into sub-parts to help focus on a particular technique and/or problem with the technique, hence the Part 2.0. Consider this a composite post, or com-post, if you will. (It may just turn out to be a pile of sh_t after all) I'll be using a contrived example, perhaps the most frustratingly useful, or usefully frustrating, function in SQL Server: @@VERSION. Contrived, because there are better ways to get the information (which I'll cover later); frustrating, because of the way Microsoft formatted the value; and useful because it does have 1 or 2 bits of information not found elsewhere. First let's take a look at the output of @@VERSION: Microsoft SQL Server 2008 R2 (RTM) - 10.50.1600.1 (Intel X86) Apr 2 2010 15:53:02 Copyright (c) Microsoft Corporation Developer Edition on Windows NT 5.1 <X86> (Build 2600: Service Pack 3) There are 4 lines, with lines 2-4 indented with a tab character.  In case your browser (or this blog software) doesn't show it correctly, I gave each line a different color.  While this PRINTs nicely, if you SELECT @@VERSION in grid mode it all runs together because it ignores carriage return/line feed (CR/LF) characters.  Not fatal, but annoying. Note that @@VERSION's output will vary depending on edition and version of SQL Server, and also the OS it's installed on.  Despite the differences, the output is laid out the same way and the relevant pieces are in the same order. I'll be using the following view for Parts 2.1 onward, so we have a nice collection of @@VERSION information: create view version(SQLVersion,VersionString) AS ( select 2000, 'Microsoft SQL Server 2000 - 8.00.2055 (Intel X86) Dec 16 2008 19:46:53 Copyright (c) 1988-2003 Microsoft Corporation Developer Edition on Windows NT 5.1 (Build 2600: Service Pack 3)' union all select 2005, 'Microsoft SQL Server 2005 - 9.00.4053.00 (Intel X86) May 26 2009 14:24:20 Copyright (c) 1988-2005 Microsoft Corporation Developer Edition on Windows NT 5.1 (Build 2600: Service Pack 3)' union all select 2008, 'Microsoft SQL Server 2008 R2 (RTM) - 10.50.1600.1 (Intel X86) Apr 2 2010 15:53:02 Copyright (c) Microsoft Corporation Developer Edition on Windows NT 5.1 <X86> (Build 2600: Service Pack 3)' union all select 2005, 'Microsoft SQL Server 2005 - 9.00.3080.00 (Intel X86) Sep 6 2009 01:43:32 Copyright (c) 1988-2005 Microsoft Corporation Standard Edition on Windows NT 5.2 (Build 3790: Service Pack 2)' union all select 2008, 'Microsoft SQL Server 2008 R2 (RTM) - 10.50.1600.1 (X64) Apr 2 2010 15:48:46 Copyright (c) Microsoft Corporation Developer Edition (64-bit) on Windows NT 6.1 <X64> (Build 7600: ) (Hypervisor)' union all select 2008, 'Microsoft SQL Server 2008 R2 (RTM) - 10.50.1600.1 (X64) Apr 2 2010 15:48:46 Copyright (c) Microsoft Corporation Express Edition with Advanced Services (64-bit) on Windows NT 6.1 <X64> (Build 7600: ) (Hypervisor)' ) Feel free to add your own @@VERSION info if it's not already there. In Part 2.1 I'll focus on extracting the SQL Server version number (10.50.1600.1 in first example) and the Edition (Developer), but will have a solution that works with all versions.  Stay tuned!

    Read the article

  • Java variadic function parameters

    - by Amir Rachum
    Hi, I have a function that accepts a variable number of parameters: foo (Class... types); In which I get a certain number of class types. Next, I want to have a function bar( ?? ) That will accepts a variable number of parameters as well, and be able to verify that the variables are the same number (that's easy) and of the same types (the hard part) as was specified in foo. How can I do that? Edit: to clarify, a call could be: foo (String.class, Int.class); bar ("aaa", 32); // OK! bar (3); // ERROR! bar ("aa" , "bb"); //ERROR! Also, foo and bar are methods of the same class.

    Read the article

  • Go — variadic parameter functions weirdness

    - by ivanzoid
    I'm trying to write simple fmt.Printf wrapper which takes variable number of arguments, here is the code: func Die(format string, args ...interface{}) { str := fmt.Sprintf(format, args) fmt.Fprintf(os.Stderr, "%v\n", str) os.Exit(1) } But when I'm calling it: Die("foo") I get: foo%!(EXTRA []interface {}=[]) Can't figure why I'm getting this text after the "foo" & what is the correct way to create wrappers around fmt.Fprintf?

    Read the article

  • How to restrict an access to some of the functions at third level in Classes (OOPs)

    - by Shantanu Gupta
    I have created a class say A which has some functions defined as protected. Now Class B inherits A and class C inherits B. Class A has private default constructor and protected parameterized constructor. I want Class B to be able to access all the protected functions defined in Class A but class C can have access on some of the functions only not all the functions and class C is inheriting class B. How can I restrict access to some of the functions of Class A from Class C ? Class A { private A(){} protected A(int ){} } Class B : A {} CLass C:B { }

    Read the article

  • Problems with variadic function

    - by morpheous
    I have the following function from some legacy code that I am maintaining. long getMaxStart(long start, long count, const myStruct *s1, ...) { long i1, maxstart; myStruct *s2; va_list marker; maxstart = start; /*BUGFIX: 003 */ /*(va_start(marker, count);*/ va_start(marker, s1); for (i1 = 1; i1 <= count; i1++) { s2 = va_arg(marker, myStruct *); /* <- s2 is assigned null here */ maxstart = MAX(maxstart, s2->firstvalid); /* <- SEGV here */ } va_end(marker); return (maxstart); } When the function is called with only one myStruct argument, it causes a SEGV. The code compiled and run without crashing on Windows XP when I compiled it using VS2005. I have now moved the code to Ubuntu Karmic and I am having problems with the stricter compiler on Linux. Is anyone able to spot what is causing the parameter not to be read correctly in the var_arg() statement? I am compiling using gcc version 4.4.1 Edit The statement that causes the SEGV is this one: start = getMaxStart(start, 1, ms1); The variables 'start' and 'ms1' have valid values when the code execution first reaches this line.

    Read the article

  • Problems with variadic function (C)

    - by morpheous
    I have the following function from some legacy code that I am maintaining. long getMaxStart(long start, long count, const myStruct *s1, ...) { long i1, maxstart; myStruct *s2; va_list marker; maxstart = start; /*BUGFIX: 003 */ /*(va_start(marker, count);*/ va_start(marker, s1); for (i1 = 1; i1 <= count; i1++) { s2 = va_arg(marker, myStruct *); /* <- s2 is assigned null here */ maxstart = MAX(maxstart, s2->firstvalid); /* <- SEGV here */ } va_end(marker); return (maxstart); } When the function is called with only one myStruct argument, it causes a SEGV. The code compiled and run without crashing on an XP, when I compiled it using VS2005. I have now moved the code to Ubuntu Karmic and I am having problems with the stricter compiler on Linux. Is anyone able to spot what is causing the parameter not to be read correctly in the var_arg() statement? I am compiling using gcc version 4.4.1

    Read the article

  • Problems with variadic macros in C

    - by imikedaman
    Hi, I'm having a problem with optional arguments in #define statements in C, or more specifically with gcc 4.2: bool func1(bool tmp) { return false; } void func2(bool tmp, bool tmp2) {} #define CALL(func, tmp, ...) func(tmp, ##__VA_ARGS__) int main() { // this compiles CALL(func2, CALL(func1, false), false); // this fails with: Implicit declaration of function 'CALL' CALL(func2, false, CALL(func1, false)); } That's obviously a contrived example, but does show the problem. Does anyone know how I can get the optional arguments to "resolve" correctly? Additional information: If I remove the ## before _VA_ARGS_, and do something like this: bool func2(bool tmp, bool tmp2) { return false; } #define CALL(func, tmp, ...) func(tmp, __VA_ARGS__) int main() { CALL(func2, false, CALL(func2, false, false)); } That compiles, but it no longer works with zero arguments since it would resolve to func(tmp, )

    Read the article

  • Problem with using the XPATH functions

    - by Alex
    I've got a problem with using the XPATH functions. When I try to call some functions like lower-case or upper-case etc,they are not executed and I can't figure the problem out. I included the namespace xmlns:fn="http://www.w3.org/2005/xpath-functions" at the top of my XSL stylesheet and use fn namespace to call these functions but anyway nothing is working. Can anyone explain the reason and what I should do in order to be able to use the following functions? Cheers

    Read the article

  • Why doesn't g++ pay attention to __attribute__((pure)) for virtual functions?

    - by jchl
    According to the GCC documentation, __attribute__((pure)) tells the compiler that a function has no side-effects, and so it can be subject to common subexpression elimination. This attribute appears to work for non-virtual functions, but not for virtual functions. For example, consider the following code: extern void f( int ); class C { public: int a1(); int a2() __attribute__((pure)); virtual int b1(); virtual int b2() __attribute__((pure)); }; void test_a1( C *c ) { if( c->a1() ) { f( c->a1() ); } } void test_a2( C *c ) { if( c->a2() ) { f( c->a2() ); } } void test_b1( C *c ) { if( c->b1() ) { f( c->b1() ); } } void test_b2( C *c ) { if( c->b2() ) { f( c->b2() ); } } When compiled with optimization enabled (either -O2 or -Os), test_a2() only calls C::a2() once, but test_b2() calls b2() twice. Is there a reason for this? Is it because, even though the implementation in class C is pure, g++ can't assume that the implementation in every subclass will also be pure? If so, is there a way to tell g++ that this virtual function and every subclass's implementation will be pure?

    Read the article

  • How can I serialize functions using JSON or some other serialization library?

    - by Oragamster
    I am trying to create a program that uses javascript to write a simple textadventure that I can then post on my blog and run on my iphone. I have run into a problem though. I was trying to make it so that my program would save it's state into cookies using JSON to convert it into strings and then post it into a cookie but then I realised that I couldn't serialize the functions that are on my item object. I was trying to make it so that my item would have an associative array that would contain the name of the use as the key and the function as the value. This worked well untill I tried to serialize it. I learned that I could create a JSON like serialization for functions by storing the body into a string and using escape charectors for the double quotes but for some reason I was unable to make my cookie with the function as the string stored. When I posted the cookie and then tried to get it back the string wasn't there. My code and the over all project are on my site if you want to look at that, though my full code including the item actions are not posted yet.

    Read the article

  • Kernel Panic: line 61: can't open /scripts/functions

    - by Pavlos G.
    I'm facing a problem with all the kernels installed at my system (Ubuntu 10.10 64-bit). Installed kernel versions: 2.6.32-21 up to 2.6.35.23. The booting halted with the following error: init: .: line 61: can't open '/scripts/functions' Kernel panic - not syncing: Attempted to kill init! Pid: 1, comm: init not tainted Only the first one (2.6.32-21) was working up until know. I asked for help at ubuntuforums.org and i was told to check if there's any problem regarding my graphics card (ATI Radeon). I uninstalled all the ATI-related packages as well as all the unecessary xserver-xorg-video-* drivers that were installed. I then rebooted and from then on ALL of the kernels halt with the same error (i.e. it didn't fix the problematic kernels, it just broke the only one that was working...) Any ideas on what i should try next? Thanks in advance. Pavlos.

    Read the article

  • Why are PHP function signatures so inconsistent?

    - by Shamim Hafiz
    I was going through some PHP functions and I could not help notice the following: <?php function foo(&$var) { } foo($a); // $a is "created" and assigned to null $b = array(); foo($b['b']); var_dump(array_key_exists('b', $b)); // bool(true) $c = new StdClass; foo($c->d); var_dump(property_exists($c, 'd')); // bool(true) ?> Notice the array_key_exists() and property_exists() function. In the first one, the property name(key for an array) is the first parameter while in the second one it is the second parameter. By intuition, one would expect them to have similar signature. This can lead to confusion and the development time may be wasted by making corrections of this type. Shouldn't PHP, or any language for that matter, consider making the signatures of related functions consistent?

    Read the article

  • Why PHP Function Naming so Inconsistent?

    - by Shamim Hafiz
    I was going through some PHP functions and I could not help notice the following: <?php function foo(&$var) { } foo($a); // $a is "created" and assigned to null $b = array(); foo($b['b']); var_dump(array_key_exists('b', $b)); // bool(true) $c = new StdClass; foo($c->d); var_dump(property_exists($c, 'd')); // bool(true) ?> Notice the array_key_exists() and property_exists() function. In the first one, the property name(key for an array) is the first parameter while in the second one it is the second parameter. By intuition, one would expect them to have similar signature. This can lead to confusion and the development time may be wasted by making corrections of this type. Shouldn't PHP, or any language for that matter, consider making the signatures of related functions consistent?

    Read the article

  • Unit-Testing functions which have parameters of classes where source code is not accessible

    - by McMannus
    Relating to this question, I have another question regarding unit testing functions in the utility classes: Assume you have function signatures like this: public function void doSomething(InternalClass obj, InternalElement element) where InternalClass and InternalElement are both Classes which source code are not available, because they are hidden in the API. Additionally, doSomething only operates on obj and element. I thought about mocking those classes away but this option is not possible due to the fact that they do not implement an interface at all which I could use for my Mocking classes. However, I need to fill obj with defined data to test doSomething. How can this problem be solved?

    Read the article

  • How do functional languages handle random numbers?

    - by Electric Coffee
    What I mean about that is that in nearly every tutorial I've read about functional languages, is that one of the great things about functions, is that if you call a function with the same parameters twice, you'll always end up with the same result. How on earth do you then make a function that takes a seed as a parameter, and then returns a random number based on that seed? I mean this would seem to go against one of the things that are so good about functions, right? Or am I completely missing something here?

    Read the article

  • ASP.NET 3.5 Functions and Subroutines

    The most basic of all ASP.NET 3.5 server side scripts that I ve covered using the Visual Basic programming language is not modular in nature. This means that an ASP.NET 3.5 server will interpret the scripts in the Visual Basic file e.g Default.aspx.vb from top to bottom. In most real-world applications that use Visual Basic in ASP.NET websites however most web developers structure their programs in modules. This article will give you information about subroutines and functions along with practical examples and their advantages.... Cloud Servers in Demand - GoGrid Start Small and Grow with Your Business. $0.10/hour

    Read the article

  • MVC helper functions business logic

    - by Menelaos Vergis
    I am creating some helper functions (mvc.net) for creating common controls that I need in almost every project such as alert boxes, dialogs etc. If these do not contain any business logic and it's just client side code (html, js) then it's ok. My problem arises when I need some business logic behind this helper. I want to create a 'rate my (web) application' control that will be visible every 3 days and the user may hide it for now, navigate to rate link or hide it for ever. To do this I need some sort of database access and a code that acts as business logic. Normally I would use a controller for this, with my DI and everything, but I don't know where to put this code now. This should be placed in the helper function or in a controller that responds objects instead of ActionResults?

    Read the article

  • How to use OpenGL functions from multiples thread?

    - by Robert
    I'm writing a small game using OpenGL. I'm implementing basic networking in this game and I'm facing a problem. I have a thread in my client socket class that check for available data, when there are data I raise an event like this : immutable int len = this.m_socket.receive(data); if(len > 0) { this.m_onDataEvent(data); } Then on my game class, I have a function that handle and parse data like this : switch(msgId) { case ProtocolID.CharacterData: // Load terrain with opengl, character model.... Im not able to call opengl functions because my opengl context is created from a different thread. But I really don't know how I can solve this problem, I tried Google but it's really hard to find a solution. I'm using D programming language if it can help.

    Read the article

  • How to solve linear recurrences involving two functions?

    - by Aditya Bahuguna
    Actually I came across a question in Dynamic Programming where we need to find the number of ways to tile a 2 X N area with tiles of given dimensions.. Here is the problem statement Now after a bit of recurrence solving I came out with these. F(n) = F(n-1) + F(n-2) + 2G(n-1), and G(n) = G(n-1) + F(n-1) I know how to solve LR model where one function is there.For large N as is the case in the above problem we can do the matrix exponentiation and achieve O(k^3log(N)) time where k is the minimum number such that for all km F(n) does not depend on F(n-k). The method of solving linear recurrence with matrix exponentiation as it is given in that blog. Now for the LR involving two functions can anyone suggest an approach feasible enough for large N.

    Read the article

  • Returning status code where one of many errors could have occured

    - by yttriuszzerbus
    I'm developing a PHP login component which includes functions to manipulate the User object, such as $User->changePassword(string $old, string $new) What I need some advice with is how to return a status, as the function can either succeed (no further information needs to be given) or fail (and the calling code needs to know why, for example incorrect password, database problem etc.) I've come up with the following ideas: Unix-style: return 0 on success, another code on failure. This doesn't seem particularly common in PHP and the language's type-coercion messes with this (a function returning FALSE on success?) This seems to be the best I can think of. Throw an exception on error. PHP's exception support is limited, and this will make life harder for anybody trying to use the functions. Return an array, containing a boolean for "success" or not, and a string or an int for "failure status" if applicable. None of these seem particularly appealing, does anyone have any advice or better ideas?

    Read the article

  • What is the most handy function you've ever came across? [closed]

    - by Viniyo Shouta
    Obviously everything is 'handy' when it comes to programming terms, but some get a highlight spot, like containers, matrix trasnformation functions and many others. But in this case please mention the one it was more handy to you, saved you from sparing hours resolving a problem, or even the one you like more, What is it and what does it does? I'll start with an example. Language: C++ Function: std::sort (STL) What does it does: Arranges the elements in a specified range into a nondescending order or according to an ordering criterion specified by a binary predicate. (It arranges a container in decreasing order) Why of this question? Because I want to learn how to if possible make my own implementations of these functions for pure studying purposes, to enhance knowledge

    Read the article

  • How to make Doxygen ignore specific PHP functions, when generating documentation from a purely proce

    - by Senthil
    I am writing a PHP Library and I am trying out Doxygen to generate the API documentation. My library does not use OOP. All code is procedural. I use lot of helper functions which have an _ (underscore) prefix in their names. They are not part of the publicly exposed API. They are just used internally. Even though they are commented just like the API functions, I don't want them included when giving out the documentation for the API. I want Doxygen to ignore these functions. I can think of two solutions for this, but I am not able to implement either one of them. First is, I can set some configuration in Doxygen to make it ignore specific function name patterns. I went through Doxygen help documentation and searched the web. There seems to be options to ignore file and folder name patterns. But I am not able to find an option to specify a function name pattern and make it ignore those functions. Second is, along with all the other content in the comments above functions, I could add some other keyword or something and make Doxygen ignore those functions. I haven't been able to find out how to do that either. How can I make Doxygen ignore specific PHP functions when generating documentation? Update I searched within Stack Overflow and came across this question. It looked similar to my question. I found out about EXCLUDE_SYMBOLS config option in one of the answers. You can use that to exclude function names too. More importantly, wildcards were supported. So I am able to ignore all my functions with _ as the prefix :) This ridiculous! I should've done more research :| Someone please delete this question or add this answer as an answer.

    Read the article

  • Stop functions in 5 minutes if they dont end running

    - by george mano
    I want to add a feature in my project. I have 2 functions running in a for-loop because I want to find the solution of the functions in random arrays. I also have an function that makes random arrays. In each loop the array that is made by the random_array fun are the input of the 2 functions. The 2 functions print solutions in the screen , they dont return an argument. int main(){ for (i=0;i<50 i++) { arr1=ramdom_array(); func1(arr1) func2(arr1) } } I need to stop the functions running if they have not ended in 5 minutes. I have thought that I have to put in the functions something like this : void func1(array<array<int,4>,4> initial) { while (5minutes_not_passed) { //do staff if(solution==true) break; } } But I dont know what to put in the 5minutes_not_passed. the declaration of the functions are like this: void func1(array<array<int,4>,4> initial) void func2(array<array<int,4>,4> initial) I have found that I can use the thread library but I dont think meshing up with threads in a good idea. I believe something like a timer is needed. Note that the functions sometimes might end before 5 minutes.

    Read the article

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