Click to See Complete Forum and Search --> : #include equivalent in VBScript
kirants
February 10th, 2006, 02:31 PM
First off, I am predominantly from a C++ background and I don't know much about HTML/VBScript. So please excuse me if I sound silly.
Background:
Currently, the stuff I am working on uses HTML with VBScript portions in it.
The HTML pages load some ActiveX controls. Now, all these HTML pages are actually compiled and bundled into an exe and the exe when launched extracts all these pages and launches in an embedded IE browser.
Problem:
The activex objects are loaded thus within the HTML body
<object id="Lang" classid="CLSID:xx-yy-zz-dd"></object>
Note the xx-yy-zz-dd is currently hardcoded. What I would like to do is, to make this configurable. If I can relate to the way C++ works, I can think of using a header file with #defines for the classid and stick in the #define there.
I would like to be able to something similar if possible here. i.e. replace CLSID:xx-yy-zz-dd with something like CLSID:clsid_for_product, and include bundle a different file containing all these constants for different products.
Is such a thing possible with VBScript ? I have researched a bit and found something like a src="filename.ext" one can use in the script section. Is this the way to go ? or any other alternatives ?
PeejAvery
February 10th, 2006, 03:59 PM
I would like to be able to something similar if possible here. i.e. replace CLSID:xx-yy-zz-dd with something like CLSID:clsid_for_product, and include bundle a different file containing all these constants for different products.
First off for me, it is a priviledge to try to help you kirants. I have admired your work in the forums. I am not a C++ but more a scripting and VB guy.
A few questions...
1. How do you obtain the CLSID for the product?
2. Your problem rests in writing the CLSID dynamically?
Concerning the include statement, VBScript does not have one but there is a work around. I have referred this (http://www.source-code.biz/snippets/vbscript/5.htm) page to others. Maybe it can also help you.
I hope this helps. If I can help more, let me know.
kirants
February 10th, 2006, 04:12 PM
First off for me, it is a priviledge to try to help you kirants. I have admired your work in the forums. I am not a C++ but more a scripting and VB guy.Hey ! Thanks a lot.. I admire your work too.. :thumb: additonally I admire your flare/knife-juggling skills :D
1. How do you obtain the CLSID for the product?
It is fixed during deployment. i.e. when the exe is run, it's gonna use a fixed CLSID.. I want this alias kind of thing just to make code maintainence easy.
Somethign on these lines.. If I put the CLSID in a fixed file and refer to thsi file in the main HTML, I just have to swap out this fixed file containing the actual CLSIDs during deployment. I don't have to go around and have different versions of the main html file ( which has all the code ). I hope I am clear.
Something along the lines of CSS , I can say. If I have a html file with all the code fixed, I can change the appearance by merely switching to a different CSS file, right ? Likewise, I want to do this for CLSIDs of activex objects used.
2. Your problem rests in writing the CLSID dynamically?Not really, as I have explained earlier. This is more of a maintainence thing. Since the HTML pages have all the code, I don't want to make multiple copies of the HTML pages for each product just for this CLSID difference. I would rather have it in a seperate file. My problem is in how to pull in this seperate file into the main html file.
Concerning the include statement, VBScript does not have one but there is a work around. I have referred this (http://www.source-code.biz/snippets/vbscript/5.htm) page to others. Maybe it can also help you.
I hope this helps. If I can help more, let me know.
Thanks for the link. I did see that link in one of your earlier posts too. And it doesn't address the situation I am in ..
Thanks...
Note: coming to think of it, I am wondering if CSS would allow me to do this ..
PeejAvery
February 10th, 2006, 05:04 PM
Hey ! Thanks a lot.. I admire your work too.. :thumb: additonally I admire your flare/knife-juggling skills :D
Well, thank you!
Something along the lines of CSS , I can say. If I have a html file with all the code fixed, I can change the appearance by merely switching to a different CSS file, right ? Likewise, I want to do this for CLSIDs of activex objects used.
Shoot, if you think CSS can fix this, it is simple as can be to change CSS files. You can use document.write() to set the correct stylesheet. Just add to the end of the url something like ?id=NUMBER. Does this help?
<script language="JavaScript">
var url = window.location.href;
var ulength = url.length;
ulength = ulength - 1;
var xchar = url.charAt(ulength);
if(xchar==1){document.write("<link rel='stylesheet' href='style1.css' type='text/css'>");}
if(xchar==2){document.write("<link rel='stylesheet' href='style2.css' type='text/css'>");}
if(xchar==3){document.write("<link rel='stylesheet' href='style3.css' type='text/css'>");}
</script>
kirants
February 10th, 2006, 06:03 PM
Shoot, if you think CSS can fix this, it is simple as can be to change CSS files. You can use document.write() to set the correct stylesheet. Just add to the end of the url something like ?id=NUMBER. Does this help?
The problem is CSS cannot fix this particular issue for me :( because the CLSID is not a valid CSS property. I have been researching for a while and this is what I have figured out :cry:
PeejAvery
February 10th, 2006, 06:08 PM
The problem is CSS cannot fix this particular issue for me :( because the CLSID is not a valid CSS property. I have been researching for a while and this is what I have figured out :cry:
Well, I am sorry about that.
I will ponder this some more and see if my highly finite mind can think up anything whatsoever.
kirants
February 10th, 2006, 06:13 PM
I will ponder this some more and see if my highly finite mind can think up anything whatsoever.
Thanks a bunch :wave:
kirants
February 10th, 2006, 07:06 PM
peejavery, finally I seemed to have managed to get what I wanted.
Here is what I do:
In main.htm:
<HTML>
<BODY>
<object id="Lang"></object>
<!-- here include the clsid definition file -->
<script src="consts.htm" language="VBScript"></script>
<!-- here include the clsid definition file -->
<script language="VBScript">
<!-- now that consts.htm is included, use the constants to set the attribute -->
Lang.classid = CLSID_CONST_FOR_LANG_FROM_CONSTS_HTM_FILE
<!-- Proceed to do rest of stuff -->
</script>
</BODY>
</HTML>
In consts.htm:
Const CLSID_CONST_FOR_LANG_FROM_CONSTS_HTM_FILE = "CLSID:87204702-BEBF-4866-82FF-ECC7EEF41A0B"
So, now, consts.htm file is very much similar to a list of #defines and I can easily swap it out without changing the main.htm file
I don't know if this is the best/right/traditional/classic approach to deal with the problem and would appreciate any inputs on alternatives.
PeejAvery
February 11th, 2006, 12:26 AM
Congrats. I am impressed. I have been at my fiancee's house all night. What a pity you beat me to it. Nice work!
CyReVolt
February 11th, 2006, 12:36 PM
Anyway, to me this sounds like a simple php job. If your server supported PHP, I would have written some script similar to C++ - you do know that PHP is similar to C++? :-)
Maybe you will find that advice useful in future work. If possible, I write almost everything that shall be dynamically having to do with the content in PHP, layouts in CSS. The reason is: more and more people get afraid of scripting or just have their dislikes. Client-side page manipulation via scripting sounds odd to me anyway.
Have a nice day!
CyReVolt
PeejAvery
February 11th, 2006, 01:11 PM
Anyway, to me this sounds like a simple php job. If your server supported PHP, I would have written some script similar to C++ - you do know that PHP is similar to C++? :-)
Well, this is part of a package to be installed on local computers, not web servers. Kirants isn't going to want to install PHP on every machine just to run a PHP script.
CyReVolt
February 11th, 2006, 03:28 PM
I see... my bad, sorry. In that case scripting is fine! :)
Keep it going, scripting and hardcoding guys! ;)
kirants
February 11th, 2006, 06:02 PM
Well, this is part of a package to be installed on local computers, not web servers. Kirants isn't going to want to install PHP on every machine just to run a PHP script.
Yes. PHP is simply not the right thing here.
Keep it going, scripting and hardcoding guys!
Whatever you meant by this, you seemed to have missed the point of this thread. The issue was more about code maintainence here and not about server-client issues at all ;)
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.