Unusual Behavior

I am getting unusual behavior with some code I am writing, I have reproduced the errors in the code below. I do not believe that the error is with my code.
Here is what's going on:
a GUID is passed to a function as a string. A GUID such as "{D498A854-FBAC-4554-B2F1-C266B45326D5}" is 38 characters long, yet the Len function is returning 40, (?) so I wrote a loop displaying each of the 40 characters with their ascii values, which displays the 38 characters and their ascii values normally, and then it seems that the response.write method starts behaving strangley. The numbers 39 and 40 are displayed however there is no characters nor ascii values, also in the output is the string "<br>" which should produce a newline character, but does not show up after lines 39 and 40.

Another strange behavior, is that if I write the GUID parameter then the lenght of the parameter the length does not show up, however if I write the length then the parameter, it works normally.

Can anyone help me to make since of this?!?!?!
ff

--CODE--
Function isGUID( dataIn )

dim i
i=1
while( i<=40 )
 response.write( i & ")" & mid(dataIn,i,1) & " " & asc(mid(dataIn,i,1)) & "<br>" )
 i=i+1
wend

response.write "<hr>"
response.write Len(dataIn) & " " & dataIn
response.write "<hr>"
response.write dataIn & " " & Len(dataIn) & " this text does not show up"
response.write "<hr>"


End Function

--OUTPUT-- // note: the line breaks that appear after <br> and <hr> are mine
1){ 123<br>
2)5 53<br>
3)F 70<br>
4)3 51<br>
5)4 52<br>
6)B 66<br>
7)8 56<br>
8)2 50<br>
9)A 65<br>
10)- 45<br>
11)A 65<br>
12)9 57<br>
13)9 57<br>
14)4 55<br>
15)- 45<br>
16)4 52<br>
17)C 67<br>
18)5 53<br>
19)C 67<br>
20)- 45<br>
21)3 56<br>
22)4 52<br>
23)1 49<br>
24)4 52<br>
25)- 45<br>
26)C 67<br>
27)8 56<br>
28)1 55<br>
29)4 52<br>
30)7 55<br>
31)3 51<br>
32)1 49<br>
33)2 50<br>
34)6 54<br>
35)C 67<br>
36)A 65<br>
37)1 48<br>
38)} 125<br>
39)40)
<hr>
40 {5F34B82A-A997-4C5C-8414-C87473126CA0}
<hr>
{5F34B82A-A997-4C5C-8414-C87473126CA0}
<hr>

LVL 2
funkyfingerAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

DexstarCommented:
funkyfinger:

> A GUID such as "{D498A854-FBAC-4554-B2F1-C266B45326D5}" is 38 characters long,
> yet the Len function is returning 40

Something is clear wrong with that.
Look at this:

     Dim str
     str = "{D498A854-FBAC-4554-B2F1-C266B45326D5}"
     Response.Write "Length = " & Len(str) & ", Value = """ & str & """"

That should print out a length of 38.  Where are you getting the GUID value?  Maybe you have some whitespace on there that needs to be trimmed off...  Add this line to the top of your isGUID function:
     dataln = TRIM(dataln)

Hope That Helps,
Dex*
0
funkyfingerAuthor Commented:
Yes indeed,
I tried the trim function and it seems to have no effect, size is unchanged and behavior remains the same,
Running your code I get correct output:
Length = 38, Value = "{D498A854-FBAC-4554-B2F1-C266B45326D5}"
Even if I switch it around str first then len()
Weird huh?
Do you think is has something to do with being a parameter ?
0
fritz_the_blankCommented:
Any chance that you are picking up the VBCrLf?

FtB
0
Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

DexstarCommented:
funkyfinger:

Try running the string through this function first:

     Function FixString( strString )
          FixString = Trim( strString )
          FixString = Replace( FixString, vbNewLine, "" )
          FixString = Replace( FixString, vbCR, "" )
          FixString = Replace( FixString, vbLF, "" )
     End Function

Can anyone else think of any other values to throw in there?

Dex*
0
funkyfingerAuthor Commented:
With the FixString function I get different results
about 80% of the time I get a character for line 40 but not 39,
the character for line 40 has been random characters some of which are not valid GUID characters
This probably doesn't help but the characters are always
r, c, 5, 4, }
about 20% of the time I get the same results as before - no character

???
0
funkyfingerAuthor Commented:
The code callin the function is
 isGUID( Server.CreateObject("Scriptlet.TypeLib").GUID  )
0
funkyfingerAuthor Commented:
I also tried not passing the GUID but creating it in the function - same result
Even more confused
0
funkyfingerAuthor Commented:
- actually the characters are not random they are in a pattern rcc3c54r_ (where _ is no character)
0
DexstarCommented:
funkyfinger:

It isn't you.  I think this is a problem with the Scriptlet.TypeLib class.  I looked at the TypeLibrary for that object and the GUID property returns a string.  The string that it returns actually has a length of 40, even though it should only be 38.  You are not doing anything wrong.

For now, I would just add these lines to the top of isGUID:
     If Len(dataIn) > 38 Then
          dataIn = Left(dataIn, 38)
     End If

That will work around the issue...  I don't know why that module is returning the wrong string, but it isn't you, and you won't be able to fix it.  You'll just be able to work around it.

Dex*
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.