开发者

Dictionary Type mismatch in VBScript

开发者 https://www.devze.com 2022-12-09 14:18 出处:网络
The error I\'m receiving is: Type mismatch: \'stylesheets\' Stylesheets is defined as: sub stylesheets(collection)

The error I'm receiving is: Type mismatch: 'stylesheets'

Stylesheets is defined as:

sub stylesheets(collection)
    for each key in collection.Keys
        response.write(stylesheet(key, collection.Item(key)))
    next
end sub

' returns a link tag for each object in the collection
function stylesheet(asset, media_type)
    if (media_type="") then
        media_type="screen"
    end if
    return "<link href=""" & asset_url(asset) & """ type=""text/css"" media=""" _
        &  media_type & """ />"
end function

And it is being called as such:

<% stylesheets(site_stylesheets) %>

Where site_stylesheets has been defined as:

' stylesheets is a collection of the stylesheets to be included on all pages
Set site_stylesheets = CreateObject("Scripting.Dictionary")
site_stylesheets.Add "css/endoworks.css", "screen"

It ha开发者_开发百科s been a long time since I've done any VBScript-ing. I'd really appreciate any help.


Try removing the parenthesis when calling stylesheets. see this question for more information. I don't think you can use parenthesis when calling a sub with only one parameter.

Try this

<% stylesheets site_stylesheets %>

or this

<% call stylesheets(site_stylesheets) %>


I ended up just placing the loop logic from stylesheets into the header sub[routine]. It works fine now.

@Tester101: I tried your suggestions, but they didn't fix the problem.

Edit: I actually discovered that I had a stylesheets argument in the header subroutine which is where the stylesheets sub was called. So it was trying to execute nothing with an argument of site_stylesheets. Can't believe I missed that.

0

精彩评论

暂无评论...
验证码 换一张
取 消