Thanks for replying, I was starting to wonder if anyone would.
I actually discovered a solution to everything except the timer on my own over the last few days.
The easiest was why I was unable to send commands properly from variable to variable. I was using char when I should have been using int. That all works fine now.
For the detection of what layer TARGET is operating under, I found I just need to read TARGET's internal layers_sw[] variable at indexes 2, 5, and 8 to get on or off bits for the shift, up, and down layers respectively.
Here's what my code looks like for reading the layer state:
int ReadIOUMD()
{
if (layer_sw[2] == 0)
{
ShiftState = 'o';
}
else
{
ShiftState = 'i';
}
if ((layer_sw[5] == 1) & (layer_sw[8] == 0))
{
LayerMode = 'u';
}
else if ((layer_sw[5] == 0) & (layer_sw[8] == 1))
{
LayerMode = 'd';
}
else
{
LayerMode = 'm';
}
}
As for the timer, well I've got an improvised one like you said, incrementing a variable over time. I call a function to do this at the very start of my rexec that adds the loop time to a variable each time through.
int IncrementTimer()
{
ScriptTimer=(ScriptTimer+(REXECLength/1000));
}
ScriptTimer and REXECLength are both floats. Also it seems TARGET doesn't have very good floating point precision. Right now I've got my REXEC running every 25ms, so ScriptTimer should always be a multiple of 0.025, but it starts going off by 0.00001 after a couple of seconds. It's still accurate enough for what I use it for later in the script, but it just irks me.
What I had been hoping for was some concrete way to generate a timestamp based on the system clock like in Autohotkey.
In autohotkey I can do this:
MyTimer := A_TickCount
which sets MyTimer to the current system uptime in ms. And then later I can just compare MyTimer to the current value of
A_TickCount and I've got a timer based on the system clock. I do the comparison in my TARGET script the same way, just using that manually incremented timer. I had been hoping to find some internal target variable that does the same thing since d() and defercall seem like they would need one and just piggyback on it the same way I'm piggybacking on layer_sw. But this makeshift way seems to function well enough.
As for getting a rexec to run by itself...
You said use a switch, are you talking about a physical button on the stick? Well that's basically what I had been doing.
Previously I had set this bind somewhere in main():
MapKey(&T16000, TS1, REXEC(0, REXECLength, "MyScript();", RNOSTOP));
And then once the script starts it would hand the trigger back its default function the first time it runs:
MapKey(&T16000, TS1, DX1);
But I discovered that I can trigger a rexec using an ActKey:
ActKey(KEYON+PULSE+REXEC(0, REXECLength, "MyScript();", RNOSTOP));
I would not be opposed to suggestions for a better way to do things if you know a different way to and see a problem with anything I'm doing here.