daxb suggestion turned out to be of great value, with the power of ARexx do what I needed was as simple as this:
Code:
/* watch a file and execute it, useful to test code compiled externally */
SAY "WATCH A FILE FOR CHANGES AND EXECUTE IN CASE"
SAY "ARexx script by KONEY 2021"
SAY "--------------------------------------------------"
library = 'rexxsupport.library'
IF ~SHOW( 'L', library ) THEN DO
IF ~ADDLIB( library, 0, -30, 0 ) THEN DO
SAY 'Failed to add library ' || library || '.'
EXIT 10
END
END
initial_file = STATEF("j")
SAY initial_file
loop=1
SAY "WATCHING..."
DO until loop > 1
actual_file = STATEF("j")
IF actual_file ~= initial_file THEN DO
SAY "CHANGES DETECTED!"
ADDRESS COMMAND "J >NIL:"
initial_file = STATEF("j")
END
END
EXIT