Page 1 of 1 1
Topic Options
#196203 - 2009-10-01 06:12 PM fso.GetStandardStream
MACE Offline
Starting to like KiXtart

Registered: 2004-09-07
Posts: 150
Loc: Manchester UK
Does anyone know whether it is possible to impliment GetStandardStream within the KIX environment !

I can use it in VBS but would prefer KIX. Ideally I want to be able to emulate the console output in a re-sizeable system.form and the general consensus is to use GetStandardStream to pipe things from Console to Form.

e.g. Experimenting with the following conversion from a VBS example but to no avail !
 Code:
/*
object.GetStandardStream(standardStreamType [, unicode ])
The standardStreamType can have any of the following settings:
Constant      Value    Description
StdIn         0        Returns a TextStream object corresponding to the standard input stream.
StdOut        1        Returns a TextStream object corresponding to the standard output stream.
StdErr        2        Returns a TextStream object corresponding to the standard error stream

unicode       Optional Boolean value that indicates whether the file is created as a Unicode or ASCII file.
              The value is true if the file is created as a Unicode file, false if it is created as an ASCII file.
              If omitted, an ASCII file is assumed.
*/

break on
Dim $FSO,$sin,$sout,$Serr,$words
$fso=createobject("scripting.FileSystemObject")
$sin=createobject("scripting.TextStream")
$sout=createobject("scripting.TextStream")

$sin = $FSO.GetStandardStream(0)
$sout = $FSO.GetStandardStream(1)
$serr = $FSO.GetStandardStream(2)

$sout.WriteLine "Hello!"+@crlf
$sout.WriteLine "What's the word?"+@crlf
$Words = $sin.ReadLine()
$sout.WriteLine "So, the word is " + $Words+@crlf
$sout = ''
$sin = ''
get $

Top
#196208 - 2009-10-01 09:32 PM Re: fso.GetStandardStream [Re: MACE]
Witto Offline
MM club member
*****

Registered: 2004-09-29
Posts: 1828
Loc: Belgium
http://msdn.microsoft.com/en-us/library/y6hbz9es(VS.85).aspx
 Code:
$fso = CreateObject("scripting.FileSystemObject")
$sin = $fso.GetStandardStream(0)
$sout = $fso.GetStandardStream(1)
$serr = $fso.GetStandardStream(2)

These are redundant
 Code:
$sin=createobject("scripting.TextStream")
$sout=createobject("scripting.TextStream")

and do not forget
 Code:
Dim $

Top
#196224 - 2009-10-02 09:07 AM Re: fso.GetStandardStream [Re: Witto]
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
Nice find! That could be very useful for things like CGI scripting.

If you are piping data don't expect to able to do anything with GetS once the input is stream exhausted - STDIN will be closed. Get will still work though, so you will be able to use any of the replacement GetS() UDFs for input.

Top
#196228 - 2009-10-02 10:33 AM Re: fso.GetStandardStream [Re: Richard H.]
Arend_ Moderator Offline
MM club member
*****

Registered: 2005-01-17
Posts: 1896
Loc: Hilversum, The Netherlands
Now Witto, what Are you pointing out with your first code block, it's the same as Mace's ?
Top
#196232 - 2009-10-02 01:32 PM Re: fso.GetStandardStream [Re: Arend_]
Witto Offline
MM club member
*****

Registered: 2004-09-29
Posts: 1828
Loc: Belgium
Dear apronk
Yes, except I cut two lines.

Top
#196238 - 2009-10-02 09:41 PM Re: fso.GetStandardStream [Re: Witto]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
$sout.WriteLine "Hello!"+@crlf
$sout.WriteLine "What's the word?"+@crlf

well...
to no avail sure.
try:
$sout.WriteLine("Hello!"+@crlf)
_________________________
!

download KiXnet

Top
#196240 - 2009-10-03 03:32 AM Re: fso.GetStandardStream [Re: Lonkero]
Witto Offline
MM club member
*****

Registered: 2004-09-29
Posts: 1828
Loc: Belgium

 Code:
; ===========================================================================================
;
; 	Script Information
;	
;	Title:       
;	Author:      Wim Rotty
;	Date:        
;	Description: 
;	
;
; ===========================================================================================

;;;;;;;;;;;;;;;;;;
; Script Options ;
;;;;;;;;;;;;;;;;;;

If Not @LOGONMODE
	Break On
Else
	Break Off
EndIf
Dim $RC
$RC = SetOption("Explicit", "On")
$RC = SetOption("NoMacrosInStrings", "On")
$RC = SetOption("NoVarsInStrings", "On")
If @SCRIPTEXE = "KIX32.EXE"
	$RC = SetOption("WrapAtEOL", "On")
EndIf

;;;;;;;;;;;;;;;;;;;;;
; Declare variables ;
;;;;;;;;;;;;;;;;;;;;;

Dim $FSO
Dim $sin
;Dim $sout
;Dim $Serr
Dim $words
Dim $

;;;;;;;;;;;;;;;;;;;;;;;;
; Initialize variables ;
;;;;;;;;;;;;;;;;;;;;;;;;

;;;;;;;;
; Code ;
;;;;;;;;

$fso = CreateObject("scripting.FileSystemObject")
$sin = $fso.GetStandardStream(0)
;$sout = $fso.GetStandardStream(1)
;$serr = $fso.GetStandardStream(2)

? 'Type 10 chars and Enter please' ?
$words = $sin.Read(12)
?? "wait 1" ??
? $Words
Sleep 3

? 'Type wsomething And end with an Enter please' ?
? $Words = $sin.ReadLine
?? "wait 2" ??
? $Words
Sleep 3

? 'Type more than one line with Returns and end with Ctrl+Z please' ?
$Words = $sin.ReadAll
?? "wait 3" ??
? $Words

Get $

Top
#210225 - 2015-05-01 03:37 PM Re: fso.GetStandardStream [Re: Witto]
MACE Offline
Starting to like KiXtart

Registered: 2004-09-07
Posts: 150
Loc: Manchester UK
Still find this useful :-)
Top
Page 1 of 1 1


Moderator:  Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 739 anonymous users online.
Newest Members
M_Moore, BeeEm, min_seow, Audio, Hoschi
17883 Registered Users

Generated in 0.064 seconds in which 0.03 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org