Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
command parsing is garbled
#8
QM3 editor supports only command line. The speed is ~100 ms if fast CPU.

If need a faster way, in QM3 create a script that runs all the time and somehow listens for QM2. For example with TCP it's easy to send and receive data. Speed: less than 1 ms if no script started, 4-16 ms if started.

TCP example.
In QM2 you need class TcpSocket. Import folder TcpSocket from https://www.quickmacros.com/forum/showth...p?tid=2852
Macro TCP to QM3
Code:
Copy      Help
#compile "__TcpSocket"
TcpSocket x.ClientConnect("127.0.0.1" 51885)
str s

x.Send("request ą")
x.Receive(s 10000)
out F"response: {s}"

x.Send("request ą")
x.Receive(s 10000)
out F"response: {s}"

In QM3 create this script and run. To run at startup, add it to Options -> General -> Run scripts...
C# code:
// script "TCP triggers.cs"
using System.Net;
using System.Net.Sockets;

TcpListener server = null;
try {
server = new TcpListener(IPEndPoint.Parse("127.0.0.1:51885"));
server.Start();
var b = new byte[100_000];
for (; ; ) {
var client = server.AcceptTcpClient();
var stream = client.GetStream();
int n;
while ((n = stream.Read(b, 0, b.Length)) != 0) {
var s = Encoding.UTF8.GetString(b, 0, n);
print.it(s);

//here add code to parse s and run a script or thread/task or execute any short/fast code. The QM2 script will wait and receive res. Examples:

//script.run(@"\Script15.cs", "arg1", "arg2"); //run async
//script.runWait(out var res, @"\Script15.cs"); //run sync and get its script.writeResult text
//run.thread(() => { print.it("thread"); });
//Task.Run(() => { print.it("thread"); });

var res = "result č";
stream.Write(Encoding.UTF8.GetBytes(res));
}
client.Close();
}
}
finally {
server.Stop();
}

This is raw code, need to test better and make easier to use.


Messages In This Thread
command parsing is garbled - by Davider - 08-12-2022, 12:47 AM
RE: command parsing is garbled - by Kevin - 08-12-2022, 01:33 AM
RE: command parsing is garbled - by Davider - 08-12-2022, 02:54 AM
RE: command parsing is garbled - by Kevin - 08-12-2022, 04:30 AM
RE: command parsing is garbled - by Davider - 08-12-2022, 05:00 AM
RE: command parsing is garbled - by Gintaras - 08-12-2022, 05:28 AM
RE: command parsing is garbled - by Davider - 08-12-2022, 08:34 AM
RE: command parsing is garbled - by Gintaras - 08-12-2022, 01:27 PM
RE: command parsing is garbled - by Davider - 08-13-2022, 01:13 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)