many errors when compiling the C program

I haven't seen Gosub used in many many years and not in Arduino so I can't tell what might be wrong there except that they simply might not work in v1.0 I did notice you use if/endif instead of if { }. I'm not sure if this syntax works in the IDE or not. In traditional C if loops, an equal to comparison is done with a double ==. This may or may not be causing problems as well since I am unfamiliar with using a VB style if/end if syntax in the arduino IDE.

I did notice some missing ';'.

g_pinCommLatch1=LOW
g_pinCommLatch2=LOW
g_pinCommLatch3=LOW

Every one of the errors you are getting are related to a syntax error where you have fumble fingered something or left out something. Fix those 3 and see if it starts to shorten your list.

Did you copy this code from somewhere or write it yourself?

I only ask because this is A LOT of code to not have built many times to catch these types of errors in pieces instead of catching all the errors in one build which makes it much more difficult to track down the problems.