Re: RegExp: \char -> /char
From: Roland Hall (nobody_at_nowhere)
Date: 05/31/04
- Next message: Clare Hsiao: "Can JavaScript intellisense in vs.net support DOM level1?"
- Previous message: Charles Edwards: "Re: Handling event from ActiveX control in IE"
- In reply to: Wilhelm Pieper: "Re: RegExp: \char -> /char"
- Next in thread: Wilhelm Pieper: "Re: RegExp: \char -> /char"
- Reply: Wilhelm Pieper: "Re: RegExp: \char -> /char"
- Messages sorted by: [ date ] [ thread ]
Date: Mon, 31 May 2004 17:00:01 -0500
"Wilhelm Pieper" wrote in message
news:OwmiNozREHA.3596@tk2msftngp13.phx.gbl...
:
: "Evertjan." <exjxw.hannivoort@interxnl.net> schrieb im Newsbeitrag
: news:Xns94FAC77008E1eejj99@194.109.133.29...
: > Wilhelm Pieper wrote on 31 mei 2004 in
: > microsoft.public.scripting.jscript:
: > > var strPath="C:\tmp\main\tmp.txt";
: > I gave all the hints you need. You cannot do THIS.
: >
: > As I told you you have to escape the \ in a string LITTERAL.
: >
: > But you said that you had the string already in a variable, so then no
: > escaping is necessary.
: Ok - a more detailed code snippet:
: ------------snip:
: var aFolders = new Array();
: var regE = /\\/g;
:
: function GetFolderList(folderspec){
: var f, fc;
: f = fso.GetFolder(folderspec);
: fc = new Enumerator(f.SubFolders);
: i=0;
: aFolders = new Array();
: for (; !fc.atEnd(); fc.moveNext()){
: aFolders[i] = "" + fc.item();
: i++;
: }
: }
: ..
: for (i=0;i<aFolders.length;i++){
: strTmp = aFolders[i].toString();
: strtTmp = strTmp.replace(regE,"/");
: strHtml = "<a href='" + strTmp + "' onClick=showFiles(" + strTmp + ")>"
+
: strTmp + "</a><br />";
: fldr1.innerHTML=fldr1.innerHTML + strHtml;
: }
: ----------------------------------snap:
: This code results in an alert-window: missing ")"
William...
If you get an error message telling you it expected ')' then that means the
line with the error is not complete since all of your ( and ) line up and it
is generally the line previous to that or somewhere preceding in that
function. The line is trying to terminate prematurely. You need to show
the relevant code, not interpreted, probably the whole function, with
passing argument values and the expected result. If your parens line up,
and if the string is valid, then stop chasing them. They are not related to
the problem you're having. Alerting expected values along the way will help
you locate the problem.
alert('Debug0: a=' + a + ' expected: somevalue'); // debug0
Generally when I get the error you're getting it is because I'm mixing ' and
" and they are either reversed or not paired.
You can also pull out a section you think is not working and create a temp
file to work on that routine and then plug it back in when you've solved the
issue.
Looking at above, is fso global?
var aFolders = new Array();
var regE = /\\/g;
function GetFolderList(folderspec){
var f, fc;
f = fso.GetFolder(folderspec);
fc = new Enumerator(f.SubFolders);
i=0;
aFolders = new Array();
for (; !fc.atEnd(); fc.moveNext()){
aFolders[i] = "" + fc.item();
i++;
}
}
Where is:
fso = new ActiveXObject("Scripting.FileSystemObject");
Why is aFolders defined twice as an array? It's already global.
What is the value of folderspec?
-- Roland Hall /* This information is distributed in the hope that it will be useful, but without any warranty; without even the implied warranty of merchantability or fitness for a particular purpose. */ Technet Script Center - http://www.microsoft.com/technet/scriptcenter/ WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp MSDN Library - http://msdn.microsoft.com/library/default.asp
- Next message: Clare Hsiao: "Can JavaScript intellisense in vs.net support DOM level1?"
- Previous message: Charles Edwards: "Re: Handling event from ActiveX control in IE"
- In reply to: Wilhelm Pieper: "Re: RegExp: \char -> /char"
- Next in thread: Wilhelm Pieper: "Re: RegExp: \char -> /char"
- Reply: Wilhelm Pieper: "Re: RegExp: \char -> /char"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|