How to use variables in string concatenation

Hi folks!

 

Is there any way to use variables in a string concatenation? What I'm exactly trying to do is to make use of a variable as part of an IP address, e.g.:

 

10.10.@DataNet.122

 

Which  should lead to an output similar to: 10.10.10.122, if 10 was the specified value.

 

Output fails with the following message:

Error:Variable @DataNet.80.5 could not be matched. Possible causes of this are:
1) It has not been declared.
2) You are referencing an entity property which does not exist.
3) You are missing a closing bracket in a prior native block.

I think this problem is located in the way entities are used. Is there any possibility to escape the period after the used variable or something?

 

Thanks in advance!

Parents
  • Hi all - this is a known issue - and we do have a workaround - but it's a tiny bit messy.  

     

    This is supported: 
     
    string @String1
    string @String2
    string @String3
     
    @String3 = @String1 + @String2
     
    This can be applied to the IP scenario 10.10.@DataNet.122 by setting string variables for the literal parts of the IP, then concatenating them all together:
     
    string @IpStart = ‘10.10.’
    string @IpEnd = ‘.122’
     
    @IpStart + @DataNet + @IpEnd

     
    I hope that helps!
    --Christine
  • Hi Christineb and MarieB,

    Thank you for responding to this thread. Can you please provide something in the form of an example ncm-template for this?

    I have attempted to implement your workaround, however the proof of concept below outputs the following error.

    Error:Cannot assign 3 of type System.Int32 to variable @String3 of type string.

     

    script CreateConfig (   

                                    NCM.Nodes @ContextNode)

    {

      //TODO - insert details of change template

     

    string @String1='1'

    string @String2='2'

    string @String3 = @String1 + @String2

      //Enter CLI commands

      CLI

      {

         configure terminal

         //Use variables in commands sent

    @String3

      }

    }

     

    Also tried the following and got 3 as the result.

    script CreateConfig (   

                                    NCM.Nodes @ContextNode)

    {

      //TODO - insert details of change template

     

    string @String1='1'

    string @String2='2'

      //Enter CLI commands

      CLI

      {

         configure terminal

         //Use variables in commands sent

    @String1+@String2

      }

    }

     

    Any additional help would be greatly appreciated.

  • Let me look into this - I'll get back to you on this thread. 

    --Christine 

Reply Children
No Data