Quantcast
Channel: THWACK: All Content - Network Configuration Manager
Viewing all articles
Browse latest Browse all 6057

same variable in if/else statements

$
0
0

Hello Everyone,

 

I'm trying to learn the intricacies of the NCM scripting language and trying to answer another question on the forums as some practice (NCM Config Template variable / parsing assistance ) and I'm having some issues at a very basic part of the solution.

 

I wrote the following piece of the script which is supposed to test if a host has a domain name defined and if yes, then remove it and pass it into @hostname, else just pass the entire NCM.Nodes.SysName to @hostname.

 

script getHostname(NCM.Nodes @ContextNode )
{
  string @dot = '.'
  if (@ContextNode.SysName contains @dot)
  {
    int @suffix = indexof(@ContextNode.SysName,@dot) - 1
    string @hostname = substring(@ContextNode.SysName, 1, @suffix)
  }
  else
  {
  string @hostname = @ContextNode.SysName
  }
}

 

When I run the script I get the following error:

 

 

It works perfectly if I use two different variable names, but the point is that I want to give the same variable different values based on an if/else statement.


Viewing all articles
Browse latest Browse all 6057

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>