parameter-passing

Passing a string between pages in Windows Phone 8

北城余情 提交于 2019-11-29 02:18:34
I need to pass a simple string between two pages in Windows Phone 8. I've been searching around, trying to find the best way of doing it - but the ones i tried turned out to not work as they should - so i ask you: What is the best way to pass a simple string between two pages in Windows Phone 8. This is the method I use to navigate to the other page: NavigationService.Navigate(new Uri("/newpage.xaml", Urikind.Relative)); For a string variable, it's easiest to use a query string parameter: NavigationService.Navigate(new Uri("/newpage.xaml?key=value", Urikind.Relative)); Pick it up on the target

Passing two or more arrays to a Perl subroutine

随声附和 提交于 2019-11-28 23:34:27
I am having trouble passing and reading arguments inside subroutine which is expected to have two arrays. sub two_array_sum { # two_array_sum ( (1 2 3 4), (2, 4, 0, 1) ) -> (3, 6, 3, 5) # I would like to use parameters @a and @b as simply as possible } # I would like to call two_array_sum here and pass two arrays, @c and @d I have seen and tried several examples from the web, but none of them worked for me. There are two ways you can do this: by prototype by reference But before I discuss these--if what you show in your question is about the extent of what you want to do--let me suggest List:

AngularJS Directive Passing String

泪湿孤枕 提交于 2019-11-28 22:14:11
This directive is trying to create an HTML element called progress bar that tracks progress as you move page to page. I'm trying to develop it to be used as : <progress-bar progress='1' max='6' error="true"></progress-bar> I'm simply trying to pass the information from the ^^element in html to my directive and process the information to change the progress bar appropriately. This is working for "progress" and "max" which take integer values, but for some reason the commented out code, which would process "error" (which is a string) is causing problems. I'm new to angularJS so I'm sorry if any

How can I pass a Class as parameter and return a generic collection in Java?

若如初见. 提交于 2019-11-28 21:31:25
问题 I am designing a simple Data Access Object for my Java application. I have a few classes (records) that represents a single row in tables like User and Fruit . I would like to have a single method for getting all records of a specific type. For the moment I have it like this: public List<User> getAllUsers() { ... } public List<Fruit> getAllFruits() { ... } .... But I would like to have a single polymorphic method like this (wrong): public List<T> getAllRecords(Class<T> type) { if(type

What's the difference between call by reference and copy/restore

烈酒焚心 提交于 2019-11-28 21:27:38
What's the difference in the outcome between call by reference and copy/restore? Background: I'm currently studying distributed systems. Concerning the passing of reference parameters for remote procedure calls, the book states that: "the call by reference has been replaced by copy/restore. Although this is not always identical, it is good enough". I understand how call by reference and copy/restore work in principle, but I fail to see where a difference in the result may be? Examples taken from here . Main code: #include <stdio.h> int a; int main() { a = 3; f( 4, &a ); printf("%d\n", a);

How are C++11 lambdas represented and passed?

喜夏-厌秋 提交于 2019-11-28 21:08:15
Passing a lambda is really easy in c++11: func( []( int arg ) { // code } ) ; But I'm wondering, what is the cost of passing a lambda to a function like this? What if func passes the lambda to other functions? void func( function< void (int arg) > f ) { doSomethingElse( f ) ; } Is the passing of the lambda expensive? Since a function object can be assigned 0, function< void (int arg) > f = 0 ; // 0 means "not init" it leads me to think that function objects kind of act like pointers. But without use of new , then it means they might be like value-typed struct or classes, which defaults to

How to pass the value 'undefined' to a function with multiple parameters?

痴心易碎 提交于 2019-11-28 21:02:55
I want to pass the value of 'undefined' on a multiple parameter function but without omitting the parameter. What do I mean with "without omitting the parameter" . I mean that we should not just omit the parm2 like this example: function myFunction (parm1, parm2) {} myFunction("abc"); This will indeed make parm2 undefined, but I am not allowed to do it this way because I will need to specify other parameters AFTER the omitted parameter, so the previous method won't work in the case I want to make parm1 undefined BUT also want to have other parameters after this one to hold a value. I have

How do C++ compilers actually pass reference parameters?

倖福魔咒の 提交于 2019-11-28 20:41:15
This question came about as a result of some mixed-language programming. I had a Fortran routine I wanted to call from C++ code. Fortran passes all its parameters by reference (unless you tell it otherwise). So I thought I'd be clever (bad start right there) in my C++ code and define the Fortran routine something like this: extern "C" void FORTRAN_ROUTINE (unsigned & flag); This code worked for a while but (of course right when I needed to leave) suddenly started blowing up on a return call. Clear indication of a munged call stack. Another engineer came behind me and fixed the problem,

How to refresh a page with jQuery by passing a parameter to URL

ⅰ亾dé卋堺 提交于 2019-11-28 20:06:13
I am refreshing my page using jQuery: location.reload(); This is working great but I want to refresh the same page by passing a parameter to URL. How can I do this by using jQuery? Ex: If my url is www.myweb.com , I want to refresh this by passing a parameter like this www.myweb.com?single Thank you You should be able to accomplish this by using location.href if(window.location.hostname == "www.myweb.com"){ window.location.href = window.location.href + "?single"; } I would use REGEX with .replace like this: window.location.href = window.location.href.replace( /[\?#].*|$/, "?single" ); You can

Android: pass parameter to Service from Activity

為{幸葍}努か 提交于 2019-11-28 19:26:29
I'm binding to Service by this way: Activity class: ListenLocationService mService; @Override public void onCreate(Bundle savedInstanceState) { ... Intent intent = new Intent(this, ListenLocationService.class); intent.putExtra("From", "Main"); bindService(intent, mConnection, Context.BIND_AUTO_CREATE); ... } private ServiceConnection mConnection = new ServiceConnection() { public void onServiceConnected(ComponentName className, IBinder service) { LocalBinder binder = (LocalBinder) service; mService = binder.getService(); } public void onServiceDisconnected(ComponentName arg0) { } }; This is