Can anybody tell me why the following code won't work as planned? It's an
extract of ASP code in JScript.
What's going on is that I'm accessing the Site Server COM objects to get a
list of deployment projects on a given server. I adapted the code from the
VBScript WSH example in the Site Server SDK, which works, but this one
doesn't seem like it wants to enumerate. The method 'EnumProjects'
supposedly enumerates through all the deployment projects, but it doesn't
happen when converted to JScript. The SDK says to initialize a variable for
iteration at zero and not to modify it thereafter. I supposedly works as the
counter for the enumeration. I've tried to set this at 1 or 2, and tried to
increment it as I loop, both techniques produce an error. That's probably
the first thing you'll see though, but manually incrementing this value
throws an error, so it's not an option. The following code is logically
correct in that it doesn't error out, but you can see that I had to put in
my own counter to keep an infinite loop from occurring. This is because the
enumeration method never increments the index. I have about 10 deployment
projects on this server, but the code hits the first one, and will continue
to display the name of the first one until my safety counter kicks off. I
would really appreciate it if someone could lend some insight into this
behavior.
Thanks!!!
var objReplicationSvr = Server.CreateObject("CrsApi.ReplicationServer")
objReplicationSvr.InitializeEx("momnpop", "exp30001", "48xmax", 300000)
intIterator = 0
var blnStillIterating = true
x = 0;
do {
x++;
try {
objRepProject = objReplicationSvr.EnumProjects(intIterator)
Response.write("<BR>Project Name: " + objRepProject.Name + " : " +
intIterator)
}
catch (Exception) {
Response.write("<BR>Error Name: " + Exception.name);
Response.write("<BR>Error Desc: " + Exception.description);
Response.write("<BR>Error Number: " + Exception.number);
Response.write("<BR>Error Message: " + Exception.message);
blnStillIterating = false
if (Exception.Number == intNoProjects) {
Response.write("<BR><B>No Projects have been defined</B>")
blnStillIterating = false;
}
else if (Exception.Number == intEOP) {
response.write("<BR><B>That's It</B>")
blnStillIterating = false
}
}
if (x > 20) blnStillIterating = false;
Quote:
} while (blnStillIterating);