Heterogenous Contacts in UDEC

Hello all,
I want to create a heterogenous contact heterogenous grain model in UDEC. I defined block grain groups and also defined contact groups after which this is the FISH code I wrote:
fish define contact_group
ic = block.contact.head
loop while ic # 0
ind_b1 = block.contact.block1(ic)
ind_b2 = block.contact.block1(ic)

if block.group(ind_b1) = 'Dolomite'
    if block.group(ind_b2) = 'Dolomite'
        command
        block contact group 'Homogenous_Dolomite' range contact ic
        endcommand
    endif
    if block.group(ind_b2) = 'Periclase'
        command
        block contact group 'Heterogenous_Dolomite_Periclase' range contact ic
        endcommand
    endif
endif

if block.group(ind_b1) = 'Periclase'
    if block.group(ind_b2) = 'Periclase'
        command
        block contact group 'Homogenous_Periclase' range contact ic
        endcommand
    endif
    if block.group(ind_b2) = 'Dolomite'
        command
        block contact group 'Heterogenous_Dolomite_Periclase' range contact ic
        endcommand
    endif
endif

ic = block.contact.next(ic)
endloop
end

When I run this, I get this error:
imaget

What I think is ic is a local variable working inside FISH code only and command option works outside FISH(I may be wrong in this). How to rectify this problem?

Thanking You

The index for the range command should be found using. block.contact.id(ic)

If you are using command-end_command, you need to tell the command that ic is a FISH variable.
Use:
block contact group “name” range contact @ic
or:
block contact group “name” range contact [ic]