Author Topic: Firing an event on macro completion  (Read 310 times)

0 Members and 1 Guest are viewing this topic.

Offline newbie

  • Occasional poster
  • *
  • Posts: 27
    • View Profile
Firing an event on macro completion
« on: October 22, 2019, 08:40:51 PM »
I would like to fire an event to do something (for e.g run exec) when a template script in my DiffTemplates finishes successfully.

For e.g: when exec |myprog.exe| runs and produces a file.ext, then fire an event that will then call another exec to do something with the file.
ie the appearance of the file constitutes an event, upon which some other process works on that file.

I looked at this https://rejetto.com/wiki/index.php?title=HFS:_Event_scripts#Other_events and searched in the forum, but it isnt clear to me how I can fire up my own event and watch for it.

I would really appreciate any help.

Thanks.


Offline Mars

  • Operator
  • Tireless poster
  • *****
  • Posts: 1899
    • View Profile
Re: Firing an event on macro completion
« Reply #1 on: October 22, 2019, 11:05:44 PM »
you can probably include an msdos command file to perform all operations so they will be executed in the correct order


Offline newbie

  • Occasional poster
  • *
  • Posts: 27
    • View Profile
Re: Firing an event on macro completion
« Reply #2 on: October 23, 2019, 01:16:10 PM »
Thanks for your response.

Ah. ok. I think I understand.
Actually, if myprog.exe is writing out the file, it can call the 2nd process to work on that file. :)
Sometimes, one tends to overthink things.

Offline rejetto

  • Administrator
  • Tireless poster
  • *
  • Posts: 12953
    • View Profile
Re: Firing an event on macro completion
« Reply #3 on: October 23, 2019, 01:35:31 PM »
hi! events in HFS were introduced to execute scripts when something happens.
In your case it's a script that will cause another script to be executed, so events are not needed.
To call a script from another script you have at least 2 ways

- you put the script inside a section, for example [MySection] and then to execute it you will use {.$MySection.}

- you put the script inside a variable/function, using {.set|MyScript|{: *******  :}.} and then to execute it you will use {.^MyScript.}

Offline rejetto

  • Administrator
  • Tireless poster
  • *
  • Posts: 12953
    • View Profile
Re: Firing an event on macro completion
« Reply #4 on: October 23, 2019, 01:55:31 PM »
do you already know the {.exec.} command ?
if you use the "out" parameter i'm pretty sure it will wait for the execution to complete,
then you may use the {.exists.} command

Offline newbie

  • Occasional poster
  • *
  • Posts: 27
    • View Profile
Re: Firing an event on macro completion
« Reply #5 on: October 23, 2019, 02:09:51 PM »
Those are excellent pointers Rejetto. Thanks for your comments. I didnt know about the MySection technique, but I knew about exec and output.
Either of those will work. I am good here.