If the variable is not a global variable then you do not need the udg_, but all GUI variables are global variables.
This is what the SetUnitAnimationByIndex() function header looks like incase it helps you out:
[ljass]native SetUnitAnimationByIndex takes unit whichUnit, integer whichAnimation returns nothing[/ljass]
So when you use it it should look like this:
[ljass]call SetUnitAnimationByIndex(whichUnit, integer)[/ljass]
Yes you can, but if you're using GUI remember that all variables have a "udg_" in from of the variable. For instance, if you have a GUI variable called "myUnit", in JASS/Custom Script the variable is referred to as "udg_myUnit".
You would need to put the desired unit or unit variable in the <unit> part, and the desired integer (whole number, no fractions/decimals) in the <Integer> portion. And also it's [ljass]call SetUnitAnimationByIndex(unit whichUnit, integer index)[/ljass]