In VbScript, when you have a method, you do
..Method A, B, C, D. If you would take some default values, you do
..Method A,,,D
My question is that how you can do this in JavaScript
..Method(???)
Thanks.
Derek 11 9278 De**********@yahoo.com (Derek Richards) writes: In VbScript, when you have a method, you do .Method A, B, C, D. If you would take some default values, you do .Method A,,,D
My question is that how you can do this in JavaScript .Method(???)
This question was asked a few days ago. The answer still is that you
don't. In Javascript you cannot omit parameters in the middle of the list,
only from some point on.
Omitted parameters in Javascript gives the value "undefined" to the
argument variables, so you can pass "undefined" instead.
/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit.html>
'Faith without judgement merely degrades the spirit divine.'
Here is some syntax.
expression.Open(FileName, UpdateLinks, ReadOnly, Format, Password,
WriteResPassword, IgnoreReadOnlyRecommended, Origin, Delimiter,
Editable, Notify, Converter, AddToMRU)
In javascript how to omit a few parameters and at the same time,
change some default values? Say for the parrameters UpdateLinks,
ReadOnly and IgnoreReadOnlyRecommended correspondingly, I would like
to choose values 2, false and true (in javascript, is true and false
the same as 0 and 1). How to express them in javascript?
..open(capturedFile, ?,?)
Lasse Reichstein Nielsen <lr*@hotpop.com> wrote in message news:<n0**********@hotpop.com>... De**********@yahoo.com (Derek Richards) writes:
In VbScript, when you have a method, you do .Method A, B, C, D. If you would take some default values, you do .Method A,,,D
My question is that how you can do this in JavaScript .Method(???)
This question was asked a few days ago. The answer still is that you don't. In Javascript you cannot omit parameters in the middle of the list, only from some point on.
Omitted parameters in Javascript gives the value "undefined" to the argument variables, so you can pass "undefined" instead.
/L De**********@yahoo.com (Derek Richards) writes: Here is some syntax. expression.Open(FileName, UpdateLinks, ReadOnly, Format, Password, WriteResPassword, IgnoreReadOnlyRecommended, Origin, Delimiter, Editable, Notify, Converter, AddToMRU)
In javascript how to omit a few parameters and at the same time, change some default values? Say for the parrameters UpdateLinks, ReadOnly and IgnoreReadOnlyRecommended correspondingly, I would like to choose values 2, false and true (in javascript, is true and false the same as 0 and 1).
No. Javascript has the boolean values true and false that are distict
from numbers. However, if used in a boolean setting, 0 and 1 convert
to the booleans false and true respectively.
How to express them in javascript? .open(capturedFile, ?,?)
expression.Open(capturedFile, 2, false, undefined, undefined, undefined, true)
This will give the value "undefined" to, e.g., Format, which is the same
value it would get if the argument is omitted.
There is no notion of default values in Javascript. An omitted argument
becomes undefined.
/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit.html>
'Faith without judgement merely degrades the spirit divine.'
I tried the syntax you gave me. Having Visual Studio 6.0 installed, I
got a Runtime Error: Open Method of Workbooks Class Failed! My
intention was also to remove the (Read-Only) above the MenuBar on the
upper left corner when an excel file is opened.
I also changed to expression.Open(capturedFile, undefined, false,
undefined, undefined, undefined, true). Still got the same error
message.
Do you have any suggestion? Thanks.
Lasse Reichstein Nielsen <lr*@hotpop.com> wrote in message news:<pt**********@hotpop.com>... De**********@yahoo.com (Derek Richards) writes:
Here is some syntax. expression.Open(FileName, UpdateLinks, ReadOnly, Format, Password, WriteResPassword, IgnoreReadOnlyRecommended, Origin, Delimiter, Editable, Notify, Converter, AddToMRU)
In javascript how to omit a few parameters and at the same time, change some default values? Say for the parrameters UpdateLinks, ReadOnly and IgnoreReadOnlyRecommended correspondingly, I would like to choose values 2, false and true (in javascript, is true and false the same as 0 and 1).
No. Javascript has the boolean values true and false that are distict from numbers. However, if used in a boolean setting, 0 and 1 convert to the booleans false and true respectively.
How to express them in javascript? .open(capturedFile, ?,?)
expression.Open(capturedFile, 2, false, undefined, undefined, undefined, true)
This will give the value "undefined" to, e.g., Format, which is the same value it would get if the argument is omitted.
There is no notion of default values in Javascript. An omitted argument becomes undefined.
/L
On 15 Oct 2003 10:10:57 -0700, De**********@yahoo.com (Derek Richards)
wrote: I tried the syntax you gave me. Having Visual Studio 6.0 installed, I got a Runtime Error: Open Method of Workbooks Class Failed! My intention was also to remove the (Read-Only) above the MenuBar on the upper left corner when an excel file is opened.
I also changed to expression.Open(capturedFile, undefined, false, undefined, undefined, undefined, true). Still got the same error message.
Do you have any suggestion? Thanks.
You can try using null but I doubt that will work either. The only
sure way is to specify a default parameter to an ActiveX method is to
pass Nothing, and you can use the JArgUtil ActiveX object for that. http://torrboy.customer.netspace.net.au/code/jargutil/
Regards,
Steve
This is really subtle. After some changes such as changing to null,
although teh error message is gone and i specified to open in Write
mode (Read Only is false), it doesn't do the way I wished to open in
Write mode. Instead, saw (Read Only) above the MenuBar on the upper
left corner when an excel file is opened. The previously-posted syntax
is what I found under the Help in Excel's VBA Editor (you may refer to
it for details of each parameter).
Syntax
expression.Open(FileName, UpdateLinks, ReadOnly, Format, Password,
WriteResPassword, IgnoreReadOnlyRecommended, Origin, Delimiter,
Editable, Notify, Converter, AddToMRU)
UpdateLinks is supposed to be a Variant datatype in VBA. How about in
javascript (simply using undefined to take its default value)? How to
specify the parameters to open in Write mode?
Thanks very much.
Steve van Dongen <st*****@hotmail.com> wrote in message news:<eo********************************@4ax.com>. .. On 15 Oct 2003 10:10:57 -0700, De**********@yahoo.com (Derek Richards) wrote:
I tried the syntax you gave me. Having Visual Studio 6.0 installed, I got a Runtime Error: Open Method of Workbooks Class Failed! My intention was also to remove the (Read-Only) above the MenuBar on the upper left corner when an excel file is opened.
I also changed to expression.Open(capturedFile, undefined, false, undefined, undefined, undefined, true). Still got the same error message.
Do you have any suggestion? Thanks.
You can try using null but I doubt that will work either. The only sure way is to specify a default parameter to an ActiveX method is to pass Nothing, and you can use the JArgUtil ActiveX object for that. http://torrboy.customer.netspace.net.au/code/jargutil/
Regards, Steve
Lasse Reichstein Nielsen wrote: [...] Javascript has the boolean values true and false that are distict from numbers. However, if used in a boolean setting, 0 and 1 convert to the booleans false and true respectively.
The explanation is incomplete. In Boolean expressions or expressions that
are evaluated as such (like in conditional statements) all numbers different
from 0 and -0 evaluate to `true': http://devedge.netscape.com/library/...v.html#1008323 How to express them in javascript? .open(capturedFile, ?,?)
expression.Open(capturedFile, 2, false, undefined, undefined, undefined, true)
This will give the value "undefined" to, e.g., Format, which is the same value it would get if the argument is omitted.
Unfortunately, IE < 5.5 does not implement the `undefined'
value. However they know `window.undefined'. But I would
choose `null' here instead.
There is no notion of default values in Javascript. An omitted argument becomes undefined.
Correct, and (JFTR) therefore you can specify default values in the function
body like
function foobar(arg1, arg2)
{
if (!arg2)
arg2 = "bla";
}
or if `arg2' is allowed to be false, 0, -0 or a reference to an object
(even `null'):
function foobar(arg1, arg2)
{
if (typeof arg2 != "undefined")
arg2 = "bla";
}
PointedEars
Thomas 'PointedEars' Lahn <Po*********@web.de> writes: The explanation is incomplete. In Boolean expressions or expressions that are evaluated as such (like in conditional statements) all numbers different from 0 and -0 evaluate to `true':
http://devedge.netscape.com/library/...v.html#1008323
Almost. The number NaN is also falsey. NaN stands for Not-a-Number,
which is (counterintuitively) a value of type number in Javascript -
typeof NaN == "number"
To be exact, the following values are converted to false by the
Boolean function and in any location that expects a boolean value (if,
while, and second argument of for-statements):
0, -0, NaN, false, "" (empty string), null, undefined
(0 and -0 are really only distinguishable internally, the programmer can't
tell the difference).
All other values are converted to true.
There is a special connection between 0/1 and true/false. If you convert
a boolean to a number, it is converted to 0 or 1.
Unfortunately, IE < 5.5 does not implement the `undefined' value. However they know `window.undefined'.
No more than it "knows" window.arglebargle. The value of a property
access of a non-eksisting property is undefined. Which is why a simple
line can make sure that "undefined" is a defined variable:
window.undefined = window.undefined;
(browsers where window is the global object only, ofcourse).
But I would choose `null' here instead.
You could use the null value, but it is not the same as not passing
the argument. It even has a different type according to the "typeof"
operator.
/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Lasse Reichstein Nielsen wrote: Thomas 'PointedEars' Lahn <Po*********@web.de> writes: The explanation is incomplete. In Boolean expressions or expressions that are evaluated as such (like in conditional statements) all numbers different from 0 and -0 evaluate to `true':
http://devedge.netscape.com/library/...v.html#1008323 Almost. The number NaN is also falsey. NaN stands for Not-a-Number, which is (counterintuitively) a value of type number in Javascript - typeof NaN == "number"
ACK
To be exact, [as written in the Guide]
Human gateway!!111
There is a special connection between 0/1 and true/false. If you convert a boolean to a number, it is converted to 0 or 1.
ACK Unfortunately, IE < 5.5 does not implement the `undefined' value. However they know `window.undefined'.
No more than it "knows" window.arglebargle. The value of a property access of a non-eksisting property is undefined.
Could be that it does not exist by default, I did not test it but read
about the possibility in dcljs a few days ago. It seems appropriate to
use window.undefined since `undefined' is not a reserved word and it is
unlikely that it has other meaning (in the DOM.)
Which is why a simple line can make sure that "undefined" is a defined variable: window.undefined = window.undefined;
Who the heck would do that???ßß But I would choose `null' here instead.
You could use the null value, but it is not the same as not passing the argument.
I know but `undefined' is not either, since arguments.length changes
when it is used as last argument. And we are talking about arguments
in the middle here.
It even has a different type according to the "typeof" operator.
Of course, and that can be helpful.
PointedEars
Thomas 'PointedEars' Lahn <Po*********@web.de> writes: Lasse Reichstein Nielsen wrote:
Could be that it does not exist by default, I did not test it but read about the possibility in dcljs a few days ago. It seems appropriate to use window.undefined since `undefined' is not a reserved word and it is unlikely that it has other meaning (in the DOM.)
I don't have access to IE<6, so I can't test it. It is quite possible
that "undefined" is not a global variable (i.e., a property of the
global object, which can also be accessed through the global variable
"window"). It is the case for Netscape 3, and I think I heard it fro
some other browsers too.
It is appropriate to use "window.undefined" for a way to get an
undefined value, since it will work correctly if "undefined" is
defined too. window.undefined = window.undefined;
Who the heck would do that???ßß
Me. If I target platforms where there might not be a global "undefined"
variable, this is the simplest way to make sure there is one. If you want
it to work on the global object without assuming the name "window", you
can write
(function(){this.undefined=this.undefined;})()
If you are going to write "window.undefined" to get an undefined value,
you might as well define it once and for all. This assignment is safe
if "undefined" exists already. As you say, it is appropriate to use
window.undefined to define undefined :)
I know but `undefined' is not either, since arguments.length changes when it is used as last argument. And we are talking about arguments in the middle here.
If we have the function
function foo(a,b,c,d,e) { ... }
and we only want to pass it the first argument
foo(42)
then the values of b through e become undefined. That is the behavior
expected by omitting arguments, which we can do in Javascript.
In Javascript, you cannot omit arguments in the middle. Not even using
foo.apply(this,[1,,,,4]);
If you test with
"3" in arguments
then the third argument is declared and has the value undefined.
(It is browser dependent whether it is defined when you omit arguments
at the end - IE isn't, Opera and Mozilla is)
The closest you can get to omitting arguments must be to give them
the same value as if they had actually been omitted: undefined. It even has a different type according to the "typeof" operator.
Of course, and that can be helpful.
That's a different point, but then the function must be written to
recognize the parameter passing convention that null represents omission,
not just the null object reference. I think it is misusing null, unless
the argument is supposed to always be an object.
/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Lasse Reichstein Nielsen wrote: Thomas 'PointedEars' Lahn <Po*********@web.de> writes: Lasse Reichstein Nielsen wrote:
[snipped because of ACK to known information]
> It even has a different type according to the "typeof" operator.
Of course, and that can be helpful.
That's a different point, but then the function must be written to recognize the parameter passing convention that null represents omission, not just the null object reference. I think it is misusing null, unless the argument is supposed to always be an object.
Provided that the function takes the middle argument(s) as optional, meaning
that it will, to some extent, work if they have not been provided, a
conditional statement like
if (bar)
{
...
}
else if (...)
{
...
}
else
{
...
}
(where `bar' is a named argument and parts of the code can be omitted, of
course) works the same for `undefined', which is risky because it is not
backwards compatible in IE, as it works for `null' which is AFAIS
cross-browser compatible. So I do not see the point why you insist to use
risky `undefined' (even if it's saner according to the specification) when
`null' can do exactly the same.
PointedEars This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: John Davis |
last post by:
Just wonder if <%@ Language="JAVASCRIPT" %> exists??
Since JavaScript is used in client-side scripting, but <% ... %> is used in
server-side scripting. It sounds doesn't make sense. But I saw...
|
by: John Davis |
last post by:
When I create new documents in Dreamweaver, there are several choices for
ASP creation:
ASP JavaScript: run at client side??
ASP VBScript: run at server side??
ASP.NET C#
ASP.NET VB
I don't...
|
by: Ian Sedwell |
last post by:
Hi guys
Many thanks to all who replied to my original question. Actually, it's dead
easy and the way I was doing it was correct the first time. You do indeed
simply call the VBScript routine...
|
by: Alex Molochnikov |
last post by:
Is there any way to find out programmatically if Javascript is
supported/enabled in a browser? By "programmatically" I mean on the Java
servlet side.
TIA
Alex Molochnikov
Gestalt Corporation
|
by: duncan |
last post by:
why does this work :-
<HEAD>
......
<SCRIPT LANGUAGE="javascript">
function test()
{
alert("test 1")
}
</SCRIPT>
|
by: shookim |
last post by:
I have a problem with my javascript code. The window.onload function
doesn't get called when there is vbscript between the two. Here is my
code which works:
<script type="text/javascript">...
|
by: Doug van Vianen |
last post by:
Hi,
I often like to include some JavaScript coding in my web pages to make them
more interesting. Unfortunately, even when this coding is as simple as a
check to see what the display width is in...
|
by: Shadow Lynx |
last post by:
That subject packs a whallop, so let me explain in better detail what's
happening and how it relates to ASPX pages...
In a nutshell, if the first <script /on a page is of type
"text/vbscript",...
|
by: Erwin Moller |
last post by:
Hi,
Can anybody comment on this?
In comp.lang.php I advised somebody to skip using:
<script language="javascript">
and use:
<script type="text/javascript">
And mr. Dunlop gave this response:
|
by: Tomislav |
last post by:
Hello,
I tried to use "javascript:return confirm();" function in following
manner ( triggered by form onSubmit event ):
**
<form method="post" action="mail.php" onSubmit="javascript:return...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
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,...
|
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...
|
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...
|
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...
| |