|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
1200+ fellow developers rate and compare features of the top IDEs, like Visual Studio, Eclipse, RAD, Delphi and others, across 13 categories. Enjoy this FREE Download of the IDE User Satisfaction Study by Evans Data Corporation. Download Now!
|
|
#1
|
||||
|
||||
|
calling a sub from another page
ok so here is what's happening. i've got two pages. they have the same name for two sub procedures that do pretty much the same thing and have the same number and types of arguments. i either run one page, the other page or both. when i run page1 it somehow is accessing page2 even if it isn't called with an include statement. so page1 is using the sub with the same name from another page even if it isn't included. so what's going on? is that normal? should i just make one page instead of 2? didn't think that sub's could jump accross pages that weren't included, but i could be wrong. any advice?
|
|
#2
|
|||
|
|||
|
My advice to you is to repost your question, don't get me wrong, I want to help you but I didn't understand a thing about your question...
sorryIf that helps though, include files are *ALWAYS* interpreted *BEFORE* the Server Side code. Assuming you have an include file that holds 5 Functions, even if you only need one function out of the 5, the engine *STILL* parses the ENTIRE include file Don't know if that helps or not but its good to know! Sincerely Vlince |
|
#3
|
||||
|
||||
|
sorry for the unclear description, i'll try again.
page1 contains the following sub sub getem(var1, var2) (outputs a recordsource, with a certain formatting) page2 contains the same sub sub getem(var1, var2) (outputs a recordsource, with a certain formatting) so i call either page1 or page2 or both based on a form variable. however, when i just include just page1 it uses the sub from page2. here is an example of my if statement if request.form("type") = 1 then <!--#include file="page1.asp"--> elseif request.form("type") = 2 then <!--#include file="page2.asp"--> elseif request.form("type") = 3 then <!--#include file="page1.asp"--> <!--#include file="page2.asp"--> else end if now say request.form("type") = 1 and page1 gets included, somehow it uses the sub from page2 instead of its own. |
|
#4
|
|||
|
|||
|
having two include pages with a function/sub with the same will not work. why would you ever want to include both? why would you expect that to work?
__________________
Programmer's Corner |
|
#5
|
||||
|
||||
|
one is for outputing one record source and the other for another record source. i would output both if i wanted to see records from the 2 tables. i suppose i could do it with one page, and just change the sql statement. but something else for you to chew on, why would you want to have 2 with the same name? overloading perhaps, but i don't know if vbscript supports that
![]() |
|
#6
|
|||
|
|||
|
no vb does not support overloading. also you are not overloading. overloading is having the same name with a different parameter list. your two subs have the same parameter list and therefore isn't valid. basically chew on this: if they both have the same name how does vb know which one to call? i would figure that something like that would cause a compile error. since it isn't the second must be overwritting the first and that is why the second is called.
|
|
#7
|
||||
|
||||
|
ok well that helps to know it doesn't support overloading. and yes, i know, its not overloading because the paramaters are the same. now i know to have just one page. thanks for the help!
![]() |
|
#8
|
|||
|
|||
|
Here is a great article that explains #include file, be sure to read it:
http://www.aspfaqs.com/aspfaqs/ShowFAQ.asp?FAQID=55 Also I might suggest a different approach such as: <%@ Language=VBScript %> <!--#include file="function.asp"--> <% Dim lngType lngType = Trim(Request.Form("type")) 'Validation of the type If lngType = "" Then Response.Write "No type was given...blah blah blah" Response.End 'or Response.Redirect... End If Call MySub(parameter1, parameter2, Clng(lngType )) %> The *idea* is to Request the type, put it inside a variable(lngType for example) then pass that variable into your Sub(MySub). Inside the Sub you can make a Select Case if you want This is a workaround that could/can help you if you want. Hope this helps! Sincerely Vlince |
|
#9
|
||||
|
||||
|
hey the readme was great! thanks again!
|
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ASP Programming > calling a sub from another page |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|