Script to count in binary format

Script to count in binary format

27
Basic UserBasic User
27

    Sep 11, 2013#1

    Hi,

    I often use the function "insert number" which is very useful.
    But as i write VHDL file, i need sometine to count in binary. But function "insert number" only insert decimal or hexadecimal function.
    Ok, i've noticed that another function "number convert" is available in UE.

    So, i'm wondering how to use both of them (or something else) to create an "insert number" script which are count in binary?

    Thanks for your help.

    6,602547
    Grand MasterGrand Master
    6,602547

      Sep 11, 2013#2

      Here is a simple example for outputting a positive, incrementing integer number as binary string to show you the technique. You can do whatever you want with string value in variable sBinary.

      Code: Select all

      UltraEdit.outputWindow.clear();
      UltraEdit.outputWindow.showWindow(true);
      var sLeadingZeros = "00000000";
      for (var nNumber = 0; nNumber < 256; nNumber++)
      {
         var sBinary = nNumber.toString(2);
         var nLeadingZeroQuantity = sLeadingZeros.length - sBinary.length;
         if (nLeadingZeroQuantity > 0)
         {
            sBinary = sLeadingZeros.substr(0,nLeadingZeroQuantity) + sBinary;
         }
         UltraEdit.outputWindow.write("Number "+nNumber.toString(10)+" = "+sBinary);
      }
      Core functions used are String.substr and Number.toString

      27
      Basic UserBasic User
      27

        Sep 12, 2013#3

        Thanks for your help.
        I'll use it to make my script.