Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
net equivalent for Exe's
Hello All,
I have been using a modification of what is described here

to call functions and pass arguments between two different QM-generated exe's running on network connected computers.

I run this in a rep or dlg timer loop in the exe and have it scan continously for any update in a trigger txt file on a network share. Clicking on a dlg button or some other event in the exe on the second pc causes a setfile event to the trigger txt (path is defined the same way in both exe's) with the function to run and any arguments to pass.

Copy      Help
str FuncTriggered_Filepath = "\\networkshare\FuncTrigger.txt"
long+ TimeModPrev_FuncTrigger
Dir d_FuncTrigger
if d_FuncTrigger.dir(FuncTriggered_Filepath 0)
,long dtTimeMod_FuncTrigger =d_FuncTrigger.TimeModified(0 0 0 1)
,if TimeModPrev_FuncTrigger != dtTimeMod_FuncTrigger  and TimeModPrev_FuncTrigger != 0
,,str FuncArgs.getfile(FuncTriggered_Filepath);err
,,if Arg != "NULL" and !empty(Arg);
,,;sameple file contents = "Func=Func1&Arg=TestArgTxt"
,,,str PassedFuncCall PassedArg
,,,findrx(FuncArgs "(?<=Func=)\w+?(?=&|$) 0 0 PassedFuncCall)
,,,findrx(FuncArgs "(?<=Arg=)\w+?(?=&|$) 0 0 PassedArg)
,,,sel PassedFuncCall    
,,,,case "Func1"
,,,,,Func1 PassedArg
,,,,case "Func2"
,,,,,Func2 PassedArg
,,,,case "Func3"
,,,,,Func3 PassedArg
,TimeModPrev_FuncTrigger = dtTimeMod_FuncTrigger

This mostly works but sometimes I get some weird delays or double triggers depending on whether I set the file on the 2nd computer (trigger origin) with setfile or CFileInterlocked FromStr. I think sometimes there is more than one modification of the file registered in the trigger pickup loop depending on how the file is "set".

Any thoughts on the best way to do this. I wish there was a version of net for exe's. I understand that this could be used dangerously but what can be done to set up something safe in a controlled situation (ie within network)?

net equivalent is TcpSocket class in Archive.qml.
Yes fantastic...I can't believe I have overlooked this for so long.
Is there a reverse equivalent of GetIpAddress to give you hostname from IP. Couldn't find it in QM forum/help. Saw something on stack overflow about nslookup but couldn't make it work with run command.

Macro Macro737
Copy      Help
str IP="..."
__WsInit 0
int ia=inet_addr(IP)
hostent* hp = gethostbyaddr(+&ia 4 AF_INET)
out hp.h_name
amazing. Works perfectly!

Forum Jump:

Users browsing this thread: 1 Guest(s)