EncodeScriptFile Method |
Description
Encodes an script. The Script Encoder encodes only scripting code, with all other file content left untouched to appear as plain text.
PowerBASIC Syntax
Arguments
Return Value
The encoded script.
Example [PowerBASIC]
#INCLUDE "windows.inc" #INCLUDE "scrrun.inc"
DIM fso AS IFileSystem DIM pStm AS ITextStream DIM pEncoder AS IScriptEncoder DIM OutString AS STRING DIM strStreamOut AS STRING
' Create an instance of the FileSystemObject fso = NEWCOM "Scripting.FileSystemObject" ' Open the file for reading pStm = pFso.OpenTextFile(UCODE$("C:\MyFolder\Test.txt"), %IOMode_ForReading, %FALSE, %FALSE) ' Read the entire stream into a string OutString = pStm.ReadAll ' Close the file pstm.Close ' Create an instance of the Script encoder and ' encode the text. ' This is for demonstration purposes only, since the text ' we are encoding isn't a script. ' Note: We aren't using UCODE$(OutString) because ' OutString already contains unicode text. pEncoder = NEWCOM "Scripting.Encoder" IF ISOBJECT(pEncoder) THEN strStreamOut = pEncoder.EncodeScriptFile(UCODE$(".vbs"), OutString, 0, UCODE$("")) MSGBOX "Encoded file: " & ACODE$(strStreamOut) END IF
|