各言語でのHmNodeJS利用の最小サンプル

  • 概要

    ここでは、hmV8を含め、hmJS / hmPy / hmRb / hmLoadCLR での最小サンプルを紹介します。

  • hmV8 (V8 ECMAScript6)

    #V8 = loaddll( hidemarudir + @"\hmV8.dll" );
    
    #_ = dllfuncw( #V8, "DoString", R"ES6(
    
    host.lib(clr, "HmNodeClient" );
    
    var currentmacrodirectory = hm.Macro.Var["currentmacrodirectory"];
    
    /*
    var options = new clr.HmNodeClient.Options();
    options.ShowConsole = true;
    var client = new clr.HmNodeClient(50001, currentmacrodirectory + "/HmNodeSample.js", options);
    */
    
    var client = new clr.HmNodeClient(50001, currentmacrodirectory + "/HmNodeSample.js");
    
    client.Start();
    
    var NameValueCollection = clr.System.Collections.Specialized.NameValueCollection;
    var param = new NameValueCollection();
    param.Add("word1", "C:/abc/♬e.mac");
    param.Add("myppp", "そそそそそ");
    var res = client.GetResponse(param);
    
    console.log(res.StatusDescription+"いいい");
    console.log(res.StatusCode+"あああ");
    console.log(res.Data);
    console.log(res.CallCount);
    console.log(res);
    
    hm.Macro.Var["$data"] = res.Data + res.CallCount;
    )ES6"
    );
    
    message $data;
    
    freedll( #V8 );
    
  • hmJS (JScript)

    #JS = loaddll( hidemarudir + @"\hmJS.dll" );
    
    #_ = dllfuncw( #JS, "DoString", R"JS(
    host.lib(clr, "HmNodeClient" );
    
    var currentmacrodirectory = hm.Macro.Var("currentmacrodirectory");
    
    /*
    var options = new clr.HmNodeClient.Options();
    options.ShowConsole = true;
    var client = new clr.HmNodeClient(50001, currentmacrodirectory + "/HmNodeSample.js", options);
    */
    
    var client = new clr.HmNodeClient(50001, currentmacrodirectory + "/HmNodeSample.js");
    
    client.Start();
    
    var NameValueCollection = clr.System.Collections.Specialized.NameValueCollection;
    var param = new NameValueCollection();
    param.Add("word1", "C:/abc/♬e.mac");
    param.Add("myppp", "そそそそそ");
    var res = client.GetResponse(param);
    
    console.log(res.StatusDescription+"いいい");
    console.log(res.StatusCode+"あああ");
    console.log(res.Data);
    console.log(res.CallCount);
    console.log(res);
    
    hm.Macro.Var("$data", res.Data + res.CallCount);
    )JS"
    );
    
    message $data;
    
    freedll( #JS );
    
  • hmPy (IronPython)

    #PY = loaddll( hidemarudir + @"\hmPy.dll" );
     
    #_ = dllfuncw(#PY, "DoString", R"IPY(
    import clr
    clr.AddReferenceByPartialName("HmNodeClient") # dllの名前を拡張子など抜きで
     
    import System
    import HmNodeClient
    
    currentmacrodirectory = hm.Macro.Var["currentmacrodirectory"];
    
    """
    options = HmNodeClient.Options()
    options.ShowConsole = True
    client = HmNodeClient(50001, currentmacrodirectory + "/HmNodeSample.js", options)
    """
    
    client = HmNodeClient(50001, currentmacrodirectory + "/HmNodeSample.js")
    client.Start()
    
    param = System.Collections.Specialized.NameValueCollection()
    param.Add("word1", "C:/abc/♬e.mac")
    param.Add("myppp", "そそそそそ");
    res = client.GetResponse(param)
    
    hm.debuginfo(res.StatusDescription+"いいい")
    hm.debuginfo(res.StatusCode+"あああ")
    hm.debuginfo(res.Data)
    hm.debuginfo(res.CallCount)
    hm.debuginfo(res)
    
    hm.Macro.Var["$data"] = res.Data + str(res.CallCount)
    )IPY"
    );
    
    message $data;
    
    freedll( #PY );
    
    
  • hmRb (IronRuby)

    #RB = loaddll( hidemarudir + @"\hmRb.dll" );
    
    #_ = dllfuncw( #RB, "DoString", R"IRB(
    require 'mscorlib'
    require "System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
    
    load_assembly 'HmNodeClient'
    
    currentmacrodirectory = $hm.Macro.Var["currentmacrodirectory"];
    
    =begin
    options = HmNodeClient::Options.new
    options.ShowConsole = true
    client = HmNodeClient.new(50001, currentmacrodirectory + "/HmNodeSample.js", options)
    =end
    
    client = HmNodeClient.new(50001, currentmacrodirectory + "/HmNodeSample.js")
    client.Start()
    
    param = System::Collections::Specialized::NameValueCollection.new
    param.Add("word1", "C:/abc/♬e.mac")
    param.Add("myppp", "そそそそそ");
    $hm.debuginfo(client)
    
    res = client.GetResponse(param)
    $hm.debuginfo(res.StatusDescription+"いいい")
    $hm.debuginfo(res.StatusCode+"あああ")
    $hm.debuginfo(res.Data)
    $hm.debuginfo(res.CallCount)
    $hm.debuginfo(res)
    
    $hm.Macro.Var["$data"] = res.Data + res.CallCount.to_s
    )IRB"
    );
    
    message $data;
    
    freedll( #RB );
    
    
  • hmLoadCLR (NeoLua)

    #MNG = loaddll( hidemarudir + @"\hmLoadCLR.dll" );
    
    #_ = dllfuncw( #MNG, "DoString", R"MNG(
    local hidemarudir = hm.Macro.Var["hidemarudir"]
    load_assembly "HmNodeClient"
    
    local currentmacrodirectory = hm.Macro.Var["currentmacrodirectory"];
    
    --[[
    local options = clr.HmNodeClient.Options()
    options.ShowConsole = true
    local client = clr.HmNodeClient(50001, currentmacrodirectory .. "/HmNodeSample.js", options)
    ]]
    
    local client = clr.HmNodeClient(50001, currentmacrodirectory .."/HmNodeSample.js")
    
    client.Start()
    
    local NameValueCollection = clr.System.Collections.Specialized.NameValueCollection
    local param = NameValueCollection()
    param.Add("word1", "C:/abc/♬e.mac")
    param.Add("myppp", "そそそそそ");
    local res = client.GetResponse(param)
    
    hm.debuginfo(res.StatusDescription.."いいい")
    hm.debuginfo(res.StatusCode.."あああ")
    hm.debuginfo(res.Data)
    hm.debuginfo(res.CallCount)
    hm.debuginfo(res)
    
    hm.Macro.Var["$data"] =  res.Data .. res.CallCount
    )MNG"
    );
    
    message $data;
    
    freedll( #MNG );