how to reference the index item in arrays

I am allowing the user to input multiple port descriptions separated by commas which i am receiving in an array.

The goal is print them individually for each port.

below is the script.

script ChangeInterfacesBasedOnDescription (
NCM.Nodes @ContextNode,
NCM.Interfaces[] @TargetPorts,
string[] @Itfname )
{
// Enter configuration mode
CLI
{
configure terminal
}
// Loop through selected interfaces
int @Temp = 0
foreach (@portItem in @TargetPorts)
{
if (@portItem.InterfaceAlias contains 'GNS')
{
// Do nothing if it's not a physical interface or Uplink Interfaces
}
else
if (@portItem.InterfaceType != '6')
{
// Do nothing if it's not a physical interface or Uplink Interfaces
}
else
{
// Set command
CLI
{
interface @portItem.InterfaceDescription
name @Itfname[]
@Temp = @Temp + 1
}
CLI
{
exit
}

}
}
// Exit configuration mode
CLI
{
exit
}
}

When i execute this remplate i get the below error:

Error: Variable @tempitem could not be matched. Possible causes of this are:
Invalid input: Error:
1) It has not been declared.
Invalid input: 1)
2) You are referencing an entity property which does not exist.
Invalid input: 2)

Any ideas or advise ?

Thanks

Amit

Top Replies

Parents Reply Children
No Data