473,703 Members | 2,371 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to list the statement of all var ?

Hello all,

and Happy end year 2005 !

Well, I would like to obtain a list of all JavaScript var statement,
With "for...in" perharps ?

That is bellow my recent test here, but the problem is to management
theses :-((( I must to declare and use all variable with this scheme :

v['name']

Thanx for all suggestion !

=============== =============== =============== =============== ============
<html>
<head>
<title>for... in (var)</title>
</head>
<body>
<script type="text/javascript">
<!--
var v=new Array();
v['titi']="";
v['bleah']='toto';
v['toto']='bibi';
v['tutu']=109;
v['annonce_fr']="Bonne f&ecirc;tes de fin d'ann&eacute;e !";
v['annonce_en']="Happy new year, this is the end of the year 2005...
Hello 2006 !!";
function print_all() {
for (var i in window.v) {
v['titi']=(typeof(window .v[i])=="string")?" ' ":"";
document.write( i + " = " + v['titi'] +
"<span style='color: blue; font-weight:bold;'>" +window.v[i]+"</span>"
+
v['titi'] + "<br>\n");
}
}
print_all();
document.write( "<hr> v['tutu']+2 = "+(v['tutu']+2));
// -->
</script>
</body>
</html>
=============== =============== =============== =============== ============

Thierry
and best regards from France,

<http://www.google.com/maps?ll=45.128...5925,0.013087&
t=k&hl=fr>

PS : sorry for my bad english spoken :-(
Dec 26 '05 #1
35 3600


Thierry Loiseau wrote:

Well, I would like to obtain a list of all JavaScript var statement,
With "for...in" perharps ?

That is bellow my recent test here, but the problem is to management
theses :-((( I must to declare and use all variable with this scheme :

v['name']


The var statement declares a variable (or more) and might additionally
initialize variables e.g.
var varName;
or
var varName = 'Kibology';

v['name'] is a property access but obviously no var statement.

The language itself does not have a "Code object model" which would
allow your script code to access the code itself in a structured way
where you could look for statements or statements of a certain type.

But global variables declared with the var statement will become
properties of the global object (which is the window object in
client-side browser script) and properties of an object can be
enumerated using the for..in statement if those properties are not
marked with the internal attribute DontEnum. As the var statement
definition does not specify that that internal DontEnum attribute should
be set for declared variables being created as properties an
implementation should make all those declared variables enumerable with
for..in.
--

Martin Honnen
http://JavaScript.FAQTs.com/
Dec 26 '05 #2
Martin Honnen <ma*******@yaho o.de> wrote:
The var statement declares a variable (or more) and might additionally
initialize variables e.g.


I'm shure "statement" is no well come in my first message :-(((
In french, "Etat" ?

Thierry
Dec 26 '05 #3


Thierry Loiseau wrote:
Martin Honnen <ma*******@yaho o.de> wrote:

The var statement declares a variable (or more) and might additionally
initialize variables e.g.

I'm shure "statement" is no well come in my first message :-(((
In french, "Etat" ?


Sorry, I can't help, there is a French group fr.comp.lang.ja vascript as
far as I know where French is the main language, posting and reading
there might be more successful for you.
Google has it here:
<http://groups.google.c om/group/fr.comp.lang.ja vascript?hl=en>
Hmm, I see you already post there, if that really does not help and you
want to post here then consider making a post with two languages,
English and French, here, that might then increase your chances that
someone here understands what you are looking for as you might have
someone read here who is fluent (enough) in French.

--

Martin Honnen
http://JavaScript.FAQTs.com/
Dec 26 '05 #4
VK

Thierry Loiseau wrote:
Martin Honnen <ma*******@yaho o.de> wrote:
The var statement declares a variable (or more) and might additionally
initialize variables e.g.


I'm shure "statement" is no well come in my first message :-(((
In french, "Etat" ?


"a state" - but this is a too vague term for the task description.
Based on the posted code you're trying to find either "valeur" (a
value) or "typage" (a type) - or both - of the v[i] elements. Could you
clarify please?
( Any recognizable version of the Shakespeare language goes just fine
;-)

Dec 26 '05 #5
VK <sc**********@y ahoo.com> wrote:
Thierry Loiseau wrote:
Martin Honnen <ma*******@yaho o.de> wrote:
The var statement declares a variable (or more) and might additionally
initialize variables e.g.
I'm shure "statement" is no well come in my first message :-(((
In french, "Etat" ?


"a state" - but this is a too vague term for the task description.


Right ! Ok !
Based on the posted code you're trying to find either "valeur" (a
value) or "typage" (a type) - or both - of the v[i] elements. Could you
clarify please?
( Any recognizable version of the Shakespeare language goes just fine
;-)


Ok. Thank you for your post. Than my example, I would like to get value
of each !

With my script =

=============== =============== =============== =============== ============
<html>
<head>
<title>for... in (var)</title>
</head>
<body>
<script type="text/javascript">
<!--
var v=new Array();
v['titi']="";
v['bleah']='toto';
v['toto']='bibi';
v['tutu']=109;
v['annonce_fr']="Bonne nouvelle ann&eacute;e 2006 !!";
v['annonce_en']="Happy new year 2006 !!";
function print_all() {
for (var i in window.v) {
v['titi']=(typeof(window .v[i])=="string")?" ' ":"";
document.write( i + " = " + v['titi'] +
"<span style='color: blue; font-weight:bold;'>" +window.v[i]+"</span>"
+
v['titi'] + "<br>\n");
}
}
print_all();
document.write( "<hr> v['tutu']+2 = "+(v['tutu']+2));
// -->
</script>
</body>
</html>
=============== =============== =============== =============== ============

The result is :

=============== =============== =============== =============== ============

titi = ' ' '
bleah = ' toto '
toto = ' bibi '
tutu = 109
annonce_fr = ' Bonne nouvelle année 2006 !! '
annonce_en = ' Happy new year 2006 !! '
v['tutu']+2 = 111
=============== =============== =============== =============== ============

I repeat : the problem is to management theses :-(((
So, I must to declare and use all variable with this strict scheme
(syntax, scheme is a good word ?) :

v['name']

Thanx for all suggestion !

Thierry,
best regards from France
Dec 26 '05 #6
VK <sc**********@y ahoo.com> wrote:
Thierry Loiseau wrote:
Martin Honnen <ma*******@yaho o.de> wrote:
The var statement declares a variable (or more) and might additionally
initialize variables e.g.
I'm shure "statement" is no well come in my first message :-(((
In french, "Etat" ?


"a state" - but this is a too vague term for the task description.


Right ! Ok !
Based on the posted code you're trying to find either "valeur" (a
value) or "typage" (a type) - or both - of the v[i] elements. Could you
clarify please?
( Any recognizable version of the Shakespeare language goes just fine
;-)


Ok. Thank you for your post. Than my example, I would like to get value
of each !

With my script =

=============== =============== =============== =============== ============
<html>
<head>
<title>for... in (var)</title>
</head>
<body>
<script type="text/javascript">
<!--
var v=new Array();
v['titi']="";
v['bleah']='toto';
v['toto']='bibi';
v['tutu']=109;
v['annonce_fr']="Bonne nouvelle ann&eacute;e 2006 !!";
v['annonce_en']="Happy new year 2006 !!";
function print_all() {
for (var i in window.v) {
v['titi']=(typeof(window .v[i])=="string")?" ' ":"";
document.write( i + " = " + v['titi'] +
"<span style='color: blue; font-weight:bold;'>" +window.v[i]+"</span>"
+ v['titi'] + " [" + typeof(window.v[i]) + "]<br>\n");
}
}
print_all();
document.write( "<hr> v['tutu']+2 = "+(v['tutu']+2));
// -->
</script>
</body>
</html>
=============== =============== =============== =============== ============

The result is :

=============== =============== =============== =============== ============

titi = ' ' '
bleah = ' toto '
toto = ' bibi '
tutu = 109
annonce_fr = ' Bonne nouvelle année 2006 !! '
annonce_en = ' Happy new year 2006 !! '
v['tutu']+2 = 111
=============== =============== =============== =============== ============

I repeat : the problem is to management theses :-(((
So, I must to declare and use all variable with this strict scheme
(syntax, scheme is a good word ?) :

v['name']

Thanx for all suggestion !

Thierry,
best regards from France
Dec 26 '05 #7
VK <sc**********@y ahoo.com> wrote:
Thierry Loiseau wrote:
Martin Honnen <ma*******@yaho o.de> wrote:
The var statement declares a variable (or more) and might additionally
initialize variables e.g.
I'm shure "statement" is no well come in my first message :-(((
In french, "Etat" ?


"a state" - but this is a too vague term for the task description.


Right ! Ok !
Based on the posted code you're trying to find either "valeur" (a
value) or "typage" (a type) - or both - of the v[i] elements. Could you
clarify please?
( Any recognizable version of the Shakespeare language goes just fine
;-)


Ok. Thank you for your post. Than my example, I would like to get value
of each !

With my script =

=============== =============== =============== =============== ============
<html>
<head>
<title>for... in (var)</title>
</head>
<body>
<script type="text/javascript">
<!--
var v=new Array();
v['titi']="";
v['bleah']='toto';
v['toto']='bibi';
v['tutu']=109;
v['annonce_fr']="Bonne nouvelle ann&eacute;e 2006 !!";
v['annonce_en']="Happy new year 2006 !!";
function print_all() {
for (var i in window.v) {
v['titi']=(typeof(window .v[i])=="string")?" ' ":"";
document.write( i + " = " + v['titi'] +
"<span style='color: blue; font-weight:bold;'>" +window.v[i]+"</span>"
+ v['titi'] + " [" + typeof(window.v[i]) + "]<br>\n");
}
}
print_all();
document.write( "<hr> v['tutu']+2 = "+(v['tutu']+2));
// -->
</script>
</body>
</html>
=============== =============== =============== =============== ============

The result print in the page is :

=============== =============== =============== =============== ============
titi = ' ' ' [string]
bleah = ' toto ' [string]
toto = ' bibi ' [string]
tutu = 109 [number]
annonce_fr = ' Bonne nouvelle année 2006 !! ' [string]
annonce_en = ' Happy new year 2006 !! ' [string]
v['tutu']+2 = 111
=============== =============== =============== =============== ============

I repeat : the problem is to management theses :-(((
So, I must to declare and use all variable with this strict scheme
(syntax, scheme is a good word ?) :

v['name']

Thanx for all suggestion !

Thierry,
best regards from France
Dec 26 '05 #8
VK

Thierry Loiseau wrote:
I repeat : the problem is to management theses :-(((
So, I must to declare and use all variable with this strict scheme
(syntax, scheme is a good word ?) :

v['name']


Array ("rangee") consists of arrayObject.len gth elements and you handle
them by their index which is positive integer:
v[10] = 'foo';
alert(v[10]);

The posted structure is *not* an array. So proper way to handle it
would be (one of possibilities):

var v=new Object(); // not Array!
v['titi']="";
v['bleah']='toto';
v['toto']='bibi';
v['tutu']=109;
v['annonce_fr']="Bonne nouvelle ann&eacute;e 2006 !!";
v['annonce_en']="Happy new year 2006 !!";
etc. as you already do

And of course no one stops you from declaring separate variables which
are not parts of any higher structure:

var blah_blah_blah = "blah-blah-blah";

I guess you need to find a good French manual of JavaScript (I cannot
advise any).
For English reading you may visit:
<http://www.geocities.c om/schools_ring/ArrayAndHash.ht ml>

:-D ;-)

Dec 26 '05 #9
VK <sc**********@y ahoo.com> wrote:
Thierry Loiseau wrote:
I repeat : the problem is to management theses :-(((
So, I must to declare and use all variable with this strict scheme
(syntax, scheme is a good word ?) :

v['name']

Array ("rangee") consists of arrayObject.len gth elements and you handle
them by their index which is positive integer:
v[10] = 'foo';
alert(v[10]);

The posted structure is *not* an array. So proper way to handle it
would be (one of possibilities):

var v=new Object(); // not Array!


Ok !
v['titi']="";
v['bleah']='toto';
v['toto']='bibi';
v['tutu']=109;
v['annonce_fr']="Bonne nouvelle ann&eacute;e 2006 !!";
v['annonce_en']="Happy new year 2006 !!";
etc. as you already do

And of course no one stops you from declaring separate variables which
are not parts of any higher structure:

var blah_blah_blah = "blah-blah-blah";

I guess you need to find a good French manual of JavaScript (I cannot
advise any).
For English reading you may visit:
<http://www.geocities.c om/schools_ring/ArrayAndHash.ht ml>
Ok (too). So I make a long script to my (sorry in french) personal
homepage.

<http://astrophoto.free .fr/calculs/calculs.js>
:-D ;-)


Yep !

Thanx VK !

Thierry Loiseau
and Best regards
From France
Dec 26 '05 #10

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

Similar topics

0
10206
by: Jan | last post by:
I store sql-commands in a database table. In the first step I get the sql command out of the database table with embedded sql. In the second step I try to execute the command, which i got from the database table, using dynamic sql. Executing 'EXEC SQL DESCRIBE SELECT LIST FOR S INTO select_dp;' the error code -2149 is returned That means "Specified partition does not exist". Does anybody know if it is a database problem or a problem of
15
2151
by: C White | last post by:
I've got another drop list problem I am using the following code where users select a name, but it should pass a name and email into the table <select name="user"> <option value="<% Response.Write (rsUser("Name")) %>"> <% Response.Write (rsUser("Name")) %> <input type="hidden" name="Email" value="<% Response.Write (rsUser("Email")) %>">
0
3514
by: starace | last post by:
I have designed a form that has 5 different list boxes where the selections within each are used as criteria in building a dynamic query. Some boxes are set for multiple selections but these list boxes do not necessarily need to have a selection made to be used in the dynamic query. In essence the form can have selections made in all or none of its list boxes to form the dynamic query I am looking to get some feedback in reference to...
9
1502
by: Michael Mair | last post by:
Hello, in C89 (at least in the last public draft), "3.6.2 Compound statement, or block", we have ,--- | Syntax | | compound-statement: | { declaration-list<opt> statement-list<opt> }
65
4216
by: Steven Watanabe | last post by:
I know that the standard idioms for clearing a list are: (1) mylist = (2) del mylist I guess I'm not in the "slicing frame of mind", as someone put it, but can someone explain what the difference is between these and: (3) mylist =
77
17029
by: Ville Vainio | last post by:
I tried to clear a list today (which I do rather rarely, considering that just doing l = works most of the time) and was shocked, SHOCKED to notice that there is no clear() method. Dicts have it, sets have it, why do lists have to be second class citizens?
6
2166
by: Heiko Wundram | last post by:
Hi all! The following PEP tries to make the case for a slight unification of for statement and list comprehension syntax. Comments appreciated, including on the sample implementation. === PEP: xxx Title: Unification of for-statement and list-comprehension syntax
6
2744
by: AA Arens | last post by:
Hi, I have a database with 2 main forms. Contacts and companies. I share the base with two others via LAN. On the companies form I have buttons to navigate throught the records (>400). We are mostly handling let say 5 companies. Every time I have to navigate or choose the find record button to get the right company. I am looking fo a feature to have listed in a combo list the last 5 visited records ("recently visited records").
3
1314
by: Nader | last post by:
Hello, I read some files name from a directory and then I put these name in a list. I will check whether it is empty or not, and I would do it with an exception. With if statement it is very simple: If list_of_files != "" : # this can be if list_of_files != : get the files elas:
0
9251
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9121
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9017
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8962
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7867
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6588
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4432
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4687
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2450
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.