Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > VB Script

Vista - question on: HTA and format to include external script file

Reply
 
Old 10-23-2008   #1 (permalink)
James


 
 

question on: HTA and format to include external script file

Noticed when playing with HTA that this:

<SCRIPT Language="VBScript" src="testinc.vbs"/>

caused problems but this:

<SCRIPT Language="VBScript" src="testinc.vbs"></script>

did not?

specifics on the problem one:
the include file *is* still included and I can call procedures from it from
within the main HTA's <script> section but I can't call procedures that are
actually defined *in* the main HTA's <script> section? error is: Type
Mismatch: 'procedurename'. Obviously 'procedurename' is the name of the
function or sub being called.

1. wanted to confirm this is by design and I don't need an update or
something?

2. is this specific to HTA's? or is it the same when using scripts in
regular web pages?

3. general enlightenment on this is greatly desired.

here is example of what I'm talking about. In the code below when the hta is
opened the Window_Onload procedure is not run, no error, and when you click
the button which simply calls the Window_Onload procedure you get the type
mismatch error. If you change the way you include testinc.vbs file to:
<SCRIPT Language="VBScript" src="testinc.vbs"></script>
then there is no problem. Note: example is not using anything from the
testinc.vbs file, its just the structure of how its included that is
relevant.
--------------------
<html>
<head>
<title>HTA Helpomatic</title>

<HTA:APPLICATION
ID="objHTAHelpomatic"
APPLICATIONNAME="HTAHelpomatic"
SCROLL="yes"
SINGLEINSTANCE="yes"
WINDOWSTATE="maximize"
Quote:

>
<SCRIPT Language="VBScript" src="testinc.vbs"/>
<SCRIPT Language="VBScript">

Sub Window_Onload
Msgbox "The application has started."
End Sub

</SCRIPT>
</head>

<body>

<h1>In the body</h1>
<input type="button" value="test" onclick="Window_Onload">

</body>
</html>
---------------------



My System SpecsSystem Spec
Old 10-23-2008   #2 (permalink)
gimme_this_gimme_that


 
 

Re: question on: HTA and format to include external script file

Store these three files in a folder and click on create_report.hta.

---
create_report.hta

<head>
<title>Data Reconciliation</title>
<HTA:APPLICATION
APPLICATIONNAME="Data Reconciliation"
SCROLL="no"
SINGLEINSTANCE="yes"
Quote:

>
</head>

<script language="vbscript">
window.resizeto 600,220
window.moveto 100,100
</script>

<script language="VBScript">

Function GetPath(Path)
ix=InstrRev(Path,"\")
Path=Left(Path,ix)
GetPath = Path
End Function

Function CreateReport
File1 = escape(document.aForm.elements("file1").value)
File2 = escape(document.aForm.elements("file2").value)
Set WSH = CreateObject("WScript.Shell")
WSH.Run("from_hta.vbs " & Chr(34) & File1 & Chr(34) & " " &
Chr(34) & File2 & Chr(34))
Window.Close
End Function

</script>

<body bgcolor="lightblue">
<center>
<form name="aForm">
<table border="1" bordercolor="darkblue" width="94%">
<tr>
<td align="center"><font color="darkblue"><h2>Data
Reconciliation</h2>
</td>
</tr>
</table>
<table border="1" bordercolor="darkblue" width="94%">
<tr>
<td><nobr>Full Path to TXT File 1: </nobr></td><td><input
type="file" name="file1" style="width: 250px" value="" /></td>
</tr>
<tr>
<td><nobr>Full Path to TXT File 2: </nobr></td><td><input
type="file" name="file2" style="width: 250px" value=""/></td>
</tr>
<tr>
<td colspan="2" align="center"><input type="button"
value="Create Report" name="run_button" onClick="CreateReport"></td>
</tr>
</table>
</form>
</center>
</body>

----------

Then from_hta.vbs looks like:

Dim HR_FILE_CORP, HR_FILE_PROT

Sub Include(sInstFile)
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set f = oFSO.OpenTextFile(GetPath() & sInstFile)
s = f.ReadAll
f.Close
ExecuteGlobal s
End Sub

Function GetPath()
Path=WScript.ScriptFullName
ix=InstrRev(Path,"\")
Path=Left(Path,ix)
GetPath = Path
End Function

Include "Build.vbs"

Sub FromHTA()
Set objArgs = WScript.Arguments
HR_FILE_CORP = objArgs(0)
HR_FILE_PROT = objArgs(1)
Main HR_FILE_CORP, HR_FILE_PROT
End Sub

FromHTA()

---------

Then Build.vbs looks like:

Sub Main(HR_FILE_CORP, HR_FILE_PROT)
'Main is called from from_hta.vbs
ExcelSetUp()
i = 2
Call enummembers(ObjDomain)
ExcelWrapUp()
MsgBox "Done"
End Sub




My System SpecsSystem Spec
Old 10-23-2008   #3 (permalink)
gimme_this_gimme_that


 
 

Re: question on: HTA and format to include external script file

Hey James,

What's with your account being banded by Google? Ouch!

This account has been banned because it violated the Google Groups
Terms Of Use.
My System SpecsSystem Spec
Old 10-23-2008   #4 (permalink)
gimme_this_gimme_that


 
 

Re: question on: HTA and format to include external script file

James,

Where you ask why one of these works and not the other ...


<SCRIPT Language="VBScript" src="testinc.vbs"/>
caused problems but this:
<SCRIPT Language="VBScript" src="testinc.vbs"></script>

I don't have time to test this ...

It's an IE script loading thing. Not a VBScript thing. Try loading
JavaScript scripts similarly and see what happens.




My System SpecsSystem Spec
Old 10-23-2008   #5 (permalink)
mayayana


 
 

Re: question on: HTA and format to include external script file

>
Quote:

> - not sure what you mean by xml-ize 'ing HTML tags?
>
The format of using /> in place of a closing tag is
XHTML. It's a way for HTML to be written in
conformance with XML. I've never understood why
that's necessary. I'm guessing that it's just part of
the general XML mania. As I understand it, XHTML adds
room for expansion beyond basic HTML, particularly in terms
of dynamic content. But it also adds room for more
browser compatibility issues. So I don't see why anyone
would ever choose to use XHTML notation unless they
specifically need it in a given page, to provide XHTML-specific
functionality, targetted at specific, supporting browsers.
Quote:

> - same behavior with space added
>
That is strange. I get the exact same behavior that
you described. (Using IE5.) I can only guess that IE
is confused, not recognizing the XHTML script tag. But,
again, it's easy enough to fix and I don't know of any
reason to use XHTML. (I tried adding a DOCTYPE and an
extended HTML tag to my sample but they had no effect.)

I've got the following:
--------------------
<HTML>
<HEAD>
<TITLE></TITLE>
<SCRIPT LANGUAGE="VBScript" SRC="test2.vbs"> </SCRIPT>
<SCRIPT LANGUAGE="VBScript">
Sub ok2()
MsgBox "ok2"
ok
End Sub
</SCRIPT>

</HEAD>
<BODY onload="ok2()" BGCOLOR="#FFFFFF" TEXT="#000000">
</BODY></HTML>
--------------
The file test2.vbs contains this:

-------------
Sub ok()
MsgBox "ok"
End Sub
-------------

As you described, I see 2 message boxes, "ok2"
and "ok". That's as it should be. With the XHTML
version I get the type mismatch error that you
described. (I get the same error if I just remove
the </script> tag.)





My System SpecsSystem Spec
Old 10-23-2008   #6 (permalink)
James


 
 

Re: question on: HTA and format to include external script file

banned by Google? What do you mean? I don't use google for newsgroups, at
least not directly? Maybe its someone else that uses noone@xxxxxx as
their email to avoid spam? I really don't know but I'm posting directly to
microsoft forum from outlook express, I don't even log in. Have been doing
this for several years.

<gimme_this_gimme_that@xxxxxx> wrote in message
news:30af1759-409a-4a3a-b185-9fe548914634@xxxxxx
Quote:

> Hey James,
>
> What's with your account being banded by Google? Ouch!
>
> This account has been banned because it violated the Google Groups
> Terms Of Use.

My System SpecsSystem Spec
Old 10-23-2008   #7 (permalink)
James


 
 

Re: question on: HTA and format to include external script file

ok, thanks for the input.

<gimme_this_gimme_that@xxxxxx> wrote in message
news:dce85c1b-cd38-4d95-ae11-78b0dd0ce098@xxxxxx
Quote:

> James,
>
> Where you ask why one of these works and not the other ...
>
>
> <SCRIPT Language="VBScript" src="testinc.vbs"/>
> caused problems but this:
> <SCRIPT Language="VBScript" src="testinc.vbs"></script>
>
> I don't have time to test this ...
>
> It's an IE script loading thing. Not a VBScript thing. Try loading
> JavaScript scripts similarly and see what happens.
>
>
>
>

My System SpecsSystem Spec
Old 10-26-2008   #8 (permalink)
David Kerber


 
 

Re: question on: HTA and format to include external script file

James wrote:
Quote:

> banned by Google? What do you mean? I don't use google for newsgroups, at
> least not directly? Maybe its someone else that uses noone@xxxxxx as
I'm pretty sure that's the case; I've seen that return address in other
groups where the user's name is not the same as yours.

Quote:

> their email to avoid spam? I really don't know but I'm posting directly to
> microsoft forum from outlook express, I don't even log in. Have been doing
> this for several years.
>
> <gimme_this_gimme_that@xxxxxx> wrote in message
> news:30af1759-409a-4a3a-b185-9fe548914634@xxxxxx
Quote:

>> Hey James,
>>
>> What's with your account being banded by Google? Ouch!
>>
>> This account has been banned because it violated the Google Groups
>> Terms Of Use.
D

My System SpecsSystem Spec
Old 10-27-2008   #9 (permalink)
gimme_this_gimme_that


 
 

Re: question on: HTA and format to include external script file

It’s up to the browser to apply the CSS rules to it’s internal
representation of the parsed HTML data.



The drawback with HTML is that you can have open-ended elements like
<p> and end up nesting elements on accident. I don’t know, but this
could potentially make your CSS act funny if you have CSS rules for
nested elements.



Also, in HTML some elements are implicit like <tbody> in a <table>. If
you write a CSS rule that targets tbody tr, for example, it would work
in HTML but not in XHTML. In XHTML that element is no implicit -
though it actually varies from browser to browser.

My System SpecsSystem Spec
Old 10-27-2008   #10 (permalink)
mayayana


 
 

Re: question on: HTA and format to include external script file

>
The drawback with HTML is that you can have open-ended elements like
<p> and end up nesting elements on accident. I don't know, but this
could potentially make your CSS act funny if you have CSS rules for
nested elements.

Also, in HTML some elements are implicit like <tbody> in a <table>. If
you write a CSS rule that targets tbody tr, for example, it would work
in HTML but not in XHTML. In XHTML that element is no implicit -
though it actually varies from browser to browser.
Quote:

>
I don't see any problem there. What you're
talking about is badly written HTML, not a CSS
issue. But I guess XHTML is OK as long as you
test in in different browsers.



My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
include file name in output PowerShell
Include another script, keep variables in included script? PowerShell
get-childitem -include question PowerShell
One more question on -LiteralPath and -Include/-Exclude for GetChi PowerShell
Get-ChildItem -Recurse -Include pattern question... PowerShell


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46