title: How call the CreateOleObject function using dwscript?
body: <p>I'm trying to execute this code (this is a minimal sample in order to use CreateOleObject) from inside of a dwscript</p>
  
  <pre><code>function GetFileVersion(const FileName: string): string;
  var
    V : OleVariant;
  begin
    V  := CreateOleObject('Scripting.FileSystemObject');
    Result := V.GetFileVersion(FileName);
  end;
  </code></pre>
  
  <p>So far i tried this</p>
  
  <pre><code>{$APPTYPE CONSOLE}
  
  {$R *.res}
  
  
  uses
    SysUtils,
    ComObj,
    ActiveX,
    dwsComp,
    dwsCompiler,
    dwsExprs,
    dwsCoreExprs;
  
  
  procedure Execute;
  var
    LScript: TDelphiWebScript;
    LUnit: TdwsUnit;
    LProg: IdwsProgram;
    LExec: IdwsProgramExecution;
  begin
    LScript := TDelphiWebScript.Create(NIL);
    LUnit := TdwsUnit.Create(NIL);
    try
      LUnit.UnitName := 'Foo';
      LUnit.Script := LScript;
      //  compile a simple script
      LProg := LScript.Compile(
        'function GetFileVersion(const FileName: string): string;'+sLineBreak+
        'var'+sLineBreak+
        '   V : Variant;'+sLineBreak+
        'begin'+sLineBreak+
        ' V  := CreateOleObject(''Scripting.FileSystemObject'');'+sLineBreak+
        ' Result := V.GetFileVersion(FileName);'+sLineBreak+
        'end;'+sLineBreak+
        ''+sLineBreak+
        'PrintLn(GetFileVersion(''Foo''));'+sLineBreak+
        ''
      );
  
      if LProg.Msgs.HasErrors then begin
        Writeln(LProg.Msgs.AsInfo);
        Exit;
      end;
  
      try
        LExec := LProg.Execute;
      except
        on E: Exception do
          WriteLn(E.Message + sLineBreak + LExec.Msgs.AsInfo );
      end;
      Writeln(LExec.Result.ToString);
    finally
      LScript.Free;
    end;
  end;
  
  begin
    try
      Execute;
      Readln;
    except
      on E: Exception do
        Writeln(E.ClassName, ': ', E.Message);
    end;
  end.
  </code></pre>
  
  <p>But i'm getting this error message </p>
  
  <blockquote>
    <p>Syntax Error: Unknown name "CreateOleObject" [line: 5, column: 8]</p>
  </blockquote>
  
  <p>the question is how i can execute the <a href="http://docwiki.embarcadero.com/Libraries/en/System.Win.ComObj.CreateOleObject" rel="nofollow noreferrer"><code>CreateOleObject</code></a> function using dwscript?</p>
  
  <h1>UPDATE</h1>
  
  <p>Following the <a href="https://stackoverflow.com/users/205496/linas">Linas</a> suggestions I could finally resolve the issue.</p>
  
  <p>This is a sample working application </p>
  
  <pre><code>uses
    SysUtils,
    ComObj,
    ActiveX,
    dwsComp,
    dwsCompiler,
    dwsExprs,
    dwsComConnector,
    dwsCoreExprs;
  
  
  procedure Execute;
  var
    LScript: TDelphiWebScript;
    LUnit: TdwsUnit;
    LProg: IdwsProgram;
    LExec: IdwsProgramExecution;
    LdwsComConnector : TdwsComConnector;
  begin
    LScript := TDelphiWebScript.Create(NIL);
    LdwsComConnector:=TdwsComConnector.Create(nil);
    LdwsComConnector.Script:=LScript;
    LUnit := TdwsUnit.Create(NIL);
    try
      LUnit.UnitName := 'Foo';
      LUnit.Script := LScript;
      //  compile a simple script
      LProg := LScript.Compile(
        'function GetFileVersion(const FileName: string): string;'+sLineBreak+
        'var'+sLineBreak+
        '   V : OleVariant;'+sLineBreak+
        'begin'+sLineBreak+
        ' V  := CreateOleObject(''Scripting.FileSystemObject'');'+sLineBreak+
        ' Result := VarToStr(V.GetFileVersion(FileName));'+sLineBreak+
        'end;'+sLineBreak+
        ''+sLineBreak+
        'PrintLn(GetFileVersion(''C:\Bar\Foo.exe''));'+sLineBreak+
        ''
      );
  
      if LProg.Msgs.HasErrors then begin
        Writeln(LProg.Msgs.AsInfo);
        Exit;
      end;
  
      try
        LExec := LProg.Execute;
      except
        on E: Exception do
          WriteLn(E.Message + sLineBreak + LExec.Msgs.AsInfo );
      end;
      Writeln(LExec.Result.ToString);
    finally
      LScript.Free;
      LdwsComConnector.Free;
    end;
  end;
  
  begin
   try
      CoInitialize(nil);
      try
        Execute;
        Readln;
      finally
        CoUninitialize;
      end;
   except
      on E:Exception do
          Writeln(E.Classname, ':', E.Message);
   end;
  end.
  </code></pre>