views:

810

answers:

3

I'm creating a GUID for use in a Classic ASP application, by using TypeLib. However, even a simple test such as writing the GUID out to the screen is giving me problems - it prints the GUID but ignores everything after it (e.g. HTML tags, additional words, anything).

Here's the rudimentary code to test this:

Set typeLib = Server.CreateObject("Scriptlet.TypeLib")
myGuid = typeLib.Guid
Response.Write myGuid & " is the new GUID"
Set typeLib = Nothing

This will display something like {9DDB27D1-F034-41D7-BB88-D0D811DB91CE} and that's it; the rest of the text is ignored and isn't written out. However, if I hard-code that GUID value and reference it from a variable, the rest of the text appears just fine. I've tried explicit conversion to a String value before displaying, but it still happens.

A: 

as far as I know GUID is a struct and not string, you need to add a ToString() method to output it as a string.

Schwartser
I don't think I can use ToString in VBScript; trying to use typeLib.Guid.ToString() gives me an error.
Wayne M
check thishttp://support.stormhosts.net/showthread.php?t=344
Schwartser
+3  A: 

I seem to have solved my own problem.. it was adding something extra to the text, so I had to do:

myGuid = Left(myGuid, Len(myGuid)-2)

and it now outputs fine. Strange.

Wayne M
did you saw my comment back to you?it is srange...
Schwartser
Not that strange if the GUID really is a struct. The Left function would have to convert it to a string, so it can work with it and return a string.
Tester101
Scriptlet.TypeLib.Guid gives a null-terminated string. Something on the way from your code to the screen uses null termination and thus stops outputing things in the middle.
svinto
A: 

I use something like this

Function GetGuid() 
        Set TypeLib = CreateObject("Scriptlet.TypeLib") 
        GetGuid = Left(CStr(TypeLib.Guid), 38) 
        Set TypeLib = Nothing 
End Function 
Louis