Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Passing value not a reference
Message
De
21/03/2016 05:43:36
 
 
À
20/03/2016 21:21:20
Information générale
Forum:
Javascript
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
01633405
Message ID:
01633410
Vues:
97
This message has been marked as the solution to the initial question of the thread.
Hi Michel,

>The values of lnLeft and lnTop, for example, are passed by reference.

I doubt so, as JavaScript only support passing parameters by value.
What probably happens is that lnLeft, not being defined by var lnLeft, is created as a property of the global object (window when executing in a browser); when onMouseOut() executes, it takes whatever lnLeft is in scope, eg window.lnLeft.

You can check that by reviewing the 'DOM' tab in FireBug (very similar to the 'locals' window in VFP debugger)

>What would be the best approach to pass a variable value?
You need to use the powerful JavaScript function 'apply'; a method of function.prototype, .apply() allows you to set the this keyword and/or the arguments the function will take at runtime.
You can review how this method works here: http://api.jquery.com/Types/#Context.2C_Call_and_Apply
Prototype.js (that I've been using since 2006) provides a convenient wrapper around .apply() called .curry(). However, could not find anything close in jQuery.




>In this line:
>
>
>   oDiv.onmouseout=function(e) {OnMouseOut(e,tcAlignID,lnLeft,lnTop,lnWidth,lnHeight)}
>   lnLeft=lnLeft-tnAlignOffsetLeft
>   lnTop=lnTop-tnAlignOffsetTop
>
>
>The values of lnLeft and lnTop, for example, are passed by reference.
>
>However, once the event is triggered, the value is not what was passed but the adjusted value in the lines following.
>
>What would be the best approach to pass a variable value?
Thierry Nivelet
FoxinCloud
Give your VFP application a second life, web-based, in YOUR cloud
http://foxincloud.com/
Never explain, never complain (Queen Elizabeth II)
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform