I managed to use CacheGlobalOrder to iterate over global and return the next subscript:

int GetGlobalStr(char *global, int subscript, CACHE_EXSTRP result) { int push = CACHEPUSHGLOBAL(strlen(global), global); int pushS = CACHEPUSHINT(subscript); // narg Number of subscript expressions pushed onto the argument stack. int narg = 1; // Direction for the $Order is 1 for forward, -1 for reverse. int dir = 1; // Indicates whether the data value, if there is one, should be returned. int valueflag = 0; int order = CACHEGLOBALORDER(narg, dir, valueflag); int pop = CACHEPOPEXSTR(result); //pop = CACHEPOPEXSTR(result); return ZF_SUCCESS; }