Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Global functions

Status
Not open for further replies.

AGNEW2PRG

Technical User
Aug 5, 2003
98
AE
Hi All,

Is there a way I can have a central file(s) that contains vbscript function(s) that can be called at any time?

I could use the includes file that is read on a page loading. Is there a better way?

For example I am using the code <%=replace((rsComments("Comments")),vbCr, "<BR>")%> in order to format the page properly. I'd like to setup a function that can format any text or file when the function is called.

Any tips..

Many thanks
 
I'm not sure I understand your question. Yes you could create an include file with a function that does what your doing above, then you would just include it in every page you need that function. No i can't think of another way to create an include file and add it to your code with including it (or using something like Server.Execute, etc).

If you just want to make that code into a funciton that can handle any text, then you would just do something like:
Code:
Function FormatOutput(outputText)
   FormatOutput = Replace(outputText,vbCr,"<br>"
End Function

Then everywhere you wanted to use it you would just call that function and pass it the text to format. So for your example above:
Code:
<%=FormatOutput(rsComments("Comments"))%>


I'm sorry if I misunderstod any part of your post. If I did, please let me know and maybe expand a little on what your looking for.

-T

barcode_1.gif
 
Thanks Tarwn,

I ended up using a include file.. But is it possible to call a external .vbs script that I can use inorder to get the same result..

If possible can you explain how its done..?



" New To Programming - Learning Fast :)
 
yeah...you can do it something like this:

<script language="VBScript" src="external.vbs"></script>
<script language="VBScript">
'write your script here..i mean call the functions here
</script>

-DNG
 
Thanks DNG,

Are there any restrictions to the number of .vbs external files you call from a single asp page ?

Thanks in advance!


" New To Programming - Learning Fast :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top