SunQuest
           ASP Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreASP Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
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  
Old August 4th, 2003, 03:07 PM
don_sparko's Avatar
don_sparko don_sparko is offline
Digitally Challenged
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2003
Posts: 280 don_sparko User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 54 m 14 sec
Reputation Power: 6
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?

Reply With Quote
  #2  
Old August 4th, 2003, 03:13 PM
Vlince Vlince is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Location: Canada, Quebec, Montreal
Posts: 410 Vlince User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
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... sorry

If 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

Reply With Quote
  #3  
Old August 4th, 2003, 03:37 PM
don_sparko's Avatar
don_sparko don_sparko is offline
Digitally Challenged
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2003
Posts: 280 don_sparko User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 54 m 14 sec
Reputation Power: 6
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.

Reply With Quote
  #4  
Old August 4th, 2003, 04:01 PM
nopoints nopoints is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Location: Windsor ON, Canada
Posts: 459 nopoints User rank is Corporal (100 - 500 Reputation Level)nopoints User rank is Corporal (100 - 500 Reputation Level)nopoints User rank is Corporal (100 - 500 Reputation Level)nopoints User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 13 h 44 m 22 sec
Reputation Power: 8
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

Reply With Quote
  #5  
Old August 4th, 2003, 04:08 PM
don_sparko's Avatar
don_sparko don_sparko is offline
Digitally Challenged
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2003
Posts: 280 don_sparko User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 54 m 14 sec
Reputation Power: 6
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

Reply With Quote
  #6  
Old August 4th, 2003, 04:19 PM
nopoints nopoints is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Location: Windsor ON, Canada
Posts: 459 nopoints User rank is Corporal (100 - 500 Reputation Level)nopoints User rank is Corporal (100 - 500 Reputation Level)nopoints User rank is Corporal (100 - 500 Reputation Level)nopoints User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 13 h 44 m 22 sec
Reputation Power: 8
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.

Reply With Quote
  #7  
Old August 4th, 2003, 04:23 PM
don_sparko's Avatar
don_sparko don_sparko is offline
Digitally Challenged
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2003
Posts: 280 don_sparko User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 54 m 14 sec
Reputation Power: 6
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!

Reply With Quote
  #8  
Old August 5th, 2003, 07:22 AM
Vlince Vlince is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Location: Canada, Quebec, Montreal
Posts: 410 Vlince User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
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

Reply With Quote
  #9  
Old August 5th, 2003, 10:49 AM
don_sparko's Avatar
don_sparko don_sparko is offline
Digitally Challenged
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2003
Posts: 280 don_sparko User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 54 m 14 sec
Reputation Power: 6
hey the readme was great! thanks again!

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreASP Programming > calling a sub from another page


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway