VBScript question

Discuss all aspects of programming here.

Moderator: The Mod Squad

VBScript question

Postby filecore » Tue Jan 27, 2009 1:28 am

Hi, I'm a bit stupid and I'm not altogether brilliant at VBS anyway. My problem is a "name redefined" error. I think I understand what's happening, but my problem is with these lines:

Code: Select all
const NumSourceFiles = 3
dim SourceFiles()
redim SourceFiles(NumSourceFiles)
SourceFiles(0) = "C:\test_source1\*.*"
SourceFiles(1) = "C:\test_source2\*.*"
SourceFiles(2) = "C:\test_source3\*.*"


This is part of a much bigger script. I'm trying to make a backup system. The problem seems to be that when the line dim SourceFiles(), it's then redefined in redim SourceFiles(NumSourceFiles) and VBS goes all funny. Any ideas?
Home server: Asus P5Q Pro, Core2Quad, 8GB DDR2, ENGTX260 876MB, Zalman 800w, Antec P180 case, 2x1TB and 2x2TB Samsung Spinpoint F1, Windows 7 64-bit, etc

Work server: HP ProLiant ML350 G6, hexacore Xeon E5645 2.4GHz (12 logical cores), 16GB DDR3, 3x300GB SAS RAID5, Server 2008 R2, nVidia GT560Ti 1GB for Hyper-V RemoteFX acceleration
filecore
Black Belt 1st Degree
Black Belt 1st Degree
 
Posts: 1092
Joined: Mon Dec 29, 2003 10:35 am
Location: Trapped inside a virtual machine.

Postby evasive » Tue Jan 27, 2009 1:33 am

We hate rut, but we fear change.
********************************
System error, strike any user to continue...
evasive
Mobo-fu Master
Mobo-fu Master
 
Posts: 37389
Joined: Sun May 06, 2001 12:01 am
Location: Netherlands

Postby filecore » Tue Jan 27, 2009 1:36 am

As far as I can tell, that's exactly what I'm doing. So why does the script not like it?
Home server: Asus P5Q Pro, Core2Quad, 8GB DDR2, ENGTX260 876MB, Zalman 800w, Antec P180 case, 2x1TB and 2x2TB Samsung Spinpoint F1, Windows 7 64-bit, etc

Work server: HP ProLiant ML350 G6, hexacore Xeon E5645 2.4GHz (12 logical cores), 16GB DDR3, 3x300GB SAS RAID5, Server 2008 R2, nVidia GT560Ti 1GB for Hyper-V RemoteFX acceleration
filecore
Black Belt 1st Degree
Black Belt 1st Degree
 
Posts: 1092
Joined: Mon Dec 29, 2003 10:35 am
Location: Trapped inside a virtual machine.

Postby evasive » Tue Jan 27, 2009 2:36 am

check if you're not using

dim SourceFiles

without the () elsewhere. If you are, you're dimming twice which is illegal.
We hate rut, but we fear change.
********************************
System error, strike any user to continue...
evasive
Mobo-fu Master
Mobo-fu Master
 
Posts: 37389
Joined: Sun May 06, 2001 12:01 am
Location: Netherlands


Return to Programming

Who is online

Users browsing this forum: trendictionbot [Bot] and 1 guest