Search Results

Search found 47805 results on 1913 pages for 'return address'.

Page 93/1913 | < Previous Page | 89 90 91 92 93 94 95 96 97 98 99 100  | Next Page >

  • Return popupmenu selection in MATLAB using one line of code

    - by Doresoom
    I have a GUI which uses a selection from a popupmenu in another callback. Is there a way to return the selected value of the popupmenu in only one line without creating any temporary variables? I've tried several solutions, but I've only managed two lines with one temporary variable: Three lines: list=get(handles.popupmenu1,'String'); val=get(handles.popupmenu1,'Value'); str=list{val}; Two lines: temp=get(handles.popupmenu1,{'String','Value'}); str=temp{1}{temp{2}}; Can anyone shave it down to one? PS, It's a dynamic menu, so I can't just use get(handles.popupmenu1,'Value') and ignore the string component altogether.)

    Read the article

  • Linq to NHibernate - How to return a parent object with only certain child objects included

    - by vakman
    Given a simplified model like the following: public class Enquiry { public virtual DateTime Created { get; set; } public virtual Sender Sender { get; set; } } public class Sender { public virtual IList<Enquiry> Enquiries { get; set; } } How can you construct a Linq to Nhibernate query such that it gives you back a list of senders and their enquiries where the enquiries meet some criteria. I have tried something like this: return session.Linq<Enquiry>() .Where(enquiry => enquiry.Created < DateTime.Now) .Select(enquiry => enquiry.Sender) In this case I get an InvalidCastException saying you can't cast type Sender to type Enquiry. Any pointers on how I can do this without using HQL?

    Read the article

  • jQuery: how to handle empty return from getJSON

    - by Gee
    Alright so I have a php script which gets results from a DB, and to get those results I'm using a jQuery script to pull the results via getJSON. It works perfectly but now I want to do something if the php script returns no results (empty). I tried: $.getJSON('path/to/script'), {parameter:parameter}, function(data){ if (data) { alert('Result'); } else { alert('Empty); } }); But it's no good. I've tried different things like if (data.length) but still nothing. I've noticed that if there is no returned data the callback will never fire at all. So if that's the case, how do I handle a empty return?

    Read the article

  • Override Django inlineformset_factory has_changed() to always return True

    - by John
    Hi, I am using the django inlineformset_factory function. a = get_object_or_404(ModelA, pk=id) FormSet = inlineformset_factory(ModelA, ModelB) if request.method == 'POST': metaform = FormSet (instance=a, data=request.POST) if metaform.is_valid(): f = metaform.save(commit=False) for instance in f: instance.updated_by = request.user instance.save() else: metaform = FormSet(instance=a) return render_to_response('nodes/form.html', {'form':metaform}) What is happening is that if I change any of the data then everything works ok and all the data gets updated. However if I don't change any of the data then the data is not updated. i.e. only entries which are changed go through the for loop to be saved. I guess this makes sense as there is no point saving data if it has not changed. However I need to go through and save every object in the form regardless of whether it has any changes on not. So my question is how do I override this so that it goes through and saves every record whether it has any changes or not? Hope this makes sense Thanks

    Read the article

  • Constructor return value

    - by Ivan Gromov
    Could you tell me what is wrong with my class constructor? Code: CVector::CVector (int size_) { if (size_ > 0) { this->size = size_; this->data = new double[size]; for (int i = 0; i < size; i++) { (*this)(i) = i; } } cout << "constructor end" << endl; return; } Usage example: tvector = CVector(6); I get an access violation after "constructor end" output.

    Read the article

  • Two Objects created with the same Address in Flex

    - by James
    Hi, I have an issue in flex which is causing a bit of a headache! I am adding objects to an ArrayCollection but in doing so, another ArrayCollection is also picking up these changes even though there is no binding occurring. I can see from the debug that the two ACs have the same address but for the life of me can't figure out why. I have two Array Collections: model.index.rows //The main array collection model.index.holdRows //The array collection that imitates the above This phantom data binding occurs only for the first iteration in the loop and for all others it will just write it the once. The reason this is proving troublesome is that it creates duplicate entries in my datagrid. public override function handleMessage(message:IMessage):void { super.handleMessage(message); if (message is IndexResponse) { var response:IndexResponse = message as IndexResponse; model.index.rows.removeAll(); model.index.indexIsEmpty = response.nullIndex; if (model.index.indexIsEmpty !== true) { //Update the index model from the response. Note: each property of the row object will be shown in the UI as a column in the grid response.index.forEach(function(entry:EntryData, i:int, a:Array):void { var row:Object = { fileID: entry.fileID, dadName: entry.dadName }; entry.tags.forEach(function(tag:Tag, i:int, a:Array):void { row[tag.name] = tag.value; }); model.index.rows.addItem(row); }); if(model.index.indexForNetworkView == true){ model.index.holdRows.source = model.index.holdRows.source.concat(model.index.rows.source); model.index.indexCounter++; model.index.indexForNetworkView = false; controller.indexController.showNetwork(model.index.indexCounter); } model.index.rows.refresh(); controller.networkController.show(); } } Has anyone else who has encountered something simillar propose a solution?

    Read the article

  • PHP - How can I check if return() was called from an include()'d file?

    - by John Himmelman
    How can I tell if return() was called from within the included file. The problem is that include() returns 'int 1', even if return() wasn't called. Here is an example... included_file_1.php <?php return 1; included_file_2.php <?php echo 'no return here, meep'; main.php <?php $ret = include('included_file_1.php'); // This file DID return a value, int 1, but include() returns this value even if return() wasn't called in the included file. if ($ret === 1) { echo 'file did not return anything'; } var_dump($ret); $ret = include('included_file_2.php'); // The included file DID NOT return a value, but include() returns 'int 1' if ($ret === 1) { echo 'file did not return anything'; } var_dump($ret);

    Read the article

  • Segmentation fault before return

    - by donalmg
    Hi, Why does the following code seg fault before returning: int main() { char iD[20]; memset (iD, 0, 20); char* prefix; srand (time(NULL) ); int iPrefix = rand()%1000000; sprintf(prefix, "%i", iPrefix); int len = strlen(prefix); char* staticChar = "123456789"; //set prefix into ID memcpy(iD, prefix, len); // append static value memcpy(iD+len, staticChar, 20-len); cout << "END " << endl; return 0; } At the minute, the cout will display, but I get a segmentation fault.

    Read the article

  • Linq to SQl Stored Procedure Problem( it can't figure out the return type)

    - by chobo2
    Hi I have this SP USE [Test] GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE PROCEDURE [dbo].[UsersInsert](@UpdatedProdData XML) AS INSERT INTO dbo.UserTable(UserId,UserName,LicenseId,Password,PasswordSalt,Email,IsApproved,IsLockedOut,CreateDate, LastLoginDate,LastLockOutDate,FailedPasswordAttempts,RoleId) SELECT @UpdatedProdData.value('(/ArrayOfUsers/Users/UserId)[1]', 'uniqueidentifier'), @UpdatedProdData.value('(/ArrayOfUsers/Users/UserName)[1]', 'varchar(20)'), @UpdatedProdData.value('(/ArrayOfUsers/Users/LicenseId)[1]', 'varchar(50)'), @UpdatedProdData.value('(/ArrayOfUsers/Users/Password)[1]', 'varchar(128)'), @UpdatedProdData.value('(/ArrayOfUsers/Users/PasswordSalt)[1]', 'varchar(128)'), @UpdatedProdData.value('(/ArrayOfUsers/Users/Email)[1]', 'varchar(50)'), @UpdatedProdData.value('(/ArrayOfUsers/Users/IsApproved)[1]', 'bit'), @UpdatedProdData.value('(/ArrayOfUsers/Users/IsLockedOut)[1]', 'bit'), @UpdatedProdData.value('(/ArrayOfUsers/Users/CreateDate)[1]', 'datetime'), @UpdatedProdData.value('(/ArrayOfUsers/Users/LastLoginDate)[1]', 'datetime'), @UpdatedProdData.value('(/ArrayOfUsers/Users/LastLockOutDate)[1]', 'datetime'), @UpdatedProdData.value('(/ArrayOfUsers/Users/FailedPasswordAttempts)[1]', 'int'), @UpdatedProdData.value('(/ArrayOfUsers/Users/RoleId)[1]', 'int') Now this SP creates just fine. It's when I go to VS2010 and try to drag this SP in my method panel of my linq to sql file in design view. It tells me that it can't figure out the return type. I try to go to the properties but it does not have "none" as a choice and I can't type it in. It should be "none" so how do I set it to "none"?

    Read the article

  • form_for with json return

    - by Lowgain
    I currently have a form like this: <% form_for @stem, :html => {:multipart => true} do |f| %> <%= f.file_field :sound %> <% end %> This outputs (essentially): <form method="post" id="new_stem" class="new_stem" action="/stems"> <input type="file" size="30" name="stem[sound]" id="stem_sound"> </form> However I'm planning to use jQuery's ajaxForm plugin here and would like the new stem to be returned in JSON format. I know if the form's action was "/stems.json" this would work, but is there a parameter I can put into the form_for call to ask it to return JSON? I tried doing <% form_for @stem, :html => {:multipart => true, :action => '/stems.json'} do |f| %> but this didn't appear to work.

    Read the article

  • JDBC going to the wrong address

    - by DCSoft
    When I try and connect it my mysql database with JDBC in java, it doesn't go to my web server. Here is the code String dbtime; String dbUrl = "jdbc:mysql://184.172.176.18:3306/dcsoft_dcsoft_balloon"; String dbUser = "myuser"; String dcPass = "mypass"; String dbClass = "com.mysql.jdbc.Driver"; String query = "Select * FROM users"; try { Class.forName("com.mysql.jdbc.Driver"); Connection con = DriverManager.getConnection(dbUrl, dbUser, dcPass); Statement stmt = con.createStatement(); ResultSet rs = stmt.executeQuery(query); while (rs.next()) { dbtime = rs.getString(1); System.out.println(dbtime); } //end while con.close(); } //end try catch(ClassNotFoundException e) { e.printStackTrace(); } catch(SQLException e) { e.printStackTrace(); } This code is supposed to go to my web server but it gives this error java.sql.SQLException: Access denied for user 'dcsoft_dcsoft_java'@'jamesposse.force9.co.uk' (using password: YES) jamesposse.force9.co.uk is the not the address im trying to connect to I'm trying to connect to 184.172.176.18:3306. Thanks.

    Read the article

  • Execute function by pressing "return" using jQuery?

    - by Axel
    Hi, i have two text inputs like the following, i don't want to use <form> , so i want when people press "return" after filling the inputs, a function called "doit()" should be executed. <script> function doit(){ alert("you submitted the info"); ..........ajax code........ } </script> <input type="text" id="email" /> <input type="text" id="skills" /> Thanks

    Read the article

  • Return a function from the anonymous wrapper?

    - by sabithpocker
    I am trying to undrstand the code for(var i = 0; i < 10; i++) { setTimeout((function(e) { return function() { console.log(e); } })(i), 1000) } from here http://bonsaiden.github.com/JavaScript-Garden/#function.closures I understood this method : for(var i = 0; i < 10; i++) { (function(e) { setTimeout(function() { console.log(e); }, 1000); })(i); } Can anyone please help me by explaining the first one?

    Read the article

  • How to return an enum ID instead of the enum text in WebAPI

    - by Rodney
    I am using the WebAPI with .NET 4.5. I have a enum called DareStatus which is a list of statuses and their corresponding integer ID's. To minimize bandwidth traffic I want to send the int values of the enums, not the full text as it is currently doing. (I have control over the client so I can map it on the clientside). The strange thing is that in my RTFM-ing everyone seems to have the opposite issue! http://www.ftter.com/desktopmodules/framework/api/dare/getalldares public enum DareStatus : int { All = 0, Accepted = 2, Pending = 1, Declined = 3, Cancelled = 4, Failed = 5, Won = 6 } public IEnumerable<DareInfo> GetDares() { IEnumerable<DareInfo> dareInfos; using (IDataContext ctx = DataContext.Instance()) { var rep = ctx.GetRepository<DareInfo>(); dareInfos = rep.Get(); } return dareInfos; }

    Read the article

  • Partial coverage of a return statement in C++/CLI

    - by brickner
    I have C++/CLI code and I'm using Visual Studio 2008 Team Suite Code Coverage. The code header: // Library.h #pragma once #include <string> using namespace System; namespace Library { public ref class MyClass { public: static void MyFoo(); static std::string Foo(); }; } The code implementation: #include "Library.h" using namespace Library; using namespace System; void MyClass::MyFoo() { Foo(); } std::string MyClass::Foo() { return std::string(); } I have a C# unit test, that calls MyClass.MyFoo(): [TestMethod] public void TestMethod1() { Library.MyClass.MyFoo(); } For some reason, I don't get a full code coverage for MyClass. The Foo() method has 3 uncovered blocks and 5 covered blocks. The closing curly brackets (}) are marked in orange - partially covered. I have no idea why is it partially covered instead of fully covered, and this is my question.

    Read the article

  • Select from parent table return ID = 0 column values for child objects

    - by SaD
    Entities: public class Person { public Person(){} public virtual long ID { get; set; } } public class Employee : Person { public Employee(){} public virtual long ID { get; set; } public virtual string Appointment { get; set; } } Mappings: public class PersonMap : ClassMap<Person> { public PersonMap() { Id(x => x.ID) .GeneratedBy.Identity(); } } public class EmployeeMap : SubclassMap<Employee> { public EmployeeMap() { KeyColumn("ID"); Map(x => x.Appointment) .Not.Nullable() .Length(50); } } 2 items in Person table 1 item in Employee table (1 in base class, 1 in child class) Query:var list = Session.CreateQuery("from Person").List<Person>(); Return: 0 | ID = 1 1 | ID = 0, Appointment = "SomeAppointment"

    Read the article

  • Return Integer value from SSIS execute SQL Task

    - by Bokhari
    I am using SQL Server 2005 Business Intelligence Studio and struggling with returning an integer value from a very simple execute SQL Task. For a very simple test, I wrote the SQL Statement as: Select 35 As 'TotalRecords' Then, I specified ResultSet as ResultName = TotalRecords and VariableName = User::TotalRecords When I execute this, the statement is executed but the variable doesn't have the updated value. However, it has the default value that I specified while variable definition. The return of a date variable works, but integer variable isn't working. The type of User::TotalRecords specified is Int32 in a package scope. Thanks for any hints

    Read the article

  • My Delphi 7 application halts on Application.Initialize and does not return to next line

    - by m-abdi
    I have created an application on Delphi 7. my app had running fine since yesterday. I don't know what's happened yesterday which cause my application halts on Application.Initialize line in source code and does not return to next line when i trace the program. I can't run the created executable file from widows niether while the generated file does run on another machine correctly. here is the code where the compiler stops on it: program Info_Kiosk; uses SysUtils, Forms, ... (some other units) ; {$R *.res} begin Application.Initialize; Application.CreateForm(Tfrm_Main, frm_Main); any help would be appreciated

    Read the article

  • "Address of" (&) an array / address of being ignored be gcc?

    - by dbarbosa
    Hi, I am a teaching assistant of a introductory programming course, and some students made this type of error: char name[20]; scanf("%s",&name); which is not surprising as they are learning... What is surprising is that, besides gcc warning, the code works (at least this part). I have been trying to understand and I wrote the following code: void foo(int *str1, int *str2) { if (str1 == str2) printf("Both pointers are the same\n"); else printf("They are not the same\n"); } int main() { int test[50]; foo(&test, test); if (&test == test) printf("Both pointers are the same\n"); else printf("They are not the same\n"); } Compiling and executing: $ gcc test.c -g test.c: In function ‘main’: test.c:12: warning: passing argument 1 of ‘foo’ from incompatible pointer type test.c:13: warning: comparison of distinct pointer types lacks a cast $ ./a.out Both pointers are the same Both pointers are the same Can anyone explain why they are not different? I suspect it is because I cannot get the address of an array (as I cannot have & &x), but in this case the code should not compile.

    Read the article

  • Return result of block passed to #scan during regex

    - by Oli
    I've searched and not been able to find the right way of doing what I'm trying to. I read a file line by line and want to create a new object from a regex on each line. I'm not using an XML parser because the data is not well formed and listed below is all I need to get from each line. I can't seem to get scan to return the result of the block. It just returns the original string. I have temporarily gotten around it by creating this temp variable, but I'm sure there is a better way. enum = File.foreach(filename) enum.map do |line| temp = nil line.scan(/<cab id="(\w+)" updates="(\d+)"/) { |a,b| temp = Cab.new(a,b) } temp end Thanks for any help.

    Read the article

  • Indexing a method return (depending on Internationalization)

    - by Hedde
    Consider a django model with an IntegerField with some choices, e.g. COLORS = ( (0, _(u"Blue"), (1, _(u"Red"), (2, _(u"Yellow"), ) class Foo(models.Model): # ...other fields... color = models.PositiveIntegerField(choices=COLOR, verbose_name=_(u"color")) My current (haystack) index: class FooIndex(SearchIndex): text = CharField(document=True, use_template=True) color = CharField(model_attr='color') def prepare_color(self, obj): return obj.get_color_display() site.register(Product, ProductIndex) This obviously only works for keyword "yellow", but not for any (available) translations. Question: What's would be a good way to solve this problem? (indexing method returns based on the active language) What I have tried: I created a function that runs a loop over every available language (from settings) appending any translation to a list, evaluating this against the query, pre search. If any colors are matched it converts them backwards into their numeric representation to evaluate against obj.color, but this feels wrong.

    Read the article

  • Return segmented average from SQL Query?

    - by Guillaume Filion
    Hi, I measure the load on DNS servers every minute and store that into an SQL DB. I want to draw a chart of the load for the last 48 hours. That's 69120 (48*24*60) data points but my chart's only 800 pixels wide so to make things faster I would like my SQL query to return only ~800 data points. It's seems to me like a pretty standard thing to do, but I've been searching the web and in books for such a thing for a while now and the closest I was able to find was a rolling average. What I'm looking for a more of a "segmented average": divide the 69120 data points in ~800 segments, then average each segment. My SQL table is: CREATE TABLE measurements ( ip int, measurement_time int, queries int, query_time float ) My query looks like this SELECT ip, queries FROM measurements WHERE measurement_time>(time()-172800) Thanks a lot!

    Read the article

  • Windows batch file: Pipe destroys my return code

    - by murxx
    Hi, is it possible to return the errorlevel also if I pipe the output of a script into a logfile: test1.bat: call test2.bat 2>&1 | tee log.txt echo ERRORLEVEL: %ERRORLEVEL% test2.bat: exit /B 1 Output when calling test1.bat: ERRORLEVEL: 0 The errorlevel is always 0. The problem is, I want to call another script inside my script where the output should be redirected synchronously with the output shown in the command line, therefore a simple is not enough for me. I tried several ideas, but result is that the pipe always seems to destroy the given error-level... :( Can you give me any further suggestions? Thanks in advance... :)

    Read the article

  • C++ return type overload hack

    - by aaa
    I was bored and came up with such hack (pseudocode): 1 struct proxy { 2 operator int(); // int function 3 operator double(); // double function 4 proxy(arguments); 5 arguments &arguments_; 6 }; 7 8 proxy function(arguments &args) { 9 return proxy(args); 10 } 11 int v = function(...); 12 double u = function(...); is it evil to use in real code?

    Read the article

  • how to return static variable PHP

    - by GOsha
    function build_path($cid) { static $fr=array(); $DB = new MySQLTable; $DB->TblName = 'shop_categories'; $where['cat_id']['='] = $cid; $res = $DB->Select('cat_id,cat_name,cat_parent', $where); if($res !== false) { $pid = mysql_fetch_array($res); if($pid['cat_parent'] !== "0") { $fr[] = $pid['cat_id']; build_path($pid['cat_parent']); } else { $fr[] = $cid; $fr = array_reverse($fr); print_r($fr); return $fr; } } } print_r(build_path(100)); Why is working print_r in function, but second print_r returns NULL?

    Read the article

< Previous Page | 89 90 91 92 93 94 95 96 97 98 99 100  | Next Page >