Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Help Groups for Snitz Forums 2000 Users
 Help: MOD Implementation
 getMemberName - Function gone bad?
 New Topic  Topic Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

Zuel
Average Member

USA
540 Posts

Posted - 17 April 2006 :  10:25:39  Show Profile  Visit Zuel's Homepage
Is this function known to distrupt loops counters?

I have a loop and in that loop I have Member ID's.
I'm trying to convert them to their respective username.

Everytime the counter variable, which is i, hits that function; it gets set to the number 5.
When I take out the getMemberName() function, all works again.

wtf?

Good Preview - Without the getMemberName()
http://www.twistingshadows.com/userimages/good.html

Bad Preview - With the getMemberName()
http://www.twistingshadows.com/userimages/bad.html

Good HTML
http://www.twistingshadows.com/userimages/good.txt

Bad HTML
http://www.twistingshadows.com/userimages/bad.txt

First code snippet is a chunck that you see in the screenshots.
Just displays information. You see the isAvatarOwner(File.Name) calls my function below.
Then the pain starts.


'=== Determine the Type of User ===
Select Case (mLev)
	Case 4
		StringBuilder.AddString "		<td align=""center"" width=""20%"" style=""border-style: solid; border-color: " & strPopUpBorderColor & "; border-width: 1px 0px 1px 0px; border-collapse: separate;"">" & vbCRLF
		StringBuilder.AddString "			<span alt=""Click to delete image."" title=""Click to delete item."">" & scriptDelete & "</span></font><br>" & vbCRLF						
		StringBuilder.AddString "			<table width=""" & intAvatarWidth & """ height=""" & intAvatarHeight & """ cellspacing=""0"" cellpadding=""0"" border=""0"" style=""background-image: url('" & fullpath & "');background-repeat: no-repeat; background-position: center;"">" & vbCRLF
		StringBuilder.AddString "				<tr>" & vbCRLF
		StringBuilder.AddString "					<td align=""center""><span alt=""Click to assign yourself this Avatar."" title=""Click to assign yourself this Avatar."">" & scriptAssign & "</span></td>" & vbCRLF
		StringBuilder.AddString "				</tr>" & vbCRLF
		StringBuilder.AddString "			</table>" & vbCRLF
		StringBuilder.AddString "			<font face=""" & strDefaultFontFace & """ size=""" & strDefaultFontSize & """>" & File.Name & "<br>Owner: " & isAvatarOwner(File.Name) & "</font>" & vbCRLF
		StringBuilder.AddString "		</td>" & vbCRLF
	Case Else: '=== Do Nothing ===					
End Select


Function isAvatarOwner(ThisAvatar)
	Dim strSql, rsGetMembersAvatar
	Dim avatarData
		
	strSql = "SELECT A_URL, A_MEMBER_ID "
	strSql = strSql & "FROM FORUM_AVATAR "
	strSql = strSql & "WHERE A_URL = '" & avatarFolderPath & privateFolderName & "/" & ThisAvatar & "'"
		
	Set rsGetMembersAvatar = Server.CreateObject("ADODB.Recordset")
	
	'=== Open Database Connection ===
	rsGetMembersAvatar.open strSql, my_Conn, adOpenForwardOnly, adLockReadOnly, adCmdText
	
	'=== Check For A Record ===
	Select Case (rsGetMembersAvatar.EOF)
		Case True: isAvatarOwner = "N/A"
		Case Else
			avatarData    = rsGetMembersAvatar.GetRows()
			isAvatarOwner = getMemberName(avatarData(1, 0))
	End Select
	
	'=== Clear Memory ===
	rsGetMembersAvatar.Close
	Set rsGetMembersAvatar = Nothing
Exit Function
End Function


The reason why I say loop counters is because I have code
that checks the loop counter to know when to end the table row.
If the function keeps setting it to 5 then either will happen:

a. Table never ends
b. Table always ends.

In the code you see the table always ends. Gah....

My Completed Mods: News Mod | Zuel's Avatar Add-on
In Development: World of Warcraft Member Roster | [C# Based Forum]

Note - I may take a few days to recieve your email. Hotmail filters all new emails as junk. Would be best to post all questions, concerns in a forum topic to catch my immediate attention. This way others can assist and also correct any similar mistakes.

MSN / E-Mail: ucyimDa_Ruler@Hotmail.com

Personal Bookmarks: How to work a DBS File

Edited by - Zuel on 17 April 2006 10:30:41

HuwR
Forum Admin

United Kingdom
20584 Posts

Posted - 17 April 2006 :  15:05:09  Show Profile  Visit HuwR's Homepage
it should have no effect on your counter whatsoever, so you need to look elsewhere to find the culprit
Go to Top of Page

Zuel
Average Member

USA
540 Posts

Posted - 17 April 2006 :  16:07:51  Show Profile  Visit Zuel's Homepage
I'll look at it later. Can't find it right now. Just doesn't seem right, everything works fine without that function. There's is nothing in it that I renamed anywhere else, no clue what could cause that.

I'll find it later, hopefully.

My Completed Mods: News Mod | Zuel's Avatar Add-on
In Development: World of Warcraft Member Roster | [C# Based Forum]

Note - I may take a few days to recieve your email. Hotmail filters all new emails as junk. Would be best to post all questions, concerns in a forum topic to catch my immediate attention. This way others can assist and also correct any similar mistakes.

MSN / E-Mail: ucyimDa_Ruler@Hotmail.com

Personal Bookmarks: How to work a DBS File
Go to Top of Page

Zuel
Average Member

USA
540 Posts

Posted - 18 April 2006 :  16:33:34  Show Profile  Visit Zuel's Homepage
quote:
Originally posted by HuwR

it should have no effect on your counter whatsoever, so you need to look elsewhere to find the culprit



I found the culprit. It wasn't that function, it was the chkBadWords function.

Function chkBadWords has a loop and in that loop it uses the variable i to the Upper Bound of how many badwords there are. Default is 5; which is why I always got 5 after the first loop.

Problem:
The reason why this function is messing things up is because I globalized a the common variable i. A big no no I guess.

Solution:
I removed the global and added it to the private sub routine and now everything works as intended.

Conclusion:
I was 1/2 way right. I was fed up with not being able to use that function so I built my own then compared the differences. I saw that chkString function was being used so I added it. Then the problems started. After tracking it down I found the problem.

I guess this makes good a modding note. Never declare i globally. (I guess this should be true with all Applications.)

My Completed Mods: News Mod | Zuel's Avatar Add-on
In Development: World of Warcraft Member Roster | [C# Based Forum]

Note - I may take a few days to recieve your email. Hotmail filters all new emails as junk. Would be best to post all questions, concerns in a forum topic to catch my immediate attention. This way others can assist and also correct any similar mistakes.

MSN / E-Mail: ucyimDa_Ruler@Hotmail.com

Personal Bookmarks: How to work a DBS File
Go to Top of Page

AnonJr
Moderator

United States
5768 Posts

Posted - 18 April 2006 :  19:53:52  Show Profile  Visit AnonJr's Homepage
quote:
Originally posted by Zuel

Never declare i globally. (I guess this should be true with all Applications.)
Never made that mistake ... again ...

Its amazing the things you are suddenly reminded of during your coding sessions.
Go to Top of Page

Zuel
Average Member

USA
540 Posts

Posted - 19 April 2006 :  09:58:34  Show Profile  Visit Zuel's Homepage
Yeah, that is one part of the eletric fence I'll never touch again.

My Completed Mods: News Mod | Zuel's Avatar Add-on
In Development: World of Warcraft Member Roster | [C# Based Forum]

Note - I may take a few days to recieve your email. Hotmail filters all new emails as junk. Would be best to post all questions, concerns in a forum topic to catch my immediate attention. This way others can assist and also correct any similar mistakes.

MSN / E-Mail: ucyimDa_Ruler@Hotmail.com

Personal Bookmarks: How to work a DBS File
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Topic Locked
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.3 seconds. Powered By: Snitz Forums 2000 Version 3.4.07