Search Results

Search found 9706 results on 389 pages for 'aggregate functions'.

Page 30/389 | < Previous Page | 26 27 28 29 30 31 32 33 34 35 36 37  | Next Page >

  • Defined variables and arrays vs functions in php

    - by Frank Presencia Fandos
    Introduction I have some sort of values that I might want to access several times each page is loaded. I can take two different approaches for accessing them but I'm not sure which one is 'better'. Three already implemented examples are several options for the Language, URI and displaying text that I describe here: Language Right now it is configured in this way: lang() is a function that returns different values depending on the argument. Example: lang("full") returns the current language, "English", while lang() returns the abbreviation of the current language, "en". There are many more options, like lang("select"), lang("selectact"), etc that return different things. The code is too long and irrelevant for the case so if anyone wants it just ask for it. Url The $Url array also returns different values depending on the request. The whole array is fully defined in the beginning of the page and used to get shorter but accurate links of the current page. Example: $Url['full'] would return "http://mypage.org/path/to/file.php?page=1" and $Url['file'] would return "file.php". It's useful for action="" within the forms and many other things. There are more values for $Url['folder'], $Url['file'], etc. Same thing about the code, if wanted, just request it. Text [You can skip this section] There's another array called $Text that is defined in the same way than $Url. The whole array is defined at the beginning, making a mysql call and defining all $Text[$i] for current page with a while loop. I'm not sure if this is more efficient than multiple calls for a single mysql cell. Example: $Text['54'] returns "This is just a test array!" which this could perfectly be implemented with a function like text(54). Question With the 3 examples you can see that I use different methods to do almost the same function (no pun intended), but I'm not sure which one should become the standard one for my code. I could create a function called url() and other called text() to output what I want. I think that working with functions in those cases is better, but I'm not sure why. So I'd really appreciate your opinions and advice. Should I mix arrays and functions in the way I described or should I just use funcions? Please, base your answer in this: The source needs to be readable and reusable by other developers Resource consumption (processing, time and memory). The shorter the code the better. The more you explain the reasons the better. Thank you PS, now I know the differences between $Url and $Uri.

    Read the article

  • How to avoid nested functions when using AJAX?

    - by Fletcher Moore
    Sequential Asynchronous calls are gross. Is there a more readable solution? The problem is this is hard to follow: ajaxOne(function() { // do something ajaxTwo(function() { // do something ajaxThree() }); }); where the anonymous functions are callbacks that are called on server response. I'm using a third party API to make the AJAX calls, so I need a generic solution.

    Read the article

  • Enable clipboard functions in swf generated by pdf2swf.

    - by user515
    I am using pdf2swf (http://www.swftools.org/) to convert PDF's to .swf. I have written a flex application that loads the swf generated by pdf2swf. I want to enable select , copy and paste functions on the loaded swf. Is there a way to do this. Please note I am able to extract the text from the loaded swf using textSnapshot, which means the pdf2swf does not convert the text to shapes.

    Read the article

  • Union results of two functions in php class

    - by Max
    I have php class(simple example): <?php class test{ public function __construct() { //some code } public function __destruct() { //some code } public function echo1 { //some code return 1; } public function echo2 { //some code return 2; } } How could I return results of this two functions echo1 and echo2 in class in one row don't creating two new objects for each function?

    Read the article

  • Adding procedural C openGL functions to an iPhone project

    - by user309595
    I want to add a few drawing functions to an iPhone project for drawing things. Something like drawTile(x,y,len,wid); which would call openGL to draw a box somewhere. I should just be able to write a procedural C file to do this but the openGL libraries are objective C and I'm getting weird errors. Do I have to make a class for all of my drawing commands and call class methods?

    Read the article

  • How do I assign functions in a dictionary?

    - by Ziv
    hi, I'm having a problem with a simple program I wrote, I want to perform a certain function according to the users input. I've already used a dictionary as a replacement for a switch to do assignment but when I try to assign functions to the dictionary it doesn't execute them... The code: def PrintValuesArea(): ## do this def PrintValuesLength(): ## do that def PrintValuesTime(): ## do third PrintTables={"a":PrintValuesArea,"l":PrintValuesLength,"t":PrintValuesTime} PrintTables.get(ans.lower()) ## ans is the user input what did I do wrong? It looks the same as all the examples I've seen....

    Read the article

  • Database: Pipelined Functions

    - by Rachel
    I am new to the concept of Pipeline Functions. I have some questions regarding From Database point of view: What actually is Pipeline function ? What is the advantage of using Pipeline Function ? What challenges are solved using Pipeline Function ? Are the any optimization advantages of using Pipeline Function ? Thanks.

    Read the article

  • Using functions and environments

    - by Eduardo Leoni
    Following the recent discussions here (e.g. 1, 2 ) I am now using environments in some of my code. My question is, how do I create functions that modify environments according to its arguments? For example: y <- new.env() with(y, x <- 1) f <- function(env,z) { with(env, x+z) } f(y,z=1) throws Error in eval(expr, envir, enclos) : object 'z' not found I am using environments to keep concurrently two sets of simulations apart (without refactoring my code, which I wrote for a single set of experiments).

    Read the article

  • C# work with functions

    - by gloris
    Hi, I'am new with C#. How works in C# functions? My try: private void Form1_Load(object sender, EventArgs e) { MessageBox.Show(Convert.ToString(number_p(5))); } public void number_p(int number) { int one = 1; number = number + one; return number; } Error: return, why? Thanks

    Read the article

  • JavaScript Self Executing Functions - What's the Difference?

    - by modernzombie
    I am very familiar with self executing functions from working with jQuery. (function($) { /* do stuff */ })(jQuery); Today I was reading the backbone.js source and noticed that they do this: (function() { /* do stuff */ }).call(this); Is this achieving the same thing? Would the following 2 lines of code do the same thing? (function($) { /* do stuff */ })(jQuery); (function($) { /* do stuff */ }).call(jQuery);

    Read the article

  • referencing desired objects in namespaced functions

    - by RyOnLife
    I'm having trouble referencing the desired object when I've namespaced functions. No problems here: obj.test = function() { // this == obj } But I'm getting tripped up when I namespace: obj.namespace.test = function() { // this == namespace } In the latter example, I know this references namespace, but I want to reference obj. How can I do it?

    Read the article

  • Documenting functions in C++ with Doxygen

    - by Paul
    I've got a project that I'm using Doxygen to generate documentation to. The documentation of the classes is fine, but I've also got some functions that I use in main() to create objects etc. I'd also like to have these into my documentation, but I have not figured how to do that. Any suggestions?

    Read the article

  • Manipulating matrix operations (transpose, negation, addition, and mutiplication) using functions in

    - by user292489
    I was trying to manipulate matrices in my input file using functions. My input file is: A 3 3 1 2 3 4 5 6 7 8 9 B 3 3 1 0 0 0 1 0 0 0 1 C 2 3 3 5 8 -1 -2 -3 D 3 5 0 0 0 1 0 1 0 1 0 1 0 1 0 0 1 E 1 1 10 F 3 10 1 0 2 0 3 0 4 0 5 0 0 2 3 -1 -3 -4 -3 8 3 7 0 0 0 4 6 5 8 2 -1 10 I am having trouble in implementing the functions that I declared. I assumed my program will perform those operations: transpose, negate, add, and multiply matices according to the users choice: /* once this program is compiled and executed, it will perform the basic matrix * operations: negation, transpose, addition, and multiplication. */ #include <stdio.h> #include <stdlib.h> #define MAX 10 int readmatrix(FILE *input, char martixname[6],int , mat[10][10], int i, int j); void printmatrix(char matrixname[6], int mat[10][10], int i, int j); void Negate(char matrixname[6], int mat[10][10], int i, int j); void add(char matrixname[6], int mat[10][10],int i, int k); void multiply(char matrixname[], int mat[][10], char A[], int i, int k); void transpose (char matrixname[], int mat[][10], char A[], int); void printT(int mat[][10], int); int selctoption(); char selectmatrix(); int main(int argc, char *argv[]) { char matrixtype[6]; int mat[][10]; FILE *filein; int size; int optionop; int matrixop; int option; if (argc != 2) { printf("Usage: executable input.\n"); exit(0); } filein = fopen(argv[1], "r"); if (!filein) { printf("ERROR: input file not found.\n"); exit (0); } size = readmatrix (filein, matrixtype); printmatrix(matrix[][10], size); option = selectoption(); matrixtype = selectmatrix(); //printf("You have: %5.2f ", deposit); optionop = readmatrix(option, matrix[][10], size); if (choiceop == 6) { printf("Thanks for using the matrix operation program.\n"); exit(0); } printf("Please select from the following matrix operations:\n") printf("\t1. Print matrix\n"); printf("\t2. Negate matrix\n"); printf("\t3. Transpose matrix\n"); printf("\t4. Add matrices\n"); printf("\t5. Multiply matrices\n"); printf("\t6. Quit\n"); fclose(filein); return 0; } do { printf("Please select option(1-%d):", optionop); scanf("%d", &matrixop); } while(matrixop <= 0 || matrixop > optionop); void readmatrix (FILE *in, int mat[][10], char A[], int i, int j) { int i=0,j = 0; while (fscanf(in, "%d", &mat[i][j]) != EOF) return 0; } // I would appreciate anyone's feedback.

    Read the article

  • Functions connected to signals in QtScript (on Qt 4.5.2) are not firing

    - by Cody Brocious
    I've injected into a proprietary Qt (4.5.2) application, added my own compatible build of QtScript, and have managed to get access to all the signals I need. However, when connecting to them (via QtScript) my functions are never called. I've come up with a few theories for why this is and I've tested everything I can think of, but I've hit a bit of a wall. Note, I've never had any connection exceptions whatsoever. Here are my current theories: The signals I'm connecting to are already connected to other slots, and that's somehow blocking it (but as far as I know, all Qt signals fire to all slots with no extra work, and can't be restricted in this way) The signals are rejecting my connection, or disconnecting me after connection (but I see no facility for this) My connection is happening from another thread, and this is somehow causing it not to connect properly Are any of these theories plausible? If not, what have I missed?

    Read the article

  • tolua++: Adding lua functions to a C++ class that has been exported to Lua

    - by skyeagle
    I am using tolua++ to export some C++ classes to Lua. My understanding that each class is 'implemented' on the lua side, as a lua table. I am wondering if it is possible therefore, to add new (Lua) methods to the C++ object table so that I can achieve the effect of adding new methods to the C++ class. Assume that I am exporting the class Foobar. Methods of Foobar will be accessisble in Lua as follows: Foobar:method1() Foobar:method2() ... etc. I would like to be able to add new methods (newmethod1, and newmethod2) to the Foobar table "object" I have the following questions: Is it possible to 'extend' the functionality of an exported C++ object in the manner I described above? How would one go about add new functions to the Foobar table? (I am relatively new to Lua)

    Read the article

  • F# List of functions

    - by akaphenom
    I am trying to have a list of functions, but seem to be comming up empty handed. The basic code is something like this: let doSomething var = var let doSomething2 var = var let listOfStuff = [doSomething doSomething2] and I am getting the followiung exception: Error 2 Value restriction. The value 'listOfStuff' has been inferred to have generic type val queue : ('_a - '_a) list Either define 'queue' as a simple data term, make it a function with explicit arguments or, if you do not intend for it to be generic, add a type annotation. C:\fsharp\SentimentFramework\TradeSignalProcessor\Program.fs 16 9 TradeSignalProcessor I tried addin the [] attribute but that didn't work...

    Read the article

  • How can I use Functions in VB.NET that's not in App_code

    - by megatoast
    I am currently working with an IPhone API which consist of about 40 pages of aspx along with their respective aspx.vb pages. They are all partial classes because the API continues to add other phone platforms to it. Currently I have them residing just in a folder. /API/0.1 and /API/1.0 ... How would I call the functions from those IPhone API classes without having to put them in the App_code? example: I have a partial class SetTextBroadcast with a function like this Function BroadcastMessage(ByVal Brodcast_recipient() As net.pmgateway.Recipient, ByVal str_Message As String) As net.pmgateway.Reply 'code here End Function How do i use that function in a webform? or do I need to put it in App_Code? something like this is what i'm looking for. Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Dim objSetTextBroadCast as new SetTextBroadCast() End Sub but i get type "SetTextBroadCast" not defined. thanks for your help

    Read the article

< Previous Page | 26 27 28 29 30 31 32 33 34 35 36 37  | Next Page >