ASP MagicShell Component  

ASP MagicShell component allows you easily execute any programs and analyze the results. Works very well with .bat files or any other executables that could be launched from command prompt. MagicShell supports multiple output options, such as Binary, Hexadecimal, Base64, Text, and Unicode Text. It woks in syncronous and Asyncronous modes.


 

Classes
The Shell Object
The BinaryData Object


 

Evaluation of MagicShell Component
Click here to download a 30-days evaluation copy of MagicShell Component.

Purchasing MagicShell Component
You can get MagicShell online or by phone from The Registration Network

  • 1-CPU Licence $99
  • 2-CPU Licence $149
  • Unlimited CPU Licence $199
Also, you may order by sending check to: Dana Consulting Inc.
(in the memo field specify MagicShell)

Send it to:
Dana Consulting Inc.
14936 CreditView Drive
Savage, MN 55378

Please, print, fill out and enclose Order Form located in OrderForm.html file

Installation

  • To register MagicShell component move the MagicShell.dll, register.exe and register.bat into a subdirectory. To register the component on the system change to the directory where you installed the DLL and run Register.bat. It will give you a message saying that your component was registered. You can start using the component for 30-day evaluation trial.

 
 

Shell Object

 

Methods

  Run Method
Sleep Method
GetLastErrorNbr Method
GetLastErrorDscr Method

  Properties
  Status Property

 

Working with Shell Object

 

Run Method

Calls any external console application.
Return Value: Nonzero if successful; otherwise 0.
Syntax: object.Run(sPath, asyncMode, [dispSTDIn], [dispSTDOut], [dispSTDErr])
sPath - command string for application execution (including command line parameters)

asyncMode - asynchronous mode. If false then calling thread will wait until the execution of application is finished. Otherwise the thread will continue immediately after Run() method has been called. Default 0.

dispSTDIn - application input binary string. Use this value to emulate console input of the application. There are two cases of using dispSTDIn:

1. asyncMode=false
dispSTDIn must be a MagicShell.BinaryData object with a binary string assigned to .AsBinary property. In this case the application will use the content of .AsBinary property as a binary console input.

2. asyncMode=true
dispSTDIn can be a variant variable (just a simple variable for ASP). Run() method returns dispSTDIn as MagicShell.BinaryData object which you can use later for passing the binary input strings to the application (use dispSTDIn.AsBinary property for that purpose).

dispSTDOut - application binary output. Actually Run() method "hides" console from application and replaces it with MagicShell.BinaryData object which is returned as dispSTDOut variable. Use dispSTDIn.AsBinary, dispSTDIn.AsText etc. properties to read the application output.

dispSTDErr - error string (if any) returned by application

Sleep Method

Suspends execution of calling thread after Run() method has been called. Especially useful when asyncMode = true.
Syntax: object.Sleep(varMSec)
varMsec - number of milliseconds for calling thread to sleep. Actually Sleep method just calls a Sleep WinAPI procedure. Default is 10.
GetLastErrorNbr Method
Returns number of a last error.
Syntax: object.GetLastErrorNbr
GetLastErrorDscr Method
Returns description of a last error.
Syntax: object.GetLastErrorDscr
Status Property
Returns status of the application lunched by Run() method.
Returns one of the following values:
   cSS_NO = 0
   cSS_STARTING = 1
   cSS_STARTED = 2
   cSS_RUNNING = 3
   cSS_READING_DATA = 4
   cSS_WRITING_DATA = 5
   cSS_TERMINATING = 6
   cSS_TERMINATED = 7
Syntax: object.Status

Example:

To call the Shell Object from VB, you will need to create the object using the following code:

Const cSS_NO = 0
Const cSS_TERMINATED = 7

set shellobj = CreateObject("MAGICShell.Shell")
If shellobj.Run("ping localhost", true, 0, binOut) then
  while NOT ((cSS_TERMINATED = shellobj.Status) OR (cSS_NO = shellobj.Status))
    shellobj.Sleep 50
    msg = msg + binOut.AsPipedText
  wend
  msg = msg + binOut.AsPipedText
Else
  msg = "Error occurred:" & shellobj.GetLastErrorDscr
End If
MsgBox("Result:" & msg)

set shellobj = nothing

top

 

BinaryData Object

BinaryData object has several methods for conversion of string and binary values. You can assign the value to one of the properties beginning with "As…" then read all other properties. Those properties will return the value automatically converted to the desired type.

 

Properties

  AsBase64 Property
AsHex Property
AsBinary Property
AsText Property
AsUText Property
AsPipedText Property
AsPipedBase64 Property
AsPipedBinary Property
  Methods
  LoadFromFile Property
SaveToFile Property
GetLastErrorNbr Property
GetLastErrorDSCR Property

 

Working with BinaryData Object

 

AsBase64 Property

Use this property to set or read the value in Base64 format.
Syntax: object.AsBase64

AsHex Property

Use this property to set or read the value in Hexadecimal format.
Syntax: object.AsHex

AsBinary Property

Use this property to set or read the value in Binary format. You can pass an optional Count value to set or read just first count bytes of the binary value.
Syntax: object.AsBinary( [Count] )

AsUText Property

Use this property to set or read the value in Unicode format.
Syntax: object.AsUText

AsText Property

Use this property to set or read the value in Text format.
Syntax: object.AsText

AsPipedText Property

The same as AsText property, but
    object.AsPipedText = <some_string_value> is equal to
    object.AsText = object.AsText + <some_string_value>.
The value of AsText property becomes empty after reading AsPipedText, so
<some_variable>=object.AsPipedText    is equal to
<some_variable> = object.AsText ;   object.AsText = ""
Syntax: object.AsPipedText

AsPipedBase64 Property

The same as AsPipedText but for Base64 values.
Syntax: object.AsPipedBase64

AsPipedBinary Property

The same as AsPipedText for binary values, but just Count bytes (if Count is specified) will be removed from the initial value after reading this property.
Syntax: object.AsPipedBinary(Count)

LoadFromFile Method

Reads the entire content of the file specified in FileName parameter. That content is accessible by any of "As…" properties after LoadFromFile is executed.
Syntax: object.LoadFromFile(FileName)

SaveToFile Method

Saves the value of AsBinary property to the file specified by FileName string.
Syntax: object.SaveToFile(FileName)
GetLastErrorNbr Method
Returns number of a last error.
Syntax: object.GetLastErrorNbr
GetLastErrorDscr Method
Returns description of a last error.
Syntax: object.GetLastErrorDscr

Example:

This example reads data from the file "win.ini" and saves they to file "newwin.ini".

set s = CreateObject("MagicShell.BinaryData")
set d = CreateObject("MagicShell.BinaryData")

s.LoadFromFile "win.ini"
d.AsBinary = s.AsBinary
d.SaveToFile "newwin.ini"

set s = Nothing
set d = Nothing

top


Home | FAQ | News | How to buy | Contacts | ASP MagicPerf Component | ASP MagicShell Component