473,324 Members | 2,002 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

Re: Replacing a private function an keeping access to privatevariables

On Jun 26, 4:53*pm, Gregor Kofler <use...@gregorkofler.atwrote:
How can I access a private variable when replacing a private function,
which originally had access to this variable, with another one? Or is it
just not possible?
If possible for your scenario, you could potentially use eval for
this. For example:


Expand|Select|Wrap|Line Numbers
  1. function MyClass(val)
  2. {
  3. var printIt = function () { window.alert("1:" + val); }
  4. this.callPrintIt = function () { printIt(); }
  5. this.setPrintIt = function (evalStr) { eval("printIt = " +
  6. evalStr); }
  7. }
  8.  
  9. var c = new MyClass("test");
  10. c.callPrintIt();
  11. c.setPrintIt("function () { window.alert(\"2:\" + val); }");
  12. c.callPrintIt();

Thanks
Jun 27 '08 #1
1 1365
ag*******@gmail.com meinte:
On Jun 26, 4:53 pm, Gregor Kofler <use...@gregorkofler.atwrote:
>How can I access a private variable when replacing a private function,
which originally had access to this variable, with another one? Or is it
just not possible?

If possible for your scenario, you could potentially use eval for
this.
No I never thought of eval() - for a lot of reasons. Anyway, it might
work in this example, but not in my real life problem, where a mousemove
listener is replaced by a custom function, which should still be able to
access the "hidden" variables of the object.

Gregor

--
http://photo.gregorkofler.at ::: Landschafts- und Reisefotografie
http://web.gregorkofler.com ::: meine JS-Spielwiese
http://www.image2d.com ::: Bildagentur für den alpinen Raum
Jun 27 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

34
by: Andy | last post by:
1) Is there any use of defining a class with a single constructor declared in private scope? I am not asking a about private copy constructors to always force pass/return by reference. 2) Is...
1
by: Suzi Carr | last post by:
Hello, We create querydefs in VB programs (i.e. CreateQueryDef). But as illustrated below, Access regenerates the SQL code we specify -- particularly the WHERE clause. While the new code is...
35
by: jacob navia | last post by:
Hi guys! I like C because is fun. So, I wrote this function for the lcc-win32 standard library: strrepl. I thought that with so many "C heads" around, maybe we could improve it in a...
8
by: Chris A via AccessMonster.com | last post by:
I have an interesting problem that I have yet to come accross that I can't change data structure on because it is an export from filemaker I am reformatting for another dept. anyway. I have a table...
1
by: amraam35 | last post by:
Here is the problem. I have made a log in script that prompts you to log in with a username and password as the "splash screen" It is an unbounded forum that checks that the username and password...
9
by: CDMAPoster | last post by:
About a year ago there was a thread about the use of global variables in A97: http://groups.google.com/group/comp.databases.ms-access/browse_frm/thread/fedc837a5aeb6157 Best Practices by Kang...
3
by: rick | last post by:
I have a situation where I want to write an extensible class that is capable of saving / restoring properties of classes derived from it. A simplified example is explained as follows;- class A...
2
by: agendum97 | last post by:
Is there a way of constructing a "class" in JavaScript to access a private member of a different scope of the same type? It is important that the variable remain private, and not accessible in...
1
by: Thomas 'PointedEars' Lahn | last post by:
Gregor Kofler wrote: I am curious, why did you choose to use a factory instead of a constructor? It's a closure and `privateVar' in privateFunc() is bound to the execution context of foo(),...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.