Re: RegExp: \char -> /char

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Roland Hall (nobody_at_nowhere)
Date: 05/31/04


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


Relevant Pages

  • (patch for Bash) regex conditional tests
    ... 'regex' are returned in array variable SUBMATCH. ... Skipping of positional parameters, array elements, string ... int dollarflag, zeropad, compareflag; ... SHELL_VAR *var; ...
    (comp.unix.shell)
  • Re: [PHP] Image Generation
    ... the text, font, colour, maximum frame size (ie the width and height it ... var $xoffset, $yoffset, $margin; ... a string or array of strings. ... a float or an array of floats - which size to display the related text at. ...
    (php.general)
  • Re: Problem with array
    ... I' m trying convert a php array to a javascript array like ... var danearray1= new Array; ... When you use the + operator where either of its operands is a string the ...
    (comp.lang.javascript)
  • Re: Which is considered the best method in this example ?
    ... It's not the level1 object. ... object (e.g. the moreinfo string (which has the value "def"), ... know which level3 element I am in the array. ... var level1 = { ...
    (comp.lang.javascript)
  • Re: TrySetLength not possible !? :(
    ... The length of the array is supposed to be the number of elements. ... function SkybuckTrySetLength(var ParaVar; const ParaNewLength: ... vWord: array of Word; ... vLongword: array of Longword; ...
    (alt.comp.lang.borland-delphi)