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 MOD-Group
 MOD Add-On Forum (W/O Code)
 getCurrentIcon Exposed
 New Topic  Topic Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

@tomic
Senior Member

USA
1790 Posts

Posted - 02 September 2002 :  20:20:28  Show Profile  Visit @tomic's Homepage  Send @tomic an ICQ Message
This is the getCurrentIcon Function on inc_iconfiles.asp

function getCurrentIcon(fIconName,fAltText,fOtherTags)
	if fIconName = "" then exit function
	if fOtherTags <> "" then fOtherTags = " " & fOtherTags
	if Instr(fIconName,"http://") > 0 then strTempImageUrl = "" else strTempImageUrl = strImageUrl
	tmpicons = split(fIconName,"|")
	if tmpicons(1) <> "" then fWidth = " width=""" & tmpicons(1) & """"
	if tmpicons(2) <> "" then fHeight = " height=""" & tmpicons(2) & """"
	getCurrentIcon = "<img src=""" & strTempImageUrl & tmpicons(0) & """" & fWidth & fHeight & " border=""0"" alt=""" & fAltText & """ title=""" & fAltText & """" & fOtherTags & " />"
end function




Part 1. Making your image a Constant in inc_iconfiles.asp

Const strIconPmforward = "pmforward.jpg|63|42"
Const strIconPmdelete = "pmdelete.jpg|63|42"
Const strIconPmprivatemessage = "icon_privatemessage.gif|22|15"

These are instances in inc_iconfiles.asp of images used in the forum. Each is turned into a constant and is given a name.

name like strIconPmforward and it is uqual to the images filename(pmforward.jpg) | Width (22) | Height(15)
This should be pretty easy to get used to. This allows you to easily define our image and it's dimensions in one handy

location. Changes made to an image here are reflected across your entire forum. You will see why you want to use this and what is done with this in the next part.


Part 2. The getCurrentIcon Function

function getCurrentIcon(fIconName,fAltText,fOtherTags)
if fIconName = "" then exit function
if fOtherTags <> "" then fOtherTags = " " & fOtherTags
if Instr(fIconName,"http://") > 0 then strTempImageUrl = "" else strTempImageUrl = strImageUrl
tmpicons = split(fIconName,"|")
if tmpicons(1) <> "" then fWidth = " width=""" & tmpicons(1) & """"
if tmpicons(2) <> "" then fHeight = " height=""" & tmpicons(2) & """"
getCurrentIcon = "<img src=""" & strTempImageUrl & tmpicons(0) & """" & fWidth & fHeight & " border=""0"" alt=""" &

fAltText & """ title=""" & fAltText & """" & fOtherTags & " />"
end function

This is the function that your images call when you want one displayed. I'll break it down so you can see how this baby runs.
------------------------------


function getCurrentIcon(fIconName,fAltText,fOtherTags)

Here we have begun a function and given it a name and define what variables are going to be passed to it. We pass strings to the function rather than Request the values inside the function for better performance.

-------------------------------

if fIconName = "" then exit function

If there is no name we cannot proceed so we exit the function.

--------------------------------


if fOtherTags <> "" then fOtherTags = " " & fOtherTags

if fOtherTags is empty we add a space so that other tags won't end up shoved against each other when called.

--------------------------------


if Instr(fIconName,"http://") > 0 then strTempImageUrl = "" else strTempImageUrl = strImageUrl

First we see if the string has http:// in it. If it does it is larger than 0. So if it is then strTempImageUrl is null. If it doesn't have http:// in it then strTempImageUrl equals strImageUrl.

--------------------------------


tmpicons = split(fIconName,"|")

Use the split function which is:

Split

PURPOSE: Returns a zero-based, one-dimensional array containing a specified number of substrings.
DATA TYPE: Array
SYNTAX: Split(string [, delimiter[, count[, compare]]])


So as you recall you are using the constants you defined on inc_iconfiles.asp and they look like this -

Const strIconPmprivatemessage = "icon_privatemessage.gif|22|15"

So, Split creates 2 substring because there are 2 "|" in it.

We now call this array tmpicons.

---------------------------------


if tmpicons(1) <> "" then fWidth = " width=""" & tmpicons(1) & """"
if tmpicons(2) <> "" then fHeight = " height=""" & tmpicons(2) & """"

These are the two substrings. tmpicons(0) is the icon's filename and tmpicons(1) is the width and tmpicons(1) is the height.
So if both of these are not null then fWidth equals " width=""" & tmpicons(1) & """ and fHeight equals "height="""" &

tmpicons(2) & """"

----------------------------------

getCurrentIcon = "<img src=""" & strTempImageUrl & tmpicons(0) & """" & fWidth & fHeight & " border=""0"" alt=""" & fAltText

& """ title=""" & fAltText & """" & fOtherTags & " />"
end function

Here we put it all together and get out of Dodge.


getCurrentIcon now equals "< img src""" Nothing fancy here. We have just begun an image tag.

& strTempImageUrl & tmpicons(0) & """"
Here we add the path to the image and the file name.

& fWidth & fHeight
Here we add those 2 strings with the " height=""" & tmpicons(1) & """" etc.

border=""0""

We usually don't like a border do we? I didn't think so.

alt=""" & fAltText & """ title=""" & fAltText & """" & fOtherTags & " />"

If, when you are calling this function you have defined some ALT text then it will be there as faltText and the TITLE is also set to be the faltText. At the end we shall place the fOtherTags we may or may not have defined when the function is called

and we shall dive right into how it's used in the next section.

The last bit is end function as all good functions have that.


part 3. Calling getCurrentIcon

" & getCurrentIcon(strIconPmforward,"Forward This Message","hspace=""0""") & "

This is how it should look in your code if the page is all Response.Write and as you can see it is concatenated and ready for action.

getCurrentIcon
This calls the function and all it does.

(strIconPmforward,
This is the name of the constant in inc_iconfiles.asp

"Show All Categories",
This is the ALT text we talked about. You put whatever you want it to say here. If you do not want ALT text put "" in it so

the example would look like:
"",

"hspace=""0""") & "

Here is the fOtherTags and we have decided to use hspace. It could have been vspace or align. Whatever you think is best. We can now move on to other business and this is how you call getCurrentIcon. If you do not want anything here at least leave "".

The minimal usage of this function would be:
" & getCurrentIcon(strIconPmforward,"","") & "

So now you should see why we define our images as constants on inc_iconfiles.asp, how the function getCurrentIcon takes this constant and sets the values it has into the bits and pieces that make an image tag out of the constant and assemblies them into a ready made image tag. You should also understand how to call the getCurrentIcon by giving it a string name that turns into the image file's name, ALT text or at least "", and some other attribute like align or hspace or at least "".

I hope some of you can make use of this in writing your MODs.

@tomic

SportsBettingAcumen.com

Edited by - @tomic on 02 September 2002 20:22:14
  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.34 seconds. Powered By: Snitz Forums 2000 Version 3.4.07