Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Run ironpython code, no output
#3
@Gintaras thanks

I have a problem. Where is the script file for currently edited? Huh
In the following code, I need to put two Python files in the same directory


C# code:
// script "ipy_code2.cs" /*/ r Libraries\IronPython.dll; r Libraries\Microsoft.Scripting.dll; r Libraries\Microsoft.Dynamic.dll; /*/ //.
using Au; using System; using Microsoft.Scripting.Hosting;
using System.Collections.Generic;
partial class Script : AScript { [STAThread] static void Main(string[] a) => new Script(a); Script(string[] args) { //;;;
AOutput.RedirectConsoleOutput=true;

ScriptEngine pythonEngine = IronPython.Hosting.Python.CreateEngine();

// Print the default search paths
System.Console.Out.WriteLine("Search paths:");
ICollection<string> searchPaths = pythonEngine.GetSearchPaths();
foreach (string path in searchPaths)
{
    System.Console.Out.WriteLine(path);
}
System.Console.Out.WriteLine();

// Now modify the search paths to include the directory from
// which we execute the script
searchPaths.Add("..\\..");
pythonEngine.SetSearchPaths(searchPaths);

// Execute the script
// We execute this script from Visual Studio so the program will executed from bin\Debug or bin\Release
Microsoft.Scripting.Hosting.ScriptSource pythonScript = pythonEngine.CreateScriptSourceFromFile("..\\..\\HelloWorld.py");
pythonScript.Execute();
}
}

Found a small problem, com lists, if  do not select item, can not close it

[Image: QQ-20210108084757.png]

I found the file path: Smile
C:\Users\Administrator\Documents\Aedit\Main\files


Attached Files
.zip   py files.zip (Size: 409 bytes / Downloads: 234)


Messages In This Thread
Run ironpython code, no output - by macman - 01-07-2021, 11:27 AM
RE: Run ironpython code, no output - by Gintaras - 01-07-2021, 12:10 PM
RE: Run ironpython code, no output - by macman - 01-08-2021, 12:45 AM
RE: Run ironpython code, no output - by macman - 01-08-2021, 05:51 AM
RE: Run ironpython code, no output - by Gintaras - 01-08-2021, 06:12 AM
RE: Run ironpython code, no output - by Gintaras - 01-08-2021, 06:59 AM
RE: Run ironpython code, no output - by Gintaras - 01-08-2021, 07:29 AM
RE: Run ironpython code, no output - by macman - 01-08-2021, 08:42 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)