Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
use relative path in script
#1
The following code can only use absolute paths, why? how to use relative path?

video demo:
https://www92.zippyshare.com/v/kPVvVYNc/file.html



C# code:
// script "edit.cs" /*/ ifRunning warn_restart; r Libraries\libxl\libxl.net.dll; resource example.xls; /*/ //.
using Au; using System;
using libxl;
partial class Script : AScript { [STAThread] static void Main(string[] a) => new Script(a); Script(string[] args) { //;;;

 
try
{                           
    Book book = new BinBook(); 
//    var s = "example.xls";
    var s = @"C:\Users\Administrator\Documents\Aedit\Main\files\libxl\example.xls";
    book.load(s);
    Sheet sheet = book.getSheet(0);
    double d = sheet.readNum(3, 1);
    sheet.writeNum(3, 1, d * 2);
    sheet.writeStr(4, 1, "new string");
//    var s2 = "example_ok.xls";
    var s2 = @"C:\Users\Administrator\Documents\Aedit\Main\files\libxl\example_ok.xls";
    book.save(s2);
}
catch (System.Exception e)
{
    Console.WriteLine(e.Message);
}  


}
}


Attached Files
.zip   libxl.zip (Size: 2.26 MB / Downloads: 218)
#2
C# code:
// script "" /*/ ifRunning warn_restart; r Libraries\libxl\libxl.net.dll; /*/ //.
using Au; using System;
using libxl;
partial class Script : AScript { [STAThread] static void Main(string[] a) => new Script(a); Script(string[] args) { //;;;
 
System.IO.Directory.SetCurrentDirectory(ScriptFolder());
Book book = new BinBook();
var s = "example.xls";
book.load(s);
Sheet sheet = book.getSheet(0);
double d = sheet.readNum(3, 1);
sheet.writeNum(3, 1, d * 2);
sheet.writeStr(4, 1, "new string");
var s2 = "example_ok.xls";
book.save(s2);
}

/// <summary>
/// Gets folder path of caller's C# source file.
/// </summary>
/// <param name="f">Don't use.</param>
public static string ScriptFolder([System.Runtime.CompilerServices.CallerFilePath] string f = null) => APath.GetDirectory(f);
}

Don't need to add to resources.
#3
@Gintaras 
I suggest the code editing area can be more concise
For example, put the reference assemblys or Dll and Namespace imports  into several tabs

recently I have found a software, Linqpad  https://www.linqpad.net/Download.aspx
in some respects, QM3 can absorb its advantages

I made a video demo,
https://www90.zippyshare.com/v/LfVijjH8/file.html


Forum Jump:


Users browsing this thread: 1 Guest(s)