function

PHP - Function inside a Function. Good or bad?

I would like to know if it is a good thing to define a function inside another function in PHP. Isn't it better to define it before the function (and not inside) in terms of performances. ...

How do you get a PowerSoft report to resolve a PowerBuilder global function.

I currently work in an environment where reports must be emailed to users as a PowerSoft file. There is a global PowerBuilder function which is used on a computed column my datawindow. This datawindow becomes the final psr report. In my testing the function is resolved fine, when run live. However, when the user runs the report, it se...

Javascript Function With JQuery POST Always Returns undefined

Hi Everyone, I have no idea what's going on here and was hoping someone could help, I'm sure it's something easy going on that I'm just missing. I have a function in javascript that has a JQuery post inside of it. I would like to return the results of the post which is just text and put it in a variable. The number is coming back cor...

How to implement a "private/restricted" function in C?

I was asked a very interesting question during a C interview: How can you implement a function f() in such a way that it can only be called from a particular g() function. If a function other than g() tries to call f() it would result in a compiler error. At first, I though this could be done with function pointers and I could get close...

Passing an int array of variable length as a function parameter in Objective C

I have the following code which works fine... int testarr[3][3] = { {1,1,1}, {1,0,1}, {1,1,1} }; [self testCall: testarr]; Which calls this function: - (void)testCall: (int[3][3]) arr { NSLog(@"cell value is %u",arr[1][1]); } I need the array to be of variable length - What is the best way to declare the function? Us...

my session_start doesn't work :(

i start a new session with : session_start(); then i set some session variables like this : $_SESSION['name']=$_POST['name']; and some another variables. at bottom of page i set header to diffrent page : header('location: index.php'); exit(); now in new page (index.php i can't access to my session variables, like $_SESSION['name']) what...

Basic jQuery slideUp/slideDown help.

I was wondering if there was a function that I can add to this, that would show the data again, as in make it slide back down or something after a given set of time so you can go back and re-enter your data. It currently just slides up after submit, and then shows the text. $("#help").slideUp(function() { $("#help").before('<div class...

Dealing with multiple Javascript IF statements.

Is it possible to put multiple IF statements in Javascript? If so, I'm having a fair amount of trouble with the statement below. I was wondering if you can put another IF statement in between if (data == 'valid') AND else? I want to add another if data =='concept') between the two. if (data == 'valid') { $("#file").slideUp(function ...

Better way to architect this function?

I have a function that consists mainly of a massive amount of calls (50+) to another function which inserts data into an array, with logic here and there dictating various conditions to insert various items into the array (plus a little bit on the end that writes the contents of the array out to a file). I'm wondering if there isn't a be...

How can I make the Count function return 0?

I am trying to create a series of queries in Access that count the number of clients of each ethnicity in each of 77 counties. Here is SQL code for one of my queries that I'm trying to do this for... SELECT [ClientsByCounty-Asian].County, [ClientsByCounty-Asian].CountyName, Count([ClientsByCounty-Asian].Asian) AS CountOfAsian FROM [Cl...

MySQL Query with PHP function compare?

Hello, What I want to do is while executing MySQL query, passing column data into a PHP function and comparing the result with WHERE clause... Something like that, I have the slug() function which I wrote in PHP and my query will be something like; SELECT * FROM articles WHERE slug(author) = "james-taylor"; So the query will select ...

Making a form re-enabled after it has been disabled, using jQuery.

I currently have my code set to disable the submit button when the field is submitted. Is there a way I can make it re-enable the submit button later? The first half of my code. $("#segment").submit(function () { $(':submit').attr('disabled', 'disbled'); The second half of my code. if (data == 'success') { $("#se...

Calling a Function From a String With the Function's Name in Ruby

How can I do what they are talking about here, but in Ruby? How would you do the function on an object? and how would you do a global function (see jetxee's answer on the post mentioned)? EXAMPLE CODE: event_name = "load" def load() puts "load() function was executed." end def row_changed() puts "row_changed() function was execu...

Set function signature in Python

Suppose I have a generic function f. I want to programmatically create a function f2 that behaves the same as f, but has a customised signature. More detail Given a list l and and dictionary d I want to be able to: Set the non-keyword arguments of f2 to the strings in l Set the keyword arguments of f2 to the keys in d and the default...

How to declare a function during program execution?

This is something like Reflection where you can call a method simply by its name, and not a precompiled pointer to it. Like in JavaScript you can: var fun = function(){ alert("Hello World!"); } fun(); Is something like that possible in Java/J2ME? How? ...

pthread in a class

Hey everyone, considering the following code (compiled with g++ -lpthread thread_test.cpp) how can I know what number thread I am in from inside "thread_function"? And let me know if you have any other suggestions. Thanks! thread_test.cpp: #include <stdio.h> #include <stdlib.h> #include <pthread.h> #include <unistd.h> class A { p...

Converting "document.getElementById" into jQuery.

I've been thinking/searching for an equivalent of the problem that I am having below, and nothing could be found. Is there a way I can rewrite this to work with jQuery as an alternative? First half of the code. <a href="link.php?test=true" onclick="request(this)" target="_blank"> <a id="step2" href="javascript:alert('NOT FINISHED!');...

Local functions in Python

In the following Python code, I get an UnboundLocalError. As I understand it, local functions share the local variables of the containing function, but this hardly seems to be the case here. I recognise that a is an immutable value in this context, but that should not be a problem. def outer(): a = 0 def inner(): a += 1 ...

Unnesting parentheses in Lisp

I want to write code (using recursive function) to unnest the parentheses in a LIST in Lisp language. Example: (unnest '(1 (2 (3)) (4 5))) ==> (1 2 3 4 5) Thanks. Any help is appreciated! ...

What are some of the more practical uses you've applied for jQuery's data() method?

As the question pretty much sums up, I'm doing a presentation on some of the more "hidden" aspects of jQuery, including the data() function. I'm quite comfortable with how the function works, but am struggling to come up with enough actual usage examples outside of basic setting / getting and identifying the events bound to an element. ...