Editing a VB script from within Revolution

Ken Ray kray at sonsothunder.com
Wed Mar 22 13:32:08 EST 2006

On 3/22/06 12:26 PM, "Thomas McGrath III" <3mcgrath at adelphia.net> wrote:

> Hello,
> Does anyone know or can show me how to edit and run a VB script from
> with a Rev stack?
> I want to change item's in the VB script and then run it like I am
> doing with Applescript on the Mac side.
> I know how to launch an external script from within REV but I want to
> run a script stored in a field or custom property within REV.
> answer file "Run VB script" with "OK" and "Cancel"
> if it is not " then launch it with "WScript.exe"
> Also, Does anyone know how to get VB scripts to execute with out
> having the user to instal WSH WScript.exe ?

Yes, you can use 'cscript.exe' and run it from the command-line. Here's my
all-purpose handler for running scripts from Rev:

function stsDoScript pScript,pScriptType,pDirectToConsole
  if pScriptType ="" then put "AppleScript" into pScriptType
  replace "`" with quote in pScript
  switch pScriptType
  case "AppleScript"
  case "AS"
    do pScript as "AppleScript"
    put the result into tResult
  case "VB Script"
  case "VBS"
    set the hideConsoleWindows to true
    if pDirectToConsole = "" then
      put "C:\libVBS_temp.vbs" into tVBSPath
      put pScript into url ("file:" & tVBSPath)
      get shell("cscript.exe //nologo" && tVBSPath)
      get shell("cscript.exe" && pScript)
    end if
    put it into tResult
    if there is a file tVBSPath then
      send "delete file" && quote & tVBSPath & quote to me in 1 second
    end if
  case "JS"
  case "JavaScript"
    if "javascript" is among the lines of the alternateLanguages then
      do pScript as "JavaScript"
      put the result into tResult
      put "Error: JavaScript OSA component not installed." into tResult
    end if
  end switch
  return tResult
end stsDoScript

To call it, do something like:

put the uVBScript of this stack into tScript
-- or wherever you have your VBS code
get stsDoScript(tScript,"VBS")
if it <> "" then
  answer it
end if


Ken Ray
Sons of Thunder Software
Web site: http://www.sonsothunder.com/
Email: kray at sonsothunder.com

More information about the Use-livecode mailing list