java -cp ../../zbnfjax/zbnf.jar org.vishia.zcmd.JZcmd testSetIp.jz.bat
pause
exit /B

==JZcmd==
main(){
  call testIpset();
}


##Checks whether the existing network adapter has the expected IP address.
##Sets the ip address to the network adapter if not given.
##This may be necessary if a device is in a automation network were all devices have a defined IP.
sub testIpset(){
  Stringjar result;
  String ipOwn = "192.168.1.62";      //The expected IP address.
  //String ipOwn = "192.168.1.63";
  String nameNetAdapter = "XXLAN-Verbindung";  //The known name of the network adapter.
  result += cmd ipconfig;             //calls the command line ipconfig.exe
  if(!result.seek(ipOwn).found()){    //checks whether the expected address is found.     
    <+out><:>IP-Adresse <&ipOwn> - is faulty. Invoke setip.bat<.><.n+>
    result = <:>set network adapter<.>;                      
                                      //set the address to the network adapter using the operation system command:
    result += cmd cmd.exe /C netsh interface ip set address <:>name="<&nameNetAdapter>"<.> static <:><&ipOwn><.> 255.255.255.0 192.168.1.1 1;
    <+out><&jzcmdsub.cmdErrorlevel>: <&result><.n+>  //writes the error level from the last cmd execution.
    result += cmd ipconfig;
  }
  <+out><&result><.+n>
  onerror{
    <+out>Any error: <&error><.n+>
  }

}
