S
Steven Scaife
I have decided to re-write the intranet site i created over a year ago. The
coding is pretty awful and hard to read cos I made the mistake of not
putting comments in or putting crappy comments in with the code. So I have
decided to try and make things neater by grouping it into subs. So i have a
sub to create the variables, a sub for the connection etc.
Only problem is when i call my subs, it says that the variable is undefined.
If i scrap the subs and put everything into the order they would be the page
works. I use the subs it doesn't.
Can anyone offer any insight or point me to a page that describes in detail
the solution i am trying to achieve
thanks in advance
sample code below.
my page would look something like
<body bgcolor="#FFFFFF" text="#000000" link="#804040" vlink="#008080"
alink="#004080">
<%
declareVar()
%>
<!--#include file="connection/connstring.inc"-->
<%
DBStrings()
%>
my subs are below as an example.
<%
sub declareVar()
'The declaration section
dim conn
dim strconn
dim physicaldbpath
dim strSQL
Dim RS
dim F
dim X
end sub
%>
<%
sub DBStrings()
set conn = server.createobject("adodb.connection")
conn.open strconn
strSQL = "Select Name, Number, Full_Number From AB_Dials;"
set RS = conn.execute(strSQL)
end sub
%>
<%
sub connClose()
RS.close
set RS = nothing
conn.close
set conn = nothing
end sub
%>
coding is pretty awful and hard to read cos I made the mistake of not
putting comments in or putting crappy comments in with the code. So I have
decided to try and make things neater by grouping it into subs. So i have a
sub to create the variables, a sub for the connection etc.
Only problem is when i call my subs, it says that the variable is undefined.
If i scrap the subs and put everything into the order they would be the page
works. I use the subs it doesn't.
Can anyone offer any insight or point me to a page that describes in detail
the solution i am trying to achieve
thanks in advance
sample code below.
my page would look something like
<body bgcolor="#FFFFFF" text="#000000" link="#804040" vlink="#008080"
alink="#004080">
<%
declareVar()
%>
<!--#include file="connection/connstring.inc"-->
<%
DBStrings()
%>
my subs are below as an example.
<%
sub declareVar()
'The declaration section
dim conn
dim strconn
dim physicaldbpath
dim strSQL
Dim RS
dim F
dim X
end sub
%>
<%
sub DBStrings()
set conn = server.createobject("adodb.connection")
conn.open strconn
strSQL = "Select Name, Number, Full_Number From AB_Dials;"
set RS = conn.execute(strSQL)
end sub
%>
<%
sub connClose()
RS.close
set RS = nothing
conn.close
set conn = nothing
end sub
%>