for KEMI there is an option which was recently merged to the master you can get value of #!defined by using KSR.kx.get_def("VAR")
#!define MYVAR 1234
then in your script you can use KSR.kx.get_def("MYVAR")
there was a mail thread on this topic in users list