473,386 Members | 1,702 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

ASP (in VBScript) array problem - type mismatch

7
Greetings,
This is my first post here but I've been reading here a while and have developed a bit of a problem I thought I'd seek some advice on.

As the subject suggests, I'm building a page with ASP and using VBScript as my language. I'm relatively new to programming in general so forgive me if I'm way off base here somewhere.

What I'm doing is reading file names from a directory on my server and storing them as one long string in a variable. The filenames are actually a relative path like "/folder/filename.jpg." These are being brought in with the FileSystemObject and loaded in to the variable with a loop.
Expand|Select|Wrap|Line Numbers
  1.     for each item in folder.Files
  2.         url = MapURL(item.path)
  3.  
  4.         ' store the file names
  5.         if fileList = NULL Then
  6.             fileList = url & ","
  7.         else
  8.             fileList = fileList & url & ","
  9.         end if
  10.     next
  11.  
Then, I try to write the contents out...

Expand|Select|Wrap|Line Numbers
  1.     response.write(fileList)
  2.     response.write("<br><br>")
  3.  
  4.     newList = split(fileList,",")
  5.  
  6.     for each i in newList
  7.         response.write(newList(i) & "<br>") '<--- this line throws the error
  8.     next
  9.  
Now, in researching this up to this point (even on these very forums), I learned that when you split a variable like I've done to fileList, newList becomes an array of everything separated by a "," in fileList.

But, when I try to write the values saved in the array I get an error "Type mismatch: '/testfolder/testimg.jpg'"

I've tried quite a bit but obviously haven't been able to get it working. What am I missing here?

Not that I think it matters for this particular issue, but I'm running IIS on XP Pro.

Thanks in advance!

Edit --> response.write(fileList) prints all the relative paths just fine just like the code looks like it should.

/folder/testimage1.jpg,/folder/testimage2.jpg,/folder/testimage3.jpg,/folder/testimage4.jpg and on and on.
Oct 4 '08 #1
4 4682
yandhi
7
Actually... nevermind. I took a break and when I came back I realized my problem was a fundamental misunderstanding of looping through an array in VBScript.

Unlike in C++ where you would say something like...

Expand|Select|Wrap|Line Numbers
  1. for (int i = 0; i < n; i++) {
  2.      cout << myArray[i] << endl;
  3. }
  4.  
I was following that same style logic with this and that failed to accomplish the goal.

Instead, I changed my loop to...

Expand|Select|Wrap|Line Numbers
  1.     for each i in newList
  2.         response.write(i & "<br>")
  3.     next
  4.  
Anyway, just thought I'd put my solution up in the public as well in the event other beginners were running in to the same type of problem.

Thanks for your consideration. I'm sure I'll be back.

- John
Oct 5 '08 #2
DrBunchman
979 Expert 512MB
Hi John,

I'm glad you fixed your problem and thanks for posting the solution.

Oh and welcome to Bytes!

Dr B
Oct 6 '08 #3
jhardman
3,406 Expert 2GB
Actually... nevermind. I took a break and when I came back I realized my problem was a fundamental misunderstanding of looping through an array in VBScript.

Unlike in C++ where you would say something like...

Expand|Select|Wrap|Line Numbers
  1. for (int i = 0; i < n; i++) {
  2.      cout << myArray[i] << endl;
  3. }
  4.  
I was following that same style logic with this and that failed to accomplish the goal.

Instead, I changed my loop to...

Expand|Select|Wrap|Line Numbers
  1.     for each i in newList
  2.         response.write(i & "<br>")
  3.     next
  4.  
Anyway, just thought I'd put my solution up in the public as well in the event other beginners were running in to the same type of problem.

Thanks for your consideration. I'm sure I'll be back.

- John
Right, because if you say "for each i in newList" you make i be each of the elements, not the index of the elements. To do a similar thing to what you did in C++ you would say "for i = 0 to ubound(newList)". Anyway, glad you found your solution.

Jared
Oct 6 '08 #4
yandhi
7
Ahh awesome, thanks Jared. Much appreciated. I'll definitely keep that in mind.
Oct 7 '08 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Gordon | last post by:
I'm just getting started in ASP and can't seem to figure out how to run a function in ASP. I get an error of "Line 11 - Type Mismatch:'myvalidate'. Line 11 is the Input Button. Here is my simple...
5
by: Arun Wadhawan | last post by:
Hello MY SQL Server is causing me this problem : Microsoft VBScript runtime error '800a000d' Type mismatch: 'ident' >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> I am getting from...
3
by: jg | last post by:
in VB 2005 the class myClass, I have Dim someStringArrary() As String --- sub New() MyBase.New() ... 'values assigned to elements of someStringArrary End Sub ......
10
by: Ocean | last post by:
I'm a novice on ASP using VBScript, and I encountered a problem when I want to get and use a return value of a web method in my ASP code. There is a web method called "getQuote", which takes a...
3
by: Snow | last post by:
Hello: I have Error Type: Microsoft VBScript runtime (0x800A000D) Type mismatch: '' The error happened at this line: if session("systemIdCount" & arrSystems(iLoop)) 0 The code like this:
19
by: zz12 | last post by:
Hello, is there a setting in IIS 5.0 that would quickly fix the following error?: Microsoft VBScript runtime (0x800A000D) Type mismatch It's strange because some of our .asp pages were...
10
by: lasmith329 | last post by:
I've never posted a question on any site before, but after racking my head over this hurdle for days, I've caved. I'm working on a program that creates a kml file and exports it to Google Earth. In...
7
by: Jimgunkel | last post by:
I'm getting an error message: Technical Information (for support personnel) Error Type: Microsoft VBScript runtime (0x800A000D) Type mismatch...
1
by: sharbha | last post by:
I am experiencing a VBScript runtime error. The error message is: "(0x800A000D)Type mismatch error" Here is my code: <% dim temp temp=session("items") ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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...
0
Oralloy
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 using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.