Search Results

Search found 15081 results on 604 pages for 'passing by reference'.

Page 59/604 | < Previous Page | 55 56 57 58 59 60 61 62 63 64 65 66  | Next Page >

  • F# passing an operator with arguments to a function

    - by dan
    Can you pass in an operation like "divide by 2" or "subtract 1" using just a partially applied operator, where "add 1" looks like this: List.map ((+) 1) [1..5];; //equals [2..6] // instead of having to write: List.map (fun x-> x+1) [1..5] What's happening is 1 is being applied to (+) as it's first argument, and the list item is being applied as the second argument. For addition and multiplication, this argument ordering doesn't matter. Suppose I want to subtract 1 from every element (this will probably be a common beginners mistake): List.map ((-) 1) [1..5];; //equals [0 .. -4], the opposite of what we wanted 1 is applied to the (-) as its first argument, so instead of (list_item - 1), I get (1 - list_item). I can rewrite it as adding negative one instead of subtracting positive one: List.map ((+) -1) [1..5];; List.map (fun x -> x-1) [1..5];; // this works too I'm looking for a more expressive way to write it, something like ((-) _ 1), where _ denotes a placeholder, like in the Arc language. This would cause 1 to be the second argument to -, so in List.map, it would evaluate to list_item - 1. So if you wanted to map divide by 2 to the list, you could write: List.map ((/) _ 2) [2;4;6] //not real syntax, but would equal [1;2;3] List.map (fun x -> x/2) [2;4;6] //real syntax equivalent of the above Can this be done or do I have to use (fun x -> x/2)? It seems that the closest we can get to the placeholder syntax is to use a lambda with a named argument.

    Read the article

  • C# ASP.Net The type or namespace name 'Secure' does not exist in the namespace 'source_extranet'

    - by Louis Russell
    Afternoon all, I really need your help as this is a Nightmare! I was earlier having a problem with referencing a 3rd Party Dll (Here) but have overcome this problem and am now having a problem referencing my own classes! Everything seems fine at build with no errors at all but when I go to run the application it comes up with the following Compilation Error: Compiler Error Message: CS0234: The type or namespace name 'Secure' does not exist in the namespace 'source_extranet' (are you missing an assembly reference?) The line that the Error points to this line in the class: source_extranet.Secure.BackendCustomData newdata = new source_extranet.Secure.BackendCustomData(); This line of code points to a class in the same folder as the calling code class. I have scoured Google looking for an answer and haven't found anything that points me to an answer to my problem. Any help would be AMAZING!

    Read the article

  • Passing javascript objects as function arguments

    - by Prashant
    Hello all I want to pass a javascript object (JSON) as an argument to another function. But i am getting following error: missing ] after element list the function is called on onclick event of href like "<a href='javascript:void(0);' onclick='javascript:openTab("+ sTab +");'>"+ sTab['SavedTab']['title'] +"</a><br/>"; When i pass whole value : sTab['SavedTab']['title'] , it works fine but i want to pass whole object, not just single value out of it. Please help me out. Thanks.

    Read the article

  • Passing variables across a multi page form in php

    - by Chris
    Forgive me as I am a newbie. I have a multi page form in which I am using $_SESSIONS to record the variables. <?php session_start(); foreach ( $_POST as $key=>$value ) { if ( $key!="submit" ) { $value= htmlentities(stripslashes(strip_tags($value))); $_SESSION[$key] = $value; } }` I have two problems actually. When I get to a checkform.php that I made that prints out the variables, The variables from page 1 doesn't show up even though that code listed above is on each page. I am using Firefox web developers tool to disable cookies and in the php ini, I altered session.use_trans_sid to 1 to turn it on. For the final page on my checkform.php I print_r($_POST) for the final page which works fine. Why doesn't variables from page 1 not show up? What am I missing? The 2nd problem is that when I print_r($_SESSION), some fields, specifically the checkbox arrays, print as [payment] => Array [agerange] => Array [meals] => Array [mealtypes] => Array What am I missing?

    Read the article

  • Not able to close Dialog from parent dialog reference

    - by coffeeaddict
    In the dialog content, I have this: <script type="text/javascript"> $(function() { $("#cancel").click(function(o) { alert(parent.$('#dialog')); parent.$("#dialog").dialog("close"); o.preventDefault(); }); }); </script> and also tried this: <script type="text/javascript"> $(function() { $("#cancel").click(function(o) { $(this).closest("#dialog").dialog("close"); o.preventDefault(); }); }); </script> <a id="cancel" href="#"><img src="images/cancelBtn.gif" /></a> This code again is the content of my dialog. When the user clicks the hyperlink I'm trying to close the parent dialog (the dialog that this content is in) but it's not doing anything. I know that the alert gets hit and that there is an object for parent.$('#dialog'); so not sure why it won't close the parent dialog

    Read the article

  • Sorting a nodeset before passing to xsl:for-each

    - by Zack Mulgrew
    I have a situation where loop through a sorted nodeset and apply a template on each of the nodes: <div id="contractscontainer"> <xsl:for-each select="document"> <xsl:sort select="content[@name='ClientName']/text()" /> <xsl:apply-templates select="." mode="client-contract" /> </xsl:for-each> </div> I want to do something special with the "first" 5 nodes in the node set and render them nested element. The problem is that they need to be in the same order as if they were sorted (as they are in the loop). I had planned on doing this by using two xsl:for-each elements, each with the correct nodes selected from the set. I can't do this, however, because they need to be sorted before I can select the "first" 5. Example: <div id="contractscontainer"> <div class="first-five"> <xsl:for-each select="document[position() < 6]"> <xsl:sort select="content[@name='ClientName']/text()" /> <xsl:apply-templates select="." mode="client-contract" /> </xsl:for-each> </div> <div class="rest-of-them"> <xsl:for-each select="document[position() > 5]"> <xsl:sort select="content[@name='ClientName']/text()" /> <xsl:apply-templates select="." mode="client-contract" /> </xsl:for-each> </div> </div> I don't think this will work because I'm selecting the nodes by position before sorting them, but I can't use xsl:sort outside of the xsl:for-each. Am I approaching this incorrectly?

    Read the article

  • Abstract class reference

    - by AlgoMan
    Can i have a class Class Room{ ~Room(); virtual cost() =0; } Class Hotel{ map rooms; /* */ }; will my hotel become abstract ? Can it hold the list of concrete Room objects that are derived from Room ?

    Read the article

  • Passing an instantiated class to concrete class derived by Castle Windsor

    - by Tr1stan
    I have a system that I'm using to test some new architecture. I have the following setup (In MVC2 .Net - C Sharp): View < Controller < Service < Repository < DB I'm using Castle Windsor as my DI (IoC) controller, and this is working just fine in both the Service and Repo layers. However, I'm now at a point where I would like to pass an Entity Framework (DatabaseNameEntity) to the constructor to the Service, and then to the Repo, so that I have something similar to a Unit of Work pattern per request (This feels like what I'm trying to achieve anyway) - and I'm having trouble working out how this can be done using Castle Windsor. Am I going off on a silly tangent? Any pointers appreciated.

    Read the article

  • Passing parameter to controller from route in laravel

    - by bretterer
    Given the following route Route::get('groups/(:any)', array('as' => 'group', 'uses' => 'groups@show')); And the URL I would like to use, http://www.example.com/groups/1 I would like to be able to use the (:any) value in my controller. My controller looks like class Groups_Controller extends Base_Controller { public $restful = true; public function get_show($groupID) { return 'I am group id ' . $groupID; } } How is this possible to do? I have tried a few things including the following Route::get('groups/(:any)', array('as' => 'group', 'uses' => 'groups@show((:1))')); but it did not work. UPDATE Anytime I try to pass in the arguments as show above i get a 404 error. Thanks for the help!

    Read the article

  • Django Passing Custom Form Parameters to Formset

    - by Paolo Bergantino
    I have a Django Form that looks like this: class ServiceForm(forms.Form): option = forms.ModelChoiceField(queryset=ServiceOption.objects.none()) rate = forms.DecimalField(widget=custom_widgets.SmallField()) units = forms.IntegerField(min_value=1, widget=custom_widgets.SmallField()) def __init__(self, *args, **kwargs): affiliate = kwargs.pop('affiliate') super(ServiceForm, self).__init__(*args, **kwargs) self.fields["option"].queryset = ServiceOption.objects.filter(affiliate=affiliate) I call this form with something like this: form = ServiceForm(affiliate=request.affiliate) Where request.affiliate is the logged in user. This works as intended. My problem is that I now want to turn this single form into a formset. What I can't figure out is how I can pass the affiliate information to the individual forms when creating the formset. According to the docs to make a formset out of this I need to do something like this: ServiceFormSet = forms.formsets.formset_factory(ServiceForm, extra=3) And then I need to create it like this: formset = ServiceFormSet() Now how can I pass affiliate=request.affiliate to the individual forms this way?

    Read the article

  • Passing pointer position to an object in Java.

    - by Gabriel A. Zorrilla
    I've got a JPanel class called Board with a static subclass, MouseHanlder, which tracks the mouse position along the appropriate listener in Board. My Board class has fields pointerX and pointerY. How do i pass the e.getX() and e.getY() from the MouseHandler subclass to its super class JPanel? I tried with getters, setters, super, and cant get the data transfer between subclass and parent class. I'm certain it's a concept issue, but im stuck. Thanks!

    Read the article

  • Passing Activity to non-activity object properly

    - by rayman
    In my app ive got a non-activity object which it's role is being a manager class. many times i need to pass "source activity" to methods as parameter to that manager class in order to make some operations on that activity. for exaple let's assume we have MyActivity which gotta do some toast. so i have this manager class called MyManager, and i have this method in it raiseToast(Activity sourceActivity) { Toast.makeText(sourceActivity, demo, Toast.LENGTH_LONG).show(); } and from Myactivity class we calling that method this way: MyManager manager=new MyManager(); manager.raitetoast(MyActivity.this); it works fine. what I'm asking here, is this a proper way to pass an Activity as parameter to a non-activity object? I'm having a memory leaks on real device(not the emulator), I wonder if this could also causing any reason for that? Thanks Idan.

    Read the article

  • Passing an TAdoDataset as parameter using TADOStoredProc

    - by Salvador
    i have an oracle stored procedure with 2 parameters declarated as input cursors. how i can assign this parameters the TADOStoredProc component? ORACLE PROCEDURE MYSTOREDPROCEDURE(P_HEADER IN TCursor, P_DETAL IN TCursor, P_RESULT OUT VARCHAR2) BEGIN //My code goes here END; Delphi function TMyClass.Add(Header, Detail: TADODataSet;var _Result: string): boolean; Var StoredProc : TADOStoredProc; begin Result:=False; StoredProc:=TADOStoredProc.Create(nil); try StoredProc.Connection :=ADOConnection1; StoredProc.ProcedureName:='MYSTOREDPROCEDURE'; StoredProc.Parameters.Refresh; StoredProc.Parameters.ParamByName('P_HEADER').Value :=Header;//How can assign this parameter? try StoredProc.Open; _Result:=VarToStrNull(StoredProc.Parameters.ParamByName('P_RESULT').Value); StoredProc.Close; Result:=True; except on E : Exception do begin _Result:=E.Message; //exit; end; end; finally StoredProc.Free; end; end;

    Read the article

  • Java: JAX-WS passing authentication info to a call to webservice

    - by agnieszka
    I am using JAX-WS. I am connecting to .NET webservice that requires authentication. I first call the Authentication.asmx so that I can be authenticated. The call returns me a LoginResult that contains a cookie name. Then I call another webservice and I need to somehow pass this cookie or a cookie name. and I don't know how. Here is the code: //first service that returns login information Authentication auth = new Authentication(new URL("the_url"), new QName("http://schemas.microsoft.com/sharepoint/soap/", "Authentication")); LoginResult result = auth.getAuthenticationSoap().login(HTTPuserName, HTTPpassword); //i need to pass cookie or cookie name or any other login information to call to this service Copy copyService = new Copy(new URL("service_url"), new QName("http://schemas.microsoft.com/sharepoint/soap/", "Copy")); BindingProvider p = (BindingProvider) copyService.getCopySoap();

    Read the article

  • passing variable to a function.

    - by sushant
    its kind of silly question. but i dont know what mistake i am making. if any one could help. function zips(s) document.write(s) end function dim x,y x="sushant" clickme sorry i dont know how to format it. but i am no getting the desired output. any help is very much appreciated

    Read the article

  • Problem passing strings with PHP post

    - by andy
    Hi Guys, Basically I'm developing a (very) simple search engine. You can enter a search term and you are taken to the results page - which works fine. However on the results page, I have a button that will take you to the next 10 results: where $term is the $_POST['term'] value. echo "<input type='hidden' name='term' value='" . $term . "'>"; This causes the following problem with the term is for example "aidan's". When the next 10 button is clicked, the term becomes aidan\ and no further results are found. I am not doing anything to $term. I usually use Java, but am required to use PHP for this uni assignment! Any help would be greatly appreciated.

    Read the article

  • Passing Validation exceptions via WCF REST

    - by Coppermill
    I am using WCF and REST, and I have complex types, which are working fine. Now I need to check for validation, I am thinking of using DataAnnotations e.g. public class Customer { [Required] public string FirstName {get;set;} } Now where the issue is how do I pass this validation down to the REST service? ALso I need to validate the object when it comes back, and throw an exception, if I am to throw an exception then what is the best way of doing this using REST?

    Read the article

  • Passing empty list as parameter to JPA query throws error

    - by Tuukka Mustonen
    If I pass an empty list into a JPA query, I get an error. For example: List<Municipality> municipalities = myDao.findAll(); // returns empty list em.createQuery("SELECT p FROM Profile p JOIN p.municipality m WHERE m IN (:municipalities)") .setParameter("municipalities", municipalities) .getResultList(); Because the list is empty, Hibernate generates this in SQL as "IN ()", which gives me error with Hypersonic database. There is a ticket for this in Hibernate issue tracking but there are not many comments/activity there. I don't know about support in other ORM products or in JPA spec either. I don't like the idea of having to manually check for null objects and empty lists every time. Is there some commonly known approach/extension to this? How do you handle these situations?

    Read the article

  • embed ttf as embeded resource can't reference it

    - by HoNgOuRu
    Hi, I've just added a ttf file to the project (c# 2008 express) as "file" and build option to embeded resource. I'm having problems when trying to set this font like this: (I know the next line is wrong...) this.label1.Font = AlarmWatch.Properties.Resources.Baby_Universe; Error 1 Cannot implicitly convert type 'byte[]' to 'System.Drawing.Font' C:\Users\hongo\Documents\Visual Studio 2008\Projects\AlarmWatch\AlarmWatch\Form1.Designer.cs 57 32 AlarmWatch I know it is byte[] cause I've set the option build as embeded resource, but...comparing with this line that is correct "this.label1.Font = new System.Drawing.Font("OCR A Extended", 24F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));" How can I set this.label1 to use the new font??? thanks

    Read the article

  • Passing a non-iterable to list.extend ()

    - by JS
    Hello, I am creating a public method to allow callers to write values to a device, call it write_vals() for example. Since these values will by typed live, I would like to simplify the user's life by allowing them type in either a list or a single value, depending on how many values they need to write. For example: write_to_device([1,2,3]) or write_to_device(1) My function would like to work with a flat list, so I tried to be clever and code something like this: input_list = [] input_list.extend( input_val ) This works swimmingly when the user inputs a list, but fails miserably when the user inputs a single integer: TypeError: 'int' object is not iterable Using list.append() would create a nested list when a list was passed in, which would be an additional hassle to flatten. Checking the type of the object passed in seems clumsy and non-pythonic and wishing that list.extend() would accept non-iterables has gotten me nowhere. So has trying a variety of other coding methods. Suggestions (coding-related only, please) would be greatly appreciated.

    Read the article

  • Doctrine DQL execute passing params

    - by Karim web Developer
    I used this DQL in Doctrine $q->update('product') ->set('quantity','?') ->where('id=?'); $q->execute(array(20,5)); I check the server for the query and this the generated sql UPDATE product SET quantity = '20', updated_at = '5' WHERE (id = '2010-04-26 14:34); So I need to know why the arguments aren't in the correct places?

    Read the article

  • Passing constructor arguments when using StructureMap

    - by Mosh
    Hello, I'm using StructureMap for my DI. Imagine I have a class that takes 1 argument like: public class ProductProvider : IProductProvider { public ProductProvider(string connectionString) { .... } } I need to specify the "connectionString at run-time when I get an instance of IProductProvider. I have configured StructureMap as follows: ForRequestedType<IProductProvider>.TheDefault.Is.OfConcreteType<ProductProvider>(). WithCtorArgument("connectionString"); However, I don't want to call EqualTo("something...") method here as I need some facility to dynamically specify this value at run-time. My question is: how can I get an instance of IProductProvider by using ObjectFactory? Currently, I have something like: ObjectFactory.GetInstance<IProductProvider>(); But as you know, this doesn't work... Any advice would be greatly appreciated.

    Read the article

  • Null reference to DataContext when testing an ASP.NET MVC app with NUnit

    - by user252160
    I have an ASP.NET MVC application with a separate project added for tests. I know the plusses and minuses of using the connection to the database when running unit tests, and I still want to use it. Yet, every time when I run the tests with the NUnit tool, they all fail due to my Data Context being null. I heard something about having a separate config file for the tests assembly, but i am not sure whether I did it properly, or whether that works at all.

    Read the article

< Previous Page | 55 56 57 58 59 60 61 62 63 64 65 66  | Next Page >