Box Function Example
Computer Architecture, Developer Tool, Plugin

CREATING A BOX LAYOUT IN CMD-BOX FUNCTION BY KVC

Adding a GUI effect to your batch program is a very difficult task, especially for newer programmers. This function will help the users in Creating a Box Layout in the CMD console with different options. BatBox is a dependency for the Box function to function properly. In this article, We will be demonstrating the syntax and usage of the Box function. You can download the plugin on our official GitHub page.

RELATED VIDEO

SYNTAX

Box [help|/?|-h|-help]: shows how to use all functions of box function
Box ver : to see the version of box function
Box [X] [Y] [Height] [Width] [Sepration] [BG_Char] [color] [Type] [_Var]
Where:-
X          = X-ordinate of top-left corner of box
Y          = Y-co_ordinate of top-left corner of box
Height     = Height of the box
Width      = Width of the box
Separation = It is the width From where you want to separate the box, if 
             don't specify or specified '-' (minus), then the box will not
             be separated.
BG_char    = Background element of Box, if not specified or specified 
             '-'(minus), then no background will be shown. It should be a
             single Character.
color      = the color Code for the Box,e.g. fc,08,70,07 etc. Don't define
             it if you want the default color or type '-' (minus) for no 
             color change.
Type       = The style/type of the Box you want, double Border, single 
             Border, etc. New, No Border Option added [Valid values: 
             0 to 4]
_Var       = Variable to save output, instead of printing directly.
             (Optional)
ver        = Version of Box Function 

USAGE AND EXAMPLE

This function can be used in adding a little GUI effect to your batch program, and allows you to create a simple box on the CMD console at a specified X Y co-ordinate with different options. Below, we will demonstrate some examples of what you can do with the function.

Creating a Simple Box Layout

Lets create a simple box with the height and width given by the user. In this example given below I create a box with the height and width both as 10, at coordinates 4,4 :

box 4 4 10 10
example of creating a simple box

Box with separation and filled with character

We can also create a box with a separation, and fill it with characters instead of just empty spaces. As I show in the example below, you just have to add a number (shorter than the width of the box) where you want to create the separation as the fifth parameter (don’t specify or use ‘-‘ (minus), if you don’t want to create separation). To add character instead of free space, add any character as the sixth parameter as I have inserted ‘o’ (don’t specify or use ‘-‘ (minus), if you don’t want to add any character in the box).

box 4 4 10 20 10 o
Example of creating separation and adding character in the created box

Adding color and style to our box

We can also add color to the background or border of the box. To do that, you have to pass the seventh parameter containing two characters with our color code for the background and border respectively. In the example below I chose ‘1 ‘as the background color (navy blue), and ‘a’ as the color of the border (lime). We can also store the box ‘object’ in a variable. As shown in the example below, I stored the box in variable a by using ‘_a’ as the ninth parameter of the syntax and calling it using the BatBox plugin.

We can also change the style of the box by using numbers 0-4 as the eighth parameter. Where the numbers 0-4 are:

  • 0: No border
  • 1: Single lined border
  • 2: Double-lined border
  • 3: Double-lined top & bottom, single lined sides
  • 4: Single lined top and bottom, double-lined sides
box 4 4 10 10 - - 1a 2 _a
batbox %_A%
Example of adding color & style to a box and adding it in a variable

CONCLUSION

In this article, we learned how the box function helps in adding a GUI effect to your batch, to create a box layout in the CMD console. I hope you enjoyed reading this article, please share your thoughts below and make sure to join our Discord and YouTube community. For more plugins like this visit our site at Batch-man. Thank you for reading.

Leave a Reply