Search Results

Search found 39207 results on 1569 pages for 'foreign function interfac'.

Page 8/1569 | < Previous Page | 4 5 6 7 8 9 10 11 12 13 14 15  | Next Page >

  • How to structure javascript callback so that function scope is maintained properly

    - by Chetan
    I'm using XMLHttpRequest, and I want to access a local variable in the success callback function. Here is the code: function getFileContents(filePath, callbackFn) { var xhr = new XMLHttpRequest(); xhr.onreadystatechange = function() { if (xhr.readyState == 4) { callbackFn(xhr.responseText); } } xhr.open("GET", chrome.extension.getURL(filePath), true); xhr.send(); } And I want to call it like this: var test = "lol"; getFileContents("hello.js", function(data) { alert(test); }); Here, test would be out of the scope of the callback function, since only the enclosing function's variables are accessible inside the callback function. What is the best way to pass test to the callback function so the alert(test); will display test correctly?

    Read the article

  • ASP.NET (VB) - Close an opened SQL connection inside Function

    - by B1GB0Y
    Can anyone tell me how I close an opened SQL connection inside a Function? I call a Select Function like this: Function Selec(ByVal SQLStr As String) As SqlDataReader Dim SQLConn As New SqlConnection() Dim SQLCmd As New SqlCommand() SQLConn.ConnectionString = Session("bd") SQLConn.Open() SQLCmd.Connection = SQLConn SQLCmd.CommandText = SQLStr Selec = SQLCmd.ExecuteReader End Function And in another page I do a While method to retrieve me the data like this: (Note: BDcon.BD is the name of the Class that have Functions) Dim write as New BDcon.BD Dim menu As SqlDataReader = writeBD.Selec("SELECT something from Table") While menu.Read 'Do something End While menu.Close 'This close just the DataReader and not the SqlConnection Finally I want to Close my SQL Connection by Function like this: Function Close() As SqlConnection Dim SQLConn As New SqlConnection() SQLConn.ConnectionString = Session("bd") SQLConn.Close() End Function I think that the problem is on the Close() Function, I want to close the connection but I don't know how to call my Opened Conneciton. Please anyone can help me? Thanks in advance :)

    Read the article

  • PHP Commercial Project Function define

    - by Shiro
    Currently I am working with a commercial project with PHP. I think this question not really apply to PHP for all programming language, just want to discuss how your guys solve it. I work in MVC framework (CodeIgniter). all the database transaction code in model class. Previously, I seperate different search criteria with different function name. Just an example function get_student_detail_by_ID($id){} function get_student_detail_by_name($name){} as you can see the function actually can merge to one, just add a parameter for it. But something you are rushing with project, you won't look back previously got what similar function just make some changes can meet the goal. In this case, we found that there is a lot function there and hard to maintenance. Recently, we try to group the entity to one ultimate search something like this function get_ResList($is_row_count=FALSE, $record_start=0, $arr_search_criteria='', $paging_limit=20, $orderby='name', $sortdir='ASC') we try to make this function to fit all the searching criteria. However, our system getting bigger and bigger, the search criteria not more 1-2 tables. It require join with other table with different purpose. What we had done is using IF ELSE, if(bla bla bla) { $sql_join = JOIN_SOME_TABLE; $sql_where = CONDITION; } at the end, we found that very hard to maintance the function. it is very hard to debug as well. I would like to ask your opinion, what is the commercial solution they solve this kind of issue, how to define a function and how to revise it. I think this is link project management skill. Hope you willing to share with us. Thanks.

    Read the article

  • JavaScript Loop and wait for function

    - by Fluidbyte
    I have a simple single-dimension array, let's say: fruits = ["apples","bananas","oranges","peaches","plums"]; I can loop thru with with $.each() function: $.each(fruits, function(index, fruit) { showFruit(fruit); }); but I'm calling to another function which I need to finish before moving on to the next item. So, if I have a function like this: function showFruit(fruit){ $.getScript('some/script.js',function(){ // Do stuff }) } What's the best way to make sure the previous fruit has been appended before moving on?

    Read the article

  • Why can't I call this function (javascript/jquery)

    - by Ankur
    This is driving me nuts .... I have written a function function seraliseQuery(){ for(var i=1; i<=variables;i++){ alert(queryPreds[i]+" - "+queryObjs[i]); } } I just want to be able to call it from my other function $(".object").click( function() { // code removed seraliseQuery(); }); The error I get is "the function serialiseQuery() is undefined". Everything is within $(document).ready( function() { // code goes here }

    Read the article

  • Pointer to a C++ class member function as a global function's parameter?

    - by marcin1400
    I have got a problem with calling a global function, which takes a pointer to a function as a parameter. Here is the declaration of the global function: int lmdif ( minpack_func_mn fcn, void *p, int m, int n, double *x, double *fvec, double ftol) The "minpack_func_mn" symbol is a typedef for a pointer to a function, defined as: typedef int (*minpack_func_mn)(void *p, int m, int n, const double *x, double *fvec, int iflag ); I want to call the "lmdif" function with a pointer to a function which is a member of a class I created, and here is the declaration of this class function: int LT_Calibrator::fcn(void *p, int m, int n, const double *x, double *fvec,int iflag) I am calling a global function like this: info=lmdif(&LT_Calibrator::fcn, 0, m, n, x, fvec, ftol) Unfortunately, I get a compiler error, which says: "error C2664: 'lmdif' : cannot convert parameter 1 from 'int (__thiscall LT_Calibrator::* )(void *,int,int,const double *,double *,int)' to 'minpack_func_mn' 1 There is no context in which this conversion is possible" Is there any way to solve that problem?

    Read the article

  • Create a callback function within a custom jQuery function

    - by Thomas
    I'm not sure how to approach this as I am fairly new to jQuery. I'm wanting to create a callback function within a custom function. Here's my example: function doSomething() { var output = 'output here'; // Do something here // This is where I want to create the callback function and pass output as a parameter } I want the callback function to be accessible by any number of scripts (e.g. more than one script can access this callback). This function (doSomething) is not part of a plugin but rather part of another callback function itself. I've also created a var within the function and want to pass that through the callback function as well. How can I do this?

    Read the article

  • Undefined function in php

    - by Bidyut
    I wrote three methods in a class and one is calling another, but when I call the function outside through the object, it is showing an undefined function error for the second function. Here's my code: function resize_image(){ } function image_resize(){ $a = resize_image(); } When I run this, it shows resize_image() as undefined. Here's the error: Fatal error: Call to undefined function resize_image() in /home/vacayge/public_html/Major/Alpha1/classes/cUserImages.php on line 2090

    Read the article

  • Actionscript: Switching back into previous function from event handler function

    - by J.Ded.
    I need to return to my original function after capturing an event (downloading something) with another function. The original function needs to return a value, which depends on the downloaded data. So, I'd like to pause original function for the time needed for the download and the eventhandler function to complete it's work, and resume it afterwards. The obvious way is to set a flag value (both the original function and the eventhandler are within the same class) and make the original function check it until the eventhandler function changes the flag. But that would be wasteful, and my AS is slow enough already:) [other parts of the application utilise some heavy graphics]. Is there another way? Like an event that gets captured "in the middle" of the function? Or some other form of flow control?

    Read the article

  • Caller property of JS for "foo = function()" style of coding

    - by arvind
    I want to use the property of "caller" for a function which is defined here It works fine for this style of function declaration function g() { alert(g.caller.name) // f } function f() { alert(f.caller.name) // undefined g() } f() JSfiddle for this But then my function declaration is something like g = function() { alert(g.caller.name) // expected f, getting undefined } f = function() { alert("calling f") alert(f.caller.name) // undefined g() } f() and I am getting undefined (basically not getting anything) JSfiddle for this Is there any way that I can use the caller property without having to rewrite my code? Also, I hope I have not made any mistakes in usage and function declaration since I am quite new to using JS.

    Read the article

  • R programming function without ()

    - by Mark Kennedy
    So, I Have the following very simple map.r file. I'm trying to have the user type "click" in interactive mode and then have the function . Since it's a function, the user has to type "click()" how can I make it so that they only have to the word (w/o parentheses), and then have that function do something with the img. So the user types: mydist("image.pnm") click //And then the function click does what it's supposed to mydist <- function(mapfile) { img <- read.pnm(mapfile) plot(img) } click <- function() { //Prompt user to click on img }

    Read the article

  • How to put foreign key constraints on a computed fields in sql server?

    - by Asaf R
    Table A has a computed field called Computed1. It's persisted and not null. Also, it always computes to an expression which is char(50). It's also unique and has a unique key constraint on it. Table B has a field RefersToComputed1, which should refer to a valid Computed1 value. Trying to create a foreign key constraint on B's RefersToComputed1 that references A' Computed1 leads to the following error: Error SQL01268: .Net SqlClient Data Provider: Msg 1753, Level 16, State 0, Line 1 Column 'B.RefersToComputed1' is not the same length or scale as referencing column 'A.Computed1' in foreign key 'FK_B_A'. Columns participating in a foreign key relationship must be defined with the same length and scale. Q: Why is this error created? Are there special measures needed for foreign keys for computed columns, and if so what are they? Summary: The specific problem rises from computed, char based, fields being varchar. Hence, Computed1 is varchar(50) and not char(50). It's best to have a cast surrounding a computed field's expression to force it to a specific type. Credit goes to Cade Roux for this tip.

    Read the article

  • Database design and foreign keys: Where should they be added in related tables?

    - by Carvell Fenton
    I have a relatively simple subset of tables in my database for tracking something called sessions. These are academic sessions (think offerings of a particular program). The tables to represent a sessions information are: sessions session_terms session_subjects session_mark_item_info session_marks All of these tables have their own primary keys, and are like a tree, in that sessions have terms, terms have subjects, subjects have mark items, etc. So each on would have at least its "parent's" foreign key. My question is, design wise is it a good idea to include the sessions primary key in the other tables as a foreign key to easily select related session items, or is that too much redundency? If I include the session foreign key (or all parent foreign keys from tables up the heirarchy) in all the tables, I can easily select all the marks for a session. As an example, something like SELECT mark FROM session_marks WHERE sessionID=... If I don't, then I would have to combine selects with something like WHERE something IN (SELECT... Which approach is "more correct" or efficient? Thanks in advance!

    Read the article

  • Laptop Function Key Dysfunctional

    - by Kanini
    My laptop has Windows Vista installed in it. Everytime, I switch on the computer, the function key seems to be enabled automatically. So, when I press i, 5 is displayed and so on and so forth. Now, I have checked and ensured that Function is key is not locked due to a faulty keyboard or coke spilling on it and suchlike. I am able to get out of it with the following key combination Fn + Ctrl + Ins (Num Lk) However, the next time I switch on my PC, the Function key is automatically enabled. Also, if my computer goes to sleep mode and comes back, it is enabled again. Anything that I can do to change this behaviour?

    Read the article

  • Excel VBA Function runtime error 1004: Application-defined or object-defined error

    - by music2myear
    I'm trying to learn functions for the purpose of simplifying and reusing code whenever necessary. I began by turning something I use pretty often into a function: Returning the integer value of the last non-blank row in a spreadsheet. Function FindLastDataLine(strColName As String) As Long FindLastDataLine = Range(strColName).Offset(Rows.Count - 1, 0).End(xlUp).Row End Function Sub PracticeMacro() intItemCount = FindLastDataLine("A:A") MsgBox ("There are " & intItemCount & " rows of data in column A.") End Sub When I run this I recieve the runtime error '1004' "Application-defined or object-defined error" which Help helpfully defines as "someone else's fault" to quote not quite verbatim. Where might I be going wrong?

    Read the article

  • I want to use blur function instead mouseup function

    - by yossi
    I have the Demo Table which I can click on the cell(td tag) and I can change the value on it.direct php DataBase. to do that I need to contain two tags.1 - span. 2 - input. like the below. <td class='Name'> <span id="spanName1" class="text" style="display: inline;"> Somevalue </span> <input type="text" value="Somevalue" class="edittd" id="inputName1" style="display: none; "> </td> to control on the data inside the cell I use in jquery .mouseup function. mouseup work but also make truble. I need to replace it with blur function but when I try to replace mouseup with blur the program thas not work becose, when I click on the cell I able to enter the input tag and I can change the value but I can't Successful to Leave the tag/field by clicking out side the table, which alow me to update the DataBase you can see that Demo with blur Here. what you advice me to do? $(".edittd").mouseup(function() { return false; }); //************* $(document).mouseup(function() { $('#span' + COLUME + ROW).show(); $('#input'+ COLUME + ROW ).hide(); VAL = $("#input" + COLUME + ROW).val(); $("#span" + COLUME + ROW).html(VAL); if(STATUS != VAL){ //******ajax code //dataString = $.trim(this.value); $.ajax({ type: "POST", dataType: 'html', url: "./public/php/ajax.php", data: 'COLUME='+COLUME+'&ROW='+ROW+'&VAL='+VAL, //{"dataString": dataString} cache: false, success: function(data) { $("#statuS").html(data); } }); //******end ajax $('#statuS').removeClass('statuSnoChange') .addClass('statuSChange'); $('#statuS').html('THERE IS CHANGE'); $('#tables').load('TableEdit2.php'); } else { //alert(DATASTRING+'status not true'); } });//End mouseup function I change it to: $(document).ready(function() { var COLUMES,COLUME,VALUE,VAL,ROWS,ROW,STATUS,DATASTRING; $('td').click(function() { COLUME = $(this).attr('class'); }); //**************** $('tr').click(function() { ROW = $(this).attr('id'); $('#display_Colume_Raw').html(COLUME+ROW); $('#span' + COLUME + ROW).hide(); $('#input'+ COLUME + ROW ).show(); STATUS = $("#input" + COLUME + ROW).val(); }); //******************** $(document).blur(function() { $('#span' + COLUME + ROW).show(); $('#input'+ COLUME + ROW ).hide(); VAL = $("#input" + COLUME + ROW).val(); $("#span" + COLUME + ROW).html(VAL); if(STATUS != VAL){ //******ajax code //dataString = $.trim(this.value); $.ajax({ type: "POST", dataType: 'html', url: "./public/php/ajax.php", data: 'COLUME='+COLUME+'&ROW='+ROW+'&VAL='+VAL, //{"dataString": dataString} cache: false, success: function(data) { $("#statuS").html(data); } }); //******end ajax $('#statuS').removeClass('statuSnoChange') .addClass('statuSChange'); $('#statuS').html('THERE IS CHANGE'); $('#tables').load('TableEdit2.php'); } else { //alert(DATASTRING+'status not true'); } });//End mouseup function $('#save').click (function(){ var input1,input2,input3,input4=""; input1 = $('#input1').attr('value'); input2 = $('#input2').attr('value'); input3 = $('#input3').attr('value'); input4 = $('#input4').attr('value'); $.ajax({ type: "POST", url: "./public/php/ajax.php", data: "input1="+ input1 +"&input2="+ input2 +"&input3="+ input3 +"&input4="+ input4, success: function(data){ $("#statuS").html(data); $('#tbl').hide(function(){$('div.success').fadeIn();}); $('#tables').load('TableEdit2.php'); } }); }); }); Thx

    Read the article

  • one primary key column foreign key to 2 other table columns.How to resolve data entry issue.

    - by Rohit
    I have a requirement according to which I have to create a central Login system.We have 2 things Corporate and Brand each represented by tables "Corporate" and "Brand". When a corporate gets registered,corporateID is given,When a user under that corporate gets registered there is a table corporateuser in which corporateID is a foreign key and CorporateUserID is a primary key.Similarly in the case of a brand. So we have CorporateUserId and BrandUserID. Now i have a table called RegisteredUsers in which i want to have corporate as well as brand users.UserID is a primary key in this table which is a foreign key to both corporateuser as well as Branduser. now when i enter a corporateuser,I do an entry to corporateuser as well as RegisteredUsers.When i enter CorporateUserID in userID for RegisteredUsers.It gives foreign key violation error. I fully understand this error.How can i achieve this.This requirement is very rigid.Please tell a workaround

    Read the article

  • Way to check for foreign key references before deleting in MySQL?

    - by Chad Johnson
    I'm working with a content management system, and users are prompted with a confirmation screen before deleting records. Some records are foreign key referenced in other tables, and therefore they cannot be deleted. I would like to display a message beside a given record if it has foreign key references. To know whether I should display the message for a record, I could just query the referencing table and see if there are references. But the problem is, there are about a dozen tables with records potentially referencing this record, and a lookup could take a "long" time. Is there an easy way to tell whether the record is delete-ready (ie. has no foreign key references)?

    Read the article

  • VBA Public Function to Excel

    - by Sugih
    Dear sir , I have create below function Option Explicit Public Function fyi(x As Double, f As String) As String Application.Volatile Dim data As Double Dim post(5) post(1) = "Ribu " post(2) = "Juta " post(3) = "Milyar " post(4) = "Trilyun " post(5) = "Ribu Trilyun " Dim part As String Dim text As String Dim cond As Boolean Dim i As Integer If (x < 0) Then fyi = " " Exit Function End If If (x = 0) Then fyi = "Nol" Exit Function End If If (x < 2000) Then cond = True End If text = " " If (x >= 1E+15) Then fyi = "Nilai Terlalu Besar" Exit Function End If For i = 4 To 1 Step -1 data = Int(x / (10 ^ (3 * i))) If (data 0) Then part = fyis(data, cond) text = text & part & post(i) End If x = x - data * (10 ^ (3 * i)) Next text = text & fyis(x, False) fyi = text & f End Function Function fyis(ByVal y As Double, ByVal conds As Boolean) As String Dim datas As Double Dim posts(2) posts(1) = "Puluh" posts(2) = "Ratus" Dim parts As String Dim texts As String 'Dim conds As Boolean Dim j As Integer Dim value(9) value(1) = "Se" value(2) = "Dua " value(3) = "Tiga " value(4) = "Empat " value(5) = "Lima " value(6) = "Enam " value(7) = "Tujuh " value(8) = "Delapan " value(9) = "Sembilan " texts = " " For j = 2 To 1 Step -1 datas = Int(y / 10 ^ j) If (datas 0) Then parts = value(datas) If (j = 1 And datas = 1) Then y = y - datas * 10 ^ j If (y = 1) Then posts(j) = "belas" Else value(y) = "Se" End If texts = texts & value(y) & posts(j) fyis = texts Exit Function Else texts = texts & parts & posts(j) End If End If y = y - datas * 10 ^ j Next If (conds = False) Then value(1) = "Satu " End If texts = texts & value(y) fyis = texts End Function but when I return to Excel and type '=fyi(500,"USD") it return to #name? please do me favor to inform me how to solve Rgds, Sugih

    Read the article

  • "Decompile" Javascript function? *ADVANCED*

    - by caesar2k
    [1] Ok, I don't even know how to call this, to be honest. So let me get some semi-pseudo code, to show what I'm trying to do. I'm using jquery to get an already existing script declared inside the page, inside a createDocument() element, from an AJAX call. GM_xmlhttprequest({ ... load:function(r){ var doc = document_from_string(r.responseText); script_content = $('body script:regex(html, local_xw_sig)', doc).html(); var scriptEl = document.createElement('script'); scriptEl.type = 'text/javascript'; scriptEl.innerHTML = script_content; // good till here (function(sc){ eval(sc.innerHTML); // not exactly like this, but you get the idea, errors alert('wont get here ' + local_xw_sig); // local_xw_sig is a global "var" inside the source })(scriptEl); } }); so far so good, the script indeed contains the source from the entire script block. Now, inside this "script_content", there are auto executing functions, like $(document).ready(function(){...}) that, everything I "eval" the innerHTML, it executes this code, halting my encapsulated script. like variables that doesn't exist, etc removing certain parts of the script using regex isn't really an option... what I really wanted is to "walk" inside the function. like do a (completely fictional): script = eval("function(){" + script_content + "};"); alert(script['local_xw_sig']); // a03ucc34095cw3495 is there any way to 'disassemble' the function, and be able to reach the "var"s inside of it? like this function: function hello(){ var message = "hello"; } alert(hello.message); // message = var inside the function is it possible at all? or I will have to hack my way using regex? ;P [2] also, is there any way I can access javascript inside a document created with "createDocument"?

    Read the article

  • How can I invoke a function in bash shell script

    - by sufery
    !/bin/bash one_func(){ echo 'abcd' } echo $(one_func) echo one_func the end I just wonder the distinction calling the function between $(one_function) and one_function in bash shell script. When I set the variable "PS1" in ~/.bashrc, I can't invoke the function by one_func e: export PS1="\n[\e[31m]\$(one_func)" it work export PS1="\n[\e[31m]one_func" it doesn't work

    Read the article

  • Jquery callback function executes over and over again...

    - by Pandiya Chendur
    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' }); } and i call this jquery function, <script type="text/javascript"> $(document).ready(function() { getRecordspage(1, 5); }); </script> As you see my It works fine for 1st time and my callback function is configured to the current function itself... when it gets called the callback gets executed over and over again.... How can i prevent this? Any suggestion....

    Read the article

  • jQuery plugin, return value from function

    - by Marius
    Hello there, Markup: <input type="text" name="email" /> Code: $(':text').focusout(function(){ $(this).validate(function(){ $(this).attr('name'); }); }); Plugin: (function($){ $.fn.validate = function(type) { return this.each(function(type) { if (type == 'email') { matches = this.val().match('/.+@.+\..{2,7}/'); (matches != null) ? alert('valid') : alert('invalid'); } /*else if (type == 'name') { } else if (type == 'age') { } else if (type == 'text') { }*/ else { alert('total failure'); } }); }; })(jQuery); The problem is that when I execute the code above, it runs the plugin as if type was a string: "function(){ $(this).attr('name'); });" instead of executing it as a function. How do I solve this? Thank you for your time. Kind regards, Marius

    Read the article

  • Need to call original function from detoured function

    - by peachykeen
    I'm using Detours to hook into an executable's message function, but I need to run my own code and then call the original code. From what I've seen in the Detours docs, it definitely sounds like that should happen automatically. The original function prints a message to the screen, but as soon as I attach a detour it starts running my code and stops printing. The original function code is roughly: void CGuiObject::AppendMsgToBuffer(classA, unsigned long, unsigned long, int, classB); My function is: void CGuiObject_AppendMsgToBuffer( [same params, with names] ); I know the memory position the original function resides in, so using: DWORD OrigPos = 0x0040592C; DetourAttach( (void*)OrigPos, CGuiObject_AppendMsgToBuffer); gets me into the function. This code works almost perfectly: my function is called with the proper parameters. However, execution leaves my function and the original code is not called. I've tried jmping back in, but that crashes the program (I'm assuming the code Detours moved to fit the hook is responsible for the crash). Edit: I've managed to fix the first issue, with no returning to program execution. By calling the OrigPos value as a function, I'm able to go to the "trampoline" function and from there on to the original code. However, somewhere along the lines the registers are changing and that is causing the program to crash with a segfault as soon as I get back into the original code.

    Read the article

< Previous Page | 4 5 6 7 8 9 10 11 12 13 14 15  | Next Page >