Using barindex and within timeframe functions

I want to get the barindex of the current bar according to the hourly timeframe, from a script that runs on the 1m timeframe. When I apply timeframeset and timeframeexpand (like in the following code), it doesn't work. It returns the barindex based off the 1m timeframe itself, but not the hourly timeframe.

foo = BarIndex();
foo_ef = TimeFrameExpand(foo, inHourly, expandFirst);

Filter = 1;
AddColumn(foo_ef, "hourly barindex"); //returns in1minute barindex

@TheNutz, please review the " How does it work internally ? in the Multiple Time Frame support in AFL document to understand why it does not work.

To get the bar indexes that corresponds to a different interval you can employ alternative methods, without invoking TimeFrame functions.

In this forum, there are multiple posts (like this) to detect a new day, a new week, month, etc.
You could use similar logic to detect when a bar is the first one in an Hour and then use the ValueWhen() function to get the corresponding BarIndex().