default-value

Can the result of a function call be used as a default parameter value?

Is there a good method for writing C / C++ function headers with default parameters that are function calls? I have some header with the function: int foo(int x, int y = 0); I am working in a large code base where many functions call this function and depend on this default value. This default value now needs to change to something ...

Determine if a named parameter was passed

I would like to know if it is possible to determine if a function parameter with a default value was passed in Python. For example, how does dict.pop work? >>> {}.pop('test') Traceback (most recent call last): File "<stdin>", line 1, in <module> KeyError: 'pop(): dictionary is empty' >>> {}.pop('test',None) >>> {}.pop('test',3) 3 >>> ...

About usage of DefaultValueAttribute Class in .Net

So here is the simple code: [System.ComponentModel.DefaultValue(true)] public bool AnyValue { get; set; } I am sure I don't set AnyValue to false again (I just created it). This property is a property of a Page class of ASP.NET. And I am cheking the value in a button event handling function. But somehow it is still false. I w...

What's the simplest way to override a Delphi property's default value?

I'm trying to write a TCustomDBGrid descendant that's designed to feel like a TListBox. One of the things I want to change is the Options property's defaults. TCustomDBGrid defines Options as: property Options: TDBGridOptions read FOptions write SetOptions default [dgEditing, dgTitles, dgIndicator, dgColumnResize, dgColLines, dgRo...

MySQL - Set default value for field as a string concatenation function

Hi I have a table that looks a bit like this actors(forename, surname, stage_name); I want to update stage_name to have a default value of forename." ".surname So that insert into actors(forename, surname) values ('Stack', 'Overflow'); would produce the record 'Stack' 'Overflow' 'Stack Overflow' Is this possible? Thank...

Returning a default value. (C#)

I'm creating my own dictionary and I am having trouble implementing the TryGetValue function. When the key isn't found, I don't have anything to assign to the out parameter, so I leave it as is. This results in the following error: "The out parameter 'value' must be assigned to before control leaves the current method" So, basically,...

default value for generic type in c#

The docs for Dictionary.TryGetValue say: When this method returns, [the value argument] contains the value associated with the specified key, if the key is found; otherwise, the default value for the type of the value parameter. This parameter is passed unin I need to mimic this in my class. How do I find the default value for type...

Bind a column default value to a function in SQL 2005

I have a column containing items that can be sorted by the user: DOC_ID DOC_Order DOC_Name 1 1 aaa 2 3 bbb 3 2 ccc I'm trying to figure out a way to properly initialize DOC_Order when the entry is created. A good value would either be the corresponding DO-CID (since it is autoassigned),...

What is the most efficient method of setting default parameter values in javascript?

I know of two methods of setting a default parameter, but I would like to know what the preferred method is. function Foo(par1, par2) { if(par2 == null) par2 = "my default" } or function Foo(par1, par2) { par2 = par2 || "my default" } or is there a better way than either of these? EDIT: I would also like to know h...

How do I add a Python-style Get() method which takes a default value to my C# dictionaries?

I'd like to be able to specify a default value to return if the key I specify can't be found in the dictionary. e.g. int default = 5; string key = "MyKey"; int foo = myDictionary.GetValue(key, default); if key is in myDictionary foo should hold the value from the dictionary, otherwise it will hold 5. ...

How can I get the default value of a type in a non-generic way ?

I know the "default" keyword returns the default value of a statically determined type, as shown for instance in this question. However, given an instance of a type, is there a simple way to get the default value of this type, dynamically ? The only way I found while googling is this : static object DefaultValue(Type myType) { if (...

Default Value for Closure Parameters in Groovy

Is there some way to use default parameters values with closures in Groovy? This is what I tried so far: class Persona { String name Persona( String name ) { this.name = name } String salute( String salute = "Hola" ) { salute + ' ' + this.name } } Persona.metaClass.salute2 = { String salute ...

Default value to a data parameter , SSRS

In my SSRS report I wanted to default the date parameter with the execution date. I default the date patameter with =DateValue(Globals!ExecutionTime) or =today. I do have 5 other parameters in my report. In reporting manager, it makes the page refresh each time when I select another parameter value. Why is that? How do I solve this? ...

Sourcesafe command line options

I am having an issue with the Microsoft Visual Sourcesafe command line options that I'm hoping someone has run across and can assist me with. I have the following line in a DOS batch file. "c:\Program Files\Microsoft Visual SourceSafe\ss.exe" GET "$/Development Projects/Activity" -GL"C:\Compile\Activity" -R -Q -Yname,passwor...

Default Value or Binding in MSSQL2008 good practice?

If you have for instance a datetime datatype set on a column in MSSQLServer2008 that gives you the datecreated, is it better to have the .NET layer pass the current date or set the Default Value or Binding of the column to (getdate())? ...

Using a constant NSString as the key for NSUserDefaults

I'm using NSUSerDefaults to store user preferences. I remember reading somewhere that setting the keys as constants is a good idea - and I agree. The following code is what I currently have: [[NSUserDefaults standardUserDefaults] setObject:[NSNumber numberWithInt:polygon.numberOfSides] forKey:@"polygonNumberOfSides"]...

Problem with default values for Reporting Services parameters

I have a SQL 2005 Reporting Services report that has several report parameters. One of them is called IsActive and is of type Boolean. The parameter is hidden and set to allow null values. For its default values settings, I have it set to null. In my application that has the reportviewer control, I have logic that decided whether or ...

Does an uninitialized hash key have a default value of zero in Perl?

I have Perl code similar to the following: # -- start -- my $res; # run query to fetch IPv6 resources while( my $row = $org_ip6_res->fetchrow_arrayref ) { if( $row->[4] =~ /PA/ ) { $res->{ipv6}{pa}{$row->[2]}++; } elsif( $row->[4] eq 'PI' ) { $res->{ipv6}{pi}{$row->[2]}++; } } # -- stop -- At no point is...

I thought curtime(), now() and current_timestamp are valid default datetime values in MySql?

I'm using the latest version of MySql and I tried altering a table to use curtime() or now() or current_timestamp as the default value for a datetime column (created_at, updated_at). For all three, the alter failed, saying these are invalid default values. Any ideas what's an appropriate default value to generate the current time in a da...

How to set a Postgresql default value datestamp like 'YYYYMM' ?

As title, how can I set a table's column to have the default value the current year and month, in format 'YYYYMM', like 200905 for today? ...