function

Loading a class into a function ?

I`m currently working on a script, and I have the following situation. function somnicefunction() { require 'someexternalclass.php'; $somevar = new SomeExternalClass(); } For some reason, the above breaks the function. I'm not sure why, I haven't seen much documentation in php.net regarding this, plus google returned no real r...

Java variable function parameters

How do you duplicate this feature in Java? In C#, you could use the params keyword to specify variable parameter lists for functions. How do you do that in Java? Or do you have to resort to multiple overloads? ...

How to make this jquery function reusable?

Hai this is my jquery function, function getRecordspage(curPage, pagSize) { $.ajax({ type: "POST", url: "Default.aspx/GetRecords", data: "{'currentPage':" + curPage + ",'pagesize':" + pagSize + "}", contentType: "application/json; charset=utf-8", dataType: "json", success: function(jso...

error: default argument given for parameter 1

I'm getting this error message with the code below: class Money { public: Money(float amount, int moneyType); string asString(bool shortVersion=true); private: float amount; int moneyType; }; First I thought that default parameters are not allowed as a first parameter in C++ but it is allowed. ...

Function to hide sloppy phone numbers..

I need to hide phone numbers (and maybe other contact details) in user generated content to protect my users from anonymous web. Input is very random, therefore I'd be looking to replace anything that looks like a phone number (e.g.: string of 3 or more numbers) with just dots, and also perhaps remove some exotic notations of e-mail add...

Double indirection and structures passed into a function

I am curious why this code works: typedef struct test_struct { int id; } test_struct; void test_func(test_struct ** my_struct) { test_struct my_test_struct; my_test_struct.id=267; *my_struct = &my_test_struct; } int main () { test_struct * main_struct; test_func(&main_struct); printf("%d\n",main_struct->id); } This works, but...

c++ global operator not playing well with template class

ok, i found some similar posts on stackoverflow, but I couldn't find any that pertained to my exact situation and I was confused with some of the answers given. Ok, so here is my problem: I have a template matrix class as follows: template <typename T, size_t ROWS, size_t COLS> class Matrix { public: template<typename, ...

How to store a function pointer in C#

Let's say I want to store a group of function pointers in a List<(*func)>, and then later call them, perhaps even with parameters... Like if I stored in a Dict<(*func), object[] params> could I call the func with the parameters? How would I do this? ...

javascript summary function

Hello, im trying to make a small name summary function depending on the size of the elements container, here's what I have; function shorten_text(str, size){ size = size.match( /[0-9]*/ ); var endValue = Math.floor( Number(size) / 10 ); var number; var newStr; for ( number = 0; number <= endValue; number++ ) { ...

function pointer error

Can anybody help me with this simple code?? #include <iostream> using namespace std; void testFunction(){ cout<<"This is the test function 0"<<endl; } void testFunction1(){ cout<<"This is the test function 1"<<endl; } void testFunction2(){ cout<<"This is the test function 2"<<endl; } void (*fp[])()={testFunction,testFunc...

"Phased" execution of functions in javascript

Hey there! This is my first post on stackoverflow, so please don't flame me too hard if I come across like a total nitwit or if I'm unable ot make myself perfectly clear. :-) Here's my problem: I'm trying to write a javascript function that "ties" two functions to another by checking the first one's completion and then executing the se...

Jquery callback function executes over and over again...

This my jquery function, function getRecordspage(curPage, pagSize) { // code here $(".pager").pagination(strarr[1], { callback: function() { getRecordspage(2, 5);},current_page: curPage - 1, items_per_page:'5', num_display_entries: '5', next_text: 'Next', prev_text: 'Prev', num_edge_entries: '1' ...

Problem with asp.net function syntax (not returning values correctly)

I have an active directory search function: Function GetAdInfo(ByVal ADDN As String, ByVal ADCommonName As String, ByVal ADGivenName As String, ByVal ADStaffNum As String, ByVal ADEmail As String, ByVal ADDescription As String, ByVal ADTelephone As String, ByVal ADOffice As String, ByVal ADEmployeeID As String) As String Dim...

How to get SQL Function run a different query and return value from either query?

I need a function, but cannot seem to get it quite right, I have looked at examples here and elsewhere and cannot seem to get this just right, I need an optional item to be included in my query, I have this query (which works): SELECT TOP 100 PERCENT SKU, Description, LEN(CONVERT(VARCHAR (1000),Description)) AS LenDesc FROM tblItem WHER...

What is wrong with these jquery statements?

I cant able to get this jquery statement to work on page load but it works once when i refresh F5 the page..... <div id="ResultsDiv"> </div> <div id="pager" class="pager"> </div> <input id="HfId" type="hidden" /> <script type="text/javascript"> var itemsPerPage = 5; $(document).ready(function() { ...

How should I use try...except while defining a function?

Hi all, I find I've been confused by the problem that when I needn't to use try..except.For last few days it was used in almost every function I defined which I think maybe a bad practice.For example: class mongodb(object): def getRecords(self,tname,conditions=''): try: col = eval("self.db.%s" %tname) ...

How to get Function names

I want Function names from the call stack, how do i get Function names from it? as peek data doesn't return address of the stack. It is returned in GETREGS, how do i get my Functions name from these addresses? ...

How to execute a function called many times, only once !

Hello, is there a way to execute a function that is called thousand of times only once ? I have a function that adds items in a container of sort, and there is code in there, that updates lists and other windows (GUI staff). So, if i have to add a million items (the number of which is impossible to tell, anyone could call the function ...

Count all lists of adjacent nodes stored in an array.

There are many naive approaches to this problem, but I'm looking for a good solution. Here is the problem (will be implemented in Java): You have a function foo(int a, int b) that returns true if 'a' is "adjacent" to 'b' and false if 'a' is not adjacent to 'b'. You have an array such as this [1,4,5,9,3,2,6,15,89,11,24], but in reality h...

Python: re-initialize a function's default value for subsequent calls to the function.

I have a function that calls itself to increment and decrement a stack. I need to call it a number of times, and I'd like it to work the same way in subsequent calls but, as expected, it doesn't re-use the default value. I've read that this is a newbie trap and I've seen suggested solutions, but I haven't been able to make any soluti...