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

 All Forums
 Snitz Forums 2000 DEV-Group
 DEV Discussions (General)
 funtion sGetColSpan?
 New Topic  Topic Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

Davio
Development Team Member

Jamaica
12217 Posts

Posted - 20 February 2004 :  20:51:48  Show Profile
Can someone explain how this function works?
Function sGetColspan(lIN, lOUT)
	if (strShowModerators = "1") then lOut = lOut + 1
	if (mlev = "4" or mlev = "3") and (strShowModerators = "1") then lOut = lOut + 1
	if (mlev = "4" or mlev = "3") and (strShowModerators <> "1") then lOut = lOut + 2
	if lOut > lIn then
		sGetColspan = lIN
	else
		sGetColspan = lOUT
	end if
End Function
I know how it works, but how do you go about knowing what numbers to send to the function? What's the logic behind it?

For example: sGetColspan(7,6)
I thought that if no extra columns are needed, it would return the 7 (lIN) but if extra columns are needed, start with 6?

I dunno, this function isn't making sense to me.

Support Snitz Forums

Nikkol
Forum Moderator

USA
6907 Posts

Posted - 20 February 2004 :  21:59:20  Show Profile
Just thinking through this out loud. This is to determine whether or not to show the Moderator column. So, with your example the choices are either 7 or 6. 7 if Moderators are to be shown, 6 if not.

So, for normal users, two possilbe cases, show moderators or not:
1. show moderators lOUT = lOUT + 1 = 7 ... check at end is 7 > 7 ... no, so return lOUT = 7
2. do not show moderators lOUT = 6 ... check at end is 6 > 7 ... no, so return lOUT = 6
both seem okay

For moderators and admin, moderators are always shown, so because of first if statement, lOUT may have been modified and it needs to be readjusted to account for moderators and admin:
1. strShowModerators = "1" ... first if makes lOUT = lOUT + 1 = 7 ... second if makes lOUT = lOUT + 1 = 8 ... check at end is 8 > 7 ... yes, so return lIN = 7
2. strShowModerators <> "1" ... first and second if not true .... third if makes lOUT = lOUT + 2 = 8 ... check at end is 8 > 7 ... yes, so return lIN = 7

seems like a strange way to accomplish this, but it works. I would have used something like
Function sGetColspan(lIN, lOUT)
	sGetColspan = lOUT
	if (mlev = "4" or mlev = "3") or (strShowModerators = "1") then sGetColspan = lIN
End Function

Nikkol ~ Help Us Help You | ReadMe | 3.4.03 fixes | security fixes ~
Go to Top of Page

Davio
Development Team Member

Jamaica
12217 Posts

Posted - 21 February 2004 :  09:41:57  Show Profile
Yeah, at least your function would have made some sense.

Thanks for the break down though.

Support Snitz Forums
Go to Top of Page

MasterOfTheCats
Junior Member

103 Posts

Posted - 21 February 2004 :  14:15:17  Show Profile
So, in any case the two parameters are consecutive numbers. You can just use one parameter like:


Function sGetColspan(intNoModColumns)
	sGetColspan = intNoModColumns
	if (mlev = "4" or mlev = "3") or (strShowModerators = "1") then sGetColspan = intNoModColumns + 1
End Function

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.2 seconds. Powered By: Snitz Forums 2000 Version 3.4.07