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

 

METHOD EncodeScriptFile ( _

BYVAL bstrExt AS STRING, _

BYVAL bstrStreamIn AS STRING, _

BYVAL cFlags AS LONG, _

BYVAL bstrDefaultLang AS STRING _

) AS STRING

 

Arguments

 

bstrExt

BSTR. Extension of the file, e.g. ".vbs", ".js", ".htm", ".html"

bstrStreamIn

BSTR. Script text to encode.

cFlags

LONG. Flags. Can be 0.

bstrDefaultLang

BSTR. Default language, e.g. "VBScript", "JScript". Can be a null string, "".

 

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

 

Valid XHTML 1.0 Transitional