I have an ASP file (functions.asp) that holds a series of functions I call from several different .asp pages that display information to the user (display1.asp, display2.asp, etc). I include functions.asp at the top of each displayX.asp page which needs to use those functions, and it works fine.
Several of these functions contain long blocks of text that are identical in each function, and also need to be updated from time to time, so I'd like to put these long blocks of text into a single file and INCLUDE it within the functions. But I cannot figure out how to do this.
Here's an example of how these files are structured - here's the display1.asp file:
and here is the functions.asp file:
These are nonsensical made-up examples, obviously, but they correctly show the structure of my files. What I want to do is to take the common fixed text:
and place it into a file called "commonDataArray.asp" and then include this into each of the three functions. But I can't figure out if this is possible, and if it is how to format the INCLUDE statement within each function.
Anyone know how to do this? Your help would be much appreciated.
Several of these functions contain long blocks of text that are identical in each function, and also need to be updated from time to time, so I'd like to put these long blocks of text into a single file and INCLUDE it within the functions. But I cannot figure out how to do this.
Here's an example of how these files are structured - here's the display1.asp file:
Code:
<!-- #include virtual="functions.asp" --> <% 'does three calculations and displays the results to the user response.write "The result of the first calculation is " & calculation1("Bathroom light") & "<br>" response.write "The result of the second calculation is " & calculation2("Bathroom light") & "<br>" response.write "The result of the third calculation is " & calculation3("Bathroom light") & "<br>" %>
Code:
<% function calculation1(deviceName)[INDENT] [/INDENT][INDENT]'do a calculation and return the value dim data(3) data(1) = 10 data(2) = 20 data(3) = 30 calculation1 = data(1) + data(2) + data(3)[/INDENT] end function function calculation2(deviceName)[INDENT]'do a calculation and return the value dim data(3) data(1) = 10 data(2) = 20 data(3) = 30 calculation2 = (data(1)*2) + (data(2)*5) + (data(3)*10)[/INDENT] end function function calculation3(deviceName)[INDENT]'do a calculation and return the value dim data(3) data(1) = 10 data(2) = 20 data(3) = 30 calculation3 = (data(1) /20) + (data(2)/40) + (data(3)/60)[/INDENT] end function
Code:
dim data(3) data(1) = 10 data(2) = 20 data(3) = 30
Anyone know how to do this? Your help would be much appreciated.
Comment