Click to See Complete Forum and Search --> : Newbie (to VB): Alternative include?
Kempis
Oct 4th, 2000, 07:28 PM
I'd like to dynamically include a file....
something like --#include virtual="<%=strTargetFile%>"--
There's gotta be a WAY!!! Did microsoft leave this idea out of the language?!?!?
-K
monte96
Oct 4th, 2000, 08:57 PM
This inserts the contents of the file literally where you put the include. Handy for creating reusable code..
<!--#include file="filename" -->
What you said will indeed literally include the file.
But now what if the file contains functions that I would rather not have displayed, or style sheets, for example.
How can I make it that I can still access those functions (and style sheets) without the actual code of those functions being included into my page (and thus not being retrievable when someone looks at the source when looking at my page) ?
Kempis
Oct 5th, 2000, 11:52 AM
Well, I've figured out my own question... Microsoft was worried about circular include statements, so it's impossible to have a dynamic include statement. I'm more used to PERL where if a file has already been included in another file, it gets ignored. The only way around it in VB is to use the HTML frameset tag and just make it a call.
Bleah. Yuk.
Now I have to make another set of header and footer files!
-K
Kempis
Oct 5th, 2000, 01:11 PM
Hey MarcelB I think the only way to do it would be to change the included file.
You could put an (if blflag <> true then) statement around the parts you don't want displayed.
I don't think there's any built-in way to include a file for it's functions only. O'course, I'm new here too. ^_^
-Mark
monte96
Oct 5th, 2000, 02:48 PM
I regularly include functions in include files. Just make sure your function page is enclosed in <% %> tags at the top and bottom and they will not be displayed but will be available just as though they were a part of your original page.
as for stylesheets:
This goes inside of your HEAD tags:
<link REL="STYLESHEET" HREF="mystylesheet.css" TYPE="text/css">
Clunietp
Oct 5th, 2000, 10:32 PM
It is possible to dynamically include files on the server side (using the FileSystemObject), but anything in these files will not be processed by the server as server side script....(which makes this useless in most cases)
Monty: Okay, thanx, that's what I was looking for for style sheets.. but can't I use something like that for functions aswell?
Kempis (I think, the replies fell off my screen) :
If I include functions using
<!--#include file="myfunctions.js"-->
and I ask for the source code in the page in IE5, I DO get the functions displayed. Try it out yourself.
So I'm still searching for a way to just be able to use those functions, without having them being displayed.
Thanx for thinking along though.. :)
monte96
Oct 6th, 2000, 09:25 AM
The sample I posted will work 100% for including server side script functions in the page and will absolutely not show up in the browser source or HTML stream.
If your talking about including client side script in the page, you can do this:
<script src="MyFunctions.js"></script>
Now the above will show up in the browser (The script tag only) but be aware that in order for client side script to work at all, it has to be on the client's machine so your .js file will be downloaded to the temporary internet files cache and run from there. Anyone with a fleeting knowledge of how IE stores files can easily go in there and get the code. But that will stop your average web page audience from seeing the code and will allow the functions to be available in the page on the client side.
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.