James,
The listing (lst) file echos the expanded program at the top of the file. This usually helps debugging compilation errors. When I do what you describe first it gives me:
23 loop(lim,
BATINCLUDE C:\Users\Michael\Documents\eBug\test1.gms
25 test_b.lim(i)=tofix(i,lim) ;
**** $315
The batinclude does a textual/string replace of arguments on the call with %1, %2, ... and hence what you get is not valid GAMS code. Moreover, you can't use the content/value of a set (lim) that changes at run time to rewrite code at compile time. The separation between compile and run time in GAMS is not easy to grasp first but essential and very powerful. I am not sure why you want what you describe in your post, but you would need to do it this way (determine this at runtime based on the content/value of lim) in test1.gms:
test_b%1lo(i)$sameas('lo',%2) = tofix(i,%2);
test_b%1up(i)$sameas('up',%2) = tofix(i,%2);
test_b%1fx(i)$sameas('fx',%2) = tofix(i,%2);
Hope this helps,
Michael