Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

win32 Pipes in HTA(piping dynamic html to client applications)

Status
Not open for further replies.

Phalanx1

Programmer
Jul 21, 2003
128
US
<html>
<head>
<meta name=&quot;GENERATOR&quot; content=&quot;SAPIEN Technologies PrimalScript 3.0&quot;>
<title>Document Title</title>
</head>
<body id=&quot;Bel&quot;>
<div id=&quot;Response&quot;></div>
<h2>Test of a PerlScript function being called from VBScript</h2>
<p>
<input type=&quot;text&quot; id=&quot;PipeCreate&quot; value=&quot;&quot;>
<input type=&quot;button&quot; onclick=&quot;PipeCreate(document.all.PipeCreate.value);&quot; value=&quot;Create Pipe&quot;><br>
<input id=&quot;WriteThis&quot; type=&quot;text&quot; size=&quot;15&quot; value=&quot;&quot;>
<input type=&quot;button&quot; onclick=&quot;WriteToPipe(document.all.WriteThis.value)&quot; value=&quot;Write To Created Pipe&quot;>
<input type=&quot;button&quot; onclick=&quot;ReadFromPipe&quot; value=&quot;Read Pipe&quot;>
</p>
<form method=&quot;POST&quot; action=&quot;&quot; onsubmit=&quot;javascript:return false&quot;>
<p><input type=&quot;button&quot; value=&quot;Close&quot; onclick=&quot;javascript:self.close();&quot;></p>
</form>
<p>
</p>
<iframe src=&quot;PerlServer.htm&quot; id=&quot;PerlServ&quot; style=&quot;height:0px;width:0px;border:0px&quot;></iframe>

<script language=&quot;PerlScript&quot;>
use IO::Socket::INET;
use Win32::pipe;
$pipe = @_;
sub WriteToPipe {
$WhatToWrite= @_;
$OurPipe = new Win32::pipe->(&quot;$pipe&quot;);
$OurPipe->connect(&quot;$pipe&quot;);
$pipe->write(&quot;$WhatToWrite&quot;);
$OurPipe->close();
}
sub ReadFromPipe {
$OurPipe->connect(&quot;$pipe&quot;);
$Data = $OurPipe->read($pipe)
$DatRetVal=(&quot;This Is The Data:$Data\n&quot;);
$window->alert(&quot;$DatRetVal&quot;);
$OurPipe->close();
}
sub PipeCreate {
$OurPipe = new Win32::pipe(&quot;\\\\.\\Pipe\\$pipe&quot;);
}
sub sayHello {
# This function takes two parameters, creates a string
# from the parameters, and returns the string.

# get the two parameters into local variables
my ($strName, $strTime) = @_;
#now, create the return string.
$strRetVal=&quot;Hello $strName. The time is $strTime.&quot;;

# Return the string
$strRetVal;
}
</script>
<script language=&quot;PerlScript&quot;>

my @win =$window->alert(&quot;hello World!\n&quot;);
@win =$window->alert(&quot;The World is ours that know perl.&quot;);
$window->alert(@win);
chomp($newdir = &quot;C:\\&quot;);
chdir($newdir) || die &quot;Cannot chdir to $newdir: $!&quot;;
foreach (<*>) {
$window->alert(&quot;$_\n&quot;);
}
</script>
<Script language=&quot;vbscript&quot;>
strOutput=sayHello(&quot;Visitor&quot;,Now & &quot;&quot;)
Response.innerText= strOutput & &quot; &quot;
</script>
<!-- Insert HTML here -->
</body>
</html>
 
<html>
<head>
<meta name=&quot;GENERATOR&quot; content=&quot;SAPIEN Technologies PrimalScript 3.0&quot;>
<title>Document Title</title>
</head>
<body id=&quot;Bel&quot;>
<div id=&quot;Response&quot;></div>
<h2>Test of a PerlScript function being called from VBScript</h2>
<p>
<input type=&quot;text&quot; id=&quot;PipeCreate&quot; value=&quot;&quot;>
<input type=&quot;button&quot; onclick=&quot;namePipe, PipeCreate&quot; value=&quot;Create Pipe&quot;><br>
<input id=&quot;WriteThis&quot; type=&quot;text&quot; size=&quot;15&quot; value=&quot;&quot;>
<input type=&quot;button&quot; onclick=&quot;WriteToPipe&quot; value=&quot;Write To Created Pipe&quot;>
<input type=&quot;button&quot; onclick=&quot;ReadFromPipe&quot; value=&quot;Read Pipe&quot;>
</p>
<form method=&quot;POST&quot; action=&quot;&quot; onsubmit=&quot;javascript:return false&quot;>
<p><input type=&quot;button&quot; value=&quot;Close&quot; onclick=&quot;javascript:self.close();&quot;></p>
</form>
<p>
</p>
<iframe src=&quot;PerlServer.htm&quot; id=&quot;PerlServ&quot; style=&quot;height:0px;width:0px;border:0px&quot;></iframe>

<script language=&quot;PerlScript&quot;>
use Win32::pipe;
sub namePipe {
$pipe = $window->document->getElementByID(PipeCreate)->value;
}
sub WriteToPipe {
$OurPipe = new Win32::pipe;
$WhatToWrite= $window->document->getElementByID(WriteThis)->value;
$OurPipe->connect(&quot;\\\\.\\pipe\\$pipe&quot;);
$pipe->write(&quot;$WhatToWrite&quot;);
$OurPipe->close();
}
sub ReadFromPipe {
$OurPipe = new Win32::pipe;
$OurPipe->connect(&quot;\\\\.\\pipe\\$pipe&quot;);
$Data = $pipe->read();
$DatRetVal =&quot;This Is The Data $Data&quot;;
$window->alert($DatRetVal);
$OurPipe->close();
}
sub PipeCreate {
$OurPipe = new Win32::pipe(&quot;$pipe&quot;)|| die $window->alert(&quot;Can't Create Named Pipe\n&quot;);
}
sub sayHello {
# This function takes two parameters, creates a string
# from the parameters, and returns the string.

# get the two parameters into local variables
my ($strName, $strTime) = @_;
#now, create the return string.
$strRetVal=&quot;Hello $strName. The time is $strTime.&quot;;

# Return the string
$strRetVal;
}
</script>
<Script language=&quot;vbscript&quot;>

strOutput=sayHello(&quot;Visitor&quot;,Now & &quot;&quot;)
Response.innerText= strOutput & &quot; &quot;
</script>
<!-- Insert HTML here -->
</body>
</html>
More Complete but still needs help...
 
Ryan,

You've marked this as a question, but I can't see where your problem might lie. If you tell us what's wrong we might be able to help ...

--Paul
 
Thank you for answering the problem is cant call method connect eval 3 line 9 then unspecified error line 12 but what i want to do is develop a completly updatable application from function to external source and with databases .mdb files or xml file whichever turns out to be easier to manipulate in jscript javascript vbscript and now PerlScript which i learned no more than a week ago...

So in the meen time never believe
the answer &quot;it can't be done&quot;
always make your own truth.
 
For starters, do 'perldoc Win32::pipe' and take another look at the method names.
 
the first page hit me like aa ton of bricks thank you.
 
but now line 14 calling the sub that reads it is say cant call method on undefined object which means i think the write method is returning undef
but in any case here is the code:

<html>
<head>
<meta name=&quot;GENERATOR&quot; content=&quot;SAPIEN Technologies PrimalScript 3.0&quot;>
<title>Document Title</title>
</head>
<body id=&quot;Bel&quot;>
<div id=&quot;Response&quot;></div>
<h2>Test of a PerlScript function being called from VBScript</h2>
<p>
<input type=&quot;text&quot; id=&quot;PipeCreate&quot; value=&quot;&quot;>
<input type=&quot;button&quot; onclick=&quot;namePipe, PipeCreate&quot; value=&quot;Create Pipe&quot;><br>
<input id=&quot;WriteThis&quot; type=&quot;text&quot; size=&quot;15&quot; value=&quot;&quot;>
<input type=&quot;button&quot; onclick=&quot;WriteToPipe&quot; value=&quot;Write To Created Pipe&quot;>
<input type=&quot;button&quot; onclick=&quot;ReadFromPipe&quot; value=&quot;Read Pipe&quot;>
</p>
<form method=&quot;POST&quot; action=&quot;&quot; onsubmit=&quot;javascript:return false&quot;>
<p><input type=&quot;button&quot; value=&quot;Close&quot; onclick=&quot;javascript:self.close();&quot;></p>
</form>
<p>
</p>
<iframe src=&quot;PerlServer.htm&quot; id=&quot;PerlServ&quot; style=&quot;height:0px;width:0px;border:0px&quot;></iframe>

<script language=&quot;PerlScript&quot;>
use Win32::pipe;
sub namePipe {
$pipe = $window->document->getElementByID(PipeCreate)->value;
}
sub WriteToPipe {
$WhatToWrite= $window->document->getElementByID(WriteThis)->value;
$OurPipe = new Win32::pipe(&quot;\\\\.\\Pipe\\$pipe&quot;);
$OurPipe->Write(&quot;$WhatToWrite&quot;);
$OurPipe->Close();
}
sub ReadFromPipe {
$OurPipe = new Win32::pipe(&quot;\\\\.\\Pipe\\$pipe&quot;);
$Data = $OurPipe->Read(&quot;\\\\.\\Pipe\\$pipe&quot;);
$DatRetVal =&quot;This Is The Data $Data&quot;;
$window->alert($DatRetVal);
$OurPipe->Close();
}
sub PipeCreate {
$OurPipe = new Win32::pipe(&quot;$pipe&quot;)|| die $window->alert(&quot;Can't Create Named Pipe\n&quot;);
}
sub sayHello {
# This function takes two parameters, creates a string
# from the parameters, and returns the string.

# get the two parameters into local variables
my ($strName, $strTime) = @_;
#now, create the return string.
$strRetVal=&quot;Hello $strName. The time is $strTime.&quot;;

# Return the string
$strRetVal;
}
</script>
<Script language=&quot;vbscript&quot;>

strOutput=sayHello(&quot;Visitor&quot;,Now & &quot;&quot;)
Response.innerText= strOutput & &quot; &quot;
</script>
<!-- Insert HTML here -->
</body>
</html>
 
update #? v12 maybe
but any way here it is now it will tell you where the errors lie

<body id=&quot;Bel&quot;>
<div id=&quot;Response&quot;></div>
<h2>Test of a PerlScript function being called from VBScript</h2>
<p>
<input type=&quot;text&quot; id=&quot;PipeCreate&quot; value=&quot;&quot;>
<input type=&quot;button&quot; onclick=&quot;namePipe, PipeCreate&quot; value=&quot;Create Pipe&quot;><br>
<input id=&quot;WriteThis&quot; type=&quot;text&quot; size=&quot;15&quot; value=&quot;&quot;>
<input type=&quot;button&quot; onclick=&quot;WriteToPipe&quot; value=&quot;Write To Created Pipe&quot;>
<input type=&quot;button&quot; onclick=&quot;ReadFromPipe&quot; value=&quot;Read Pipe&quot;>
</p>
<input type=&quot;button&quot; onclick=&quot;Discon&quot; value=&quot;Disconnect Pipe!!&quot;>
<form method=&quot;POST&quot; action=&quot;&quot; onsubmit=&quot;javascript:return false&quot;>
<p><input type=&quot;button&quot; value=&quot;Close&quot; onclick=&quot;javascript:self.close();&quot;></p>
</form>
<p>
</p>
<script language=&quot;PerlScript&quot;>
use Win32::pipe;
sub namePipe {
$pipe = $window->document->getElementByID(PipeCreate)->value;
}
sub WriteToPipe {
$WhatToWrite= $window->document->getElementByID(WriteThis)->value;
$OurPipe = new Win32::pipe(&quot;\\\\.\\Pipe\\$pipe&quot;)|| die $window->alert(&quot;Can't Create Named $pipe\n&quot;);
my $Writer = $OurPipe->Write(&quot;$WhatToWrite&quot;);
}
sub ReadFromPipe {
$OurPipe = new Win32::pipe(&quot;\\\\.\\Pipe\\$pipe&quot;)|| die $window->alert(&quot;Can't Create Named $pipe\n&quot;);
$Data = $OurPipe->Read();
$DatRetVal =&quot;This Is The Data $Data&quot;;
$window->alert($DatRetVal);
}
sub PipeCreate {
$OurPipe = new Win32::pipe(&quot;$pipe&quot;)|| die $window->alert(&quot;Can't Create Named $OurPipe\n&quot;);
}
sub Discon {
$OurPipe = new Win32::pipe(&quot;\\\\.\\Pipe\\$pipe&quot;)|| die $window->alert(&quot;Can't Create Named $pipe err1 \n&quot;);
$OurPipe->Close()|| die $window->alert(&quot;Can't Create Named $pipe err2\n&quot;);
$OurPipe->Disconnect()|| die $window->alert(&quot;Can't Create Named $pipe err3 \n&quot;);
}
sub sayHello {
# This function takes two parameters, creates a string
# from the parameters, and returns the string.

# get the two parameters into local variables
my ($strName, $strTime) = @_;
#now, create the return string.
$strRetVal=&quot;Hello $strName. The time is $strTime.&quot;;

# Return the string
$strRetVal;
}
</script>
<Script language=&quot;vbscript&quot;>

strOutput=sayHello(&quot;Visitor&quot;,Now & &quot;&quot;)
Response.innerText= strOutput & &quot; &quot;
</script>
<!-- Insert HTML here -->
</body>
 
Your code looks like a mixture of PerlScript, JavaScript and VBScript, none of which I know. I do know Perl and VBA.

Where is this &quot;window&quot; object being instantiated? I don't see it anywhere. It is referenced in line 14 of the code in your last post.

Something else that looks odd to me. Several of your PerlScript subs are creating a new pipe object and assigning it to the variable $OurPipe. Since I don't see that anything here is lexically scoped (I don't even know if this is possible in PerlScript), I'm guessing that $OurPipe is the same variable throughout, so each one of these assignments clobbers any previous one, i.e., you lose access to the previously created objects. Shouldn't you be creating $OurPipe just once and then only refer to it later?
 
But u only lose total access to it when either undef or close() or disconnect() in manpage
but Are you using active state perl on win32???
if so create a html file with Script language=&quot;PerlScript&quot; in it then one ie make a script tag <script>type &quot;window.&quot;</script> a list should pop up for access to the DOM of the HTML file but javascript can access this a lot easier becuase the $window entry point is it only entrance. try typing document. or
$History = $window.history #History Object
if($History->Length) {
$History->Back(1);
}
 
&quot;But u only lose total access to it when either undef or close() or disconnect() in manpage&quot;

See following example:
Code:
# Create new Pipe object and assign to $OurPipe
$OurPipe = new Win32::Pipe(&quot;\\\\.\\Pipe\\$pipe&quot;)|| die $window->alert(&quot;Can't Create Named $pipe\n&quot;);

...
#later
$OurPipe = new Win32::Pipe(&quot;\\\\.\\Pipe\\$pipe&quot;)|| die $window->alert(&quot;Can't Create Named $pipe\n&quot;);

$OurPipe now points to a new Pipe object, not the
original one. Unless there is something else pointing to the original object, it is now inaccessible.
 
Brilliant... astounding i should have known iwas calling a new object..[noevil]:)I
thank you
 
But Yes it does.(look like perl vbscript javascript) smashed into pure ugliness. its beutiful isn't it. it scares me the kind of things that are possible, now that perlscript is about to hit)ServerSide and ClientSide...(probably client side will run only when creator enters the site with a special cookie...)
 
<script language=&quot;PerlScript&quot;>
use Win32::pipe;
sub namePipe {
$pipe = $window->document->getElementByID(PipeCreate)->value;
}
sub WriteToPipe {
$WhatToWrite = $window->document->getElementByID(WriteThis)->value;
$OurPipe = Win32::pipe(&quot;\\\\.\\Pipe\\$pipe&quot;)|| die $window->alert(&quot;Can't Create Named $pipe\n&quot;);
$OurPipe->Write(&quot;$WhatToWrite&quot;);
}
sub ReadFromPipe {
$OurPipe = Win32::pipe(&quot;\\\\.\\Pipe\\$pipe&quot;)|| die $window->alert(&quot;Can't Create Named $pipe\n&quot;);
$Data = $OurPipe->Read();
$DatRetVal =&quot;This Is The Data $Data&quot;;
$window->alert($DatRetVal);
}
sub PipeCreate {
$OurPipe = new Win32::pipe(&quot;$pipe&quot;)|| die $window->alert(&quot;Can't Create Named $OurPipe\n&quot;);
}
sub Discon {
$OurPipe = Win32::pipe(&quot;\\\\.\\Pipe\\$pipe&quot;)|| die $window->alert(&quot;Can't Create Named $OurPipe err1 \n&quot;);
$OurPipe->Close()|| die $window->alert(&quot;Can't Create Named $pipe err2\n&quot;);
$OurPipe->Disconnect()|| die $window->alert(&quot;Can't Create Named $pipe err3 \n&quot;);
}
Problem with writing to the pipe now
 
Should this be @OurPipe instead of $OurPipe
But anyways =left_down_right_up_ and the world turns
My Idea for a server For this is Many ideas of mine combined into one IF You have IE on WindowsXP Home or Pro
with ActiveScripting Enabled visit my site it isn't flashy or beutiful in fact it is down right Crude but the code is all mine and yours if you understand it but it is beutiful in my eyes try my BuildArea() Function in the IPPC CAller
(Internal Page Source Procedure Caller) at the bottom of the page use my on site google that can dissappear reappear try it any other way i dare you..
If You know javascript and the Document Object Model You can Edit My Site in the Javascript Inserter or your canCreate Pure 4.01 HTML (Explicit Requirment...) into the page and use the Event to do all your code. Save Your Build Data, Clear It, Load it, Build To and Bottom, or if you really wanna develop something with help from on site source reference but you need to have wsInetTools.Http COM Object Installed For It To Work! Try a Look at the Local File Cem.htm for how i access the DOM From a Hidden Iframe and call functions embedded in the Source Of The (ClientServer it's both) or (all rolled up into one) no server reload minimil need of bandwidth accept that it is 22 kb Called RPIPPC Remote Page with Inner Page Source Procedure Call. named them myself.

But here is the link:
http:\\
P.s. The No Button will send you back here.
Thank You For Reading
Sincerly Ryan April
 
Have Decided on using Sockets instead of pipes..
but here is my idea in full
first a server Side HTA that makes the Server Sockets
names Build Customer EmpBoard
each socket writes html line by line to the socket upon connection to it.upon close of the socket the client reads socket stdin to a hidden Text area that is conteneditable upon the client use Document.insertAdjacentHTML(SockHTMLRet.innerText);
to build the required application dynamically. or document.write(SockHTMLRet.innerText)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top