AFAIK there are 4 ways to write info to a file in KiX:1. KiX functions OPEN, WRITELINE, CLOSE
; first, delete the file if it exists
; this is because KiX will append by default. If you want to append, remove this DEL line.
del "filename"
; open the file for write access.
; The 1 is the file handle, all future operations on this file will be done via this handle
; The 5 is 1 + 4: 1=Create file if it does not exist and 4=open file for write access
$nul=open(1, "filename", 5)
; write workstation name and $vsver to our text file
; the chr(13)+chr(10) is CR/LF. If you intend to use this more than once in a script, create a $variable for it instead
$nul=writeline(1, @wksta+", "+$vsver+chr(13)+chr(10))
; now close the file
$nul=close(1)
2. KiX function REDIRECTOUTPUT
; This will redirect most screen writes to the file instead of the screen. This is basically KiX's version of >file in DOS.
; The 1 is overwrite, change this to 0 to append
$nul=RedirectOutput("filename", 1)
; now just write the info to the screen with ? for CR/LF
@wksta ", " $vsver ?
; turn off redirection by assigning a blank filename
$nul=RedirectOutput("")
3. S(h)elling out to DOS
; This will use DOS's > redirect command to send info that would normally echo to the screen, to a file instead.
shell "%comspec% /c echo @wksta, $vsver> filename"
4. OLE/VBS external code calls. NT only!
; create file for writing
$fText=val("&"+olecallfunc(olecreateobject("Scripting.FileSystemObject"), "CreateTextFile", "s", "filename"))
; write a line to the file
$nul=olecallfunc($fText, "WriteLine", "s", @wksta+", "+$vsver)
; close the file
$nul=olecallfunc($fText, "Close")
The $nul= is used because that KiX function returns a value. If you remove it, you will see lots of zeros while the script runs. If there is a bul in the script, remove them and look for non zeros.
Hope this helps and if you find another file write method, let me know. I will post another message soon with speed test results of the four methods...
cj
------------------
For more scripts goto my website and click the hammer and spanner icon.
chrismat@ozemail.com.au