Revision 4.1.0 ------------------------------------------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------------------------------------------ The Window Batch Library is a collection of pre-written batch scripts that can be used to simplify and speed up the process of creating command-line interfaces (CLIs) and other types of text-based user interfaces (TUIs). The library includes a wide range of functions and macros, including standard console manipulations, mathematical calculations, color and text formatting, and mouse input. Overall, the Window Batch Library is a powerful tool for anyone looking to create command-line interfaces or other types of text-based user interfaces using Windows Batch scripting. By providing a range of pre-written functions and macros, the library can help streamline the development process and make it easier to create complex and powerful applications using the command line. Open the library by substituting '?' with the name of the library in the variable %(% and check if the required revision OR LESS is being used. If everything checks out, it will CALL :FUNCTIONS from INSIDE the "Library.bat." Library.bat contains many labels, but not all of them are intended to be called, rather than they are book markers when using Notepad++. Clicking the "fx" button on the top menu bar will display all of the "book marks" as well as labels intended to be called by the user. Be mindful of the documentation below, as well as the "DON'T CALL" next to the labels that are not intended to be called. Thanks <3 ------------------------------------------------------------------------------------------------------------------------------------------ @echo off & setlocal enableDelayedExpansion & set "(=(ren "%~nx0" -t.bat & ren "Library.bat" "%~nx0"" & set ")=ren "%~nx0" "Library.bat" & ren -t.bat "%~nx0")" & set "self=%~nx0" & set "failLib=ren -t.bat "%~nx0" &echo Library not found & timeout /t 3 /nobreak & exit" %(% && (call :revision 4.1.0)||(%failLib%) call :stdlib /w:N /h:N /fs:N /title:"foobar" /debug /extlib /math /misc /shape /ac /cursor /cr:N /gfx /util %)% pause ------------------------------------------------------------------------------------------------------------------------------------------ CALL :STDLIB STDLIB provides the following variables for you to use. %pixel% - Û character %.% - Û character %esc% - esc character Example: echo %esc%[5;5HHello World %\e% - esc Example: echo %\e%[5;5HHello World %cls% - echo or - Provides the following variables to be used in set /a using substitution. EX: echo %cursor[D]:?=1% %>% - - Provides the following variables to be used in set /a using substitution. EX: %SIN:x=90% %gravity% - substitute ? for affected variable accerlation increases by 1 per frame, velocity increases by accerlation per frame, Y position is increased by velocity per frame provides as variables: %_G_% - Gravity added to Accerlation %?.acceleration% - Acceleration add to Velocity %?.velocity% - Velocity added to substituted ? %chance% - provide x. requires 2>nul redirection, but works as such. EX: set /a "%chance:x=25%" && ( echo 25 percent chance ) || ( echo 75 percent chance ) %every% - provide x MUST ITERATE frameCount+=1 EX: set /a "%every:x=frameCount%" && ( code ) %smoothStep% - provide x %bitcolor% - translate R G B to BITCOLOR %ifOdd% - provide x EX: set /a "%ifOdd:x=3%" && ( code ) %ifEven% - provide x EX: set /a "%ifEven:x=3%" && ( code ) %RCX% - provide x returns 1 if 0 < x < wid EX: set /a "%RCX:x=-10%" || ( code ) %RCY% - provide x returns 1 if 0 < x < hei EX: set /a "%RCY:x=-10%" || ( code ) %edgeCase% - provide x, y returns 1 if 0 < x & y < wid & hei EX: set /a "%edgeCase%" && ( code ) %rndBetween% - provide x get a random number between -x and x %fib% - returns fibonacci sequence %mouseBound% - provide ma, mb, mc, md as edge cases to mouse clicks. ------------------------------------------------------------------------------------------------------------------------------------------ /SHAPES /sh - Provides the following variables to be used in set /a using substitution. EX: %SIN:x=90% %SQ(x)% - provide x - returns x^2 or area of square. %CUBE(x)% - provide x - returns x^3 or area of cube %pmSQ(x)% - provide x - returns x * 4 %pmREC(l,w)% - provide l, w - returns l * 2 + w * 2 %pmTRI(a,b,c)% - provide a, b, c - returns a + b + C %areaREC(l,w)% - provide l, w - returns l * w %areaTRI(b,h)% - provide b, h - returns b * h / 2 %areaTRA(b1,b2,h)% - provide b1, b2, h - returns b1 * b2 * h / 2 %volBOX(l,w,h)% - provide l, w, h - returns l * w * h ------------------------------------------------------------------------------------------------------------------------------------------ /ac ALGORITHMIC CONDITIONS - Provides the following variables to be used in set /a using substitution. EX: %SIN:x=90% %LSS(x,y)% - provide x, y - < %LEQ(x,y)% - provide x, y - <= %GTR(x,y)% - provide x, y - > %GEQ(x,y)% - provide x, y - >= %EQU(x,y)% - provide x, y - == %NEQ(x,y)% - provide x, y - != %AND(b1,b2)% - provide b1, b2 - && %OR(b1,b2)% - provide b1, b2 - || %XOR(b1,b2)% - provide b1, b2 - ^ %TERN(bool,v1,v2)% - provide bool, v1, v2 - ?: ------------------------------------------------------------------------------------------------------------------------------------------ /cr <1-255> - Provides array of colors sorted in RGB in color[] Use %totalColorsInRange% (CONSTANT) to get the max out the the color[] array Also provides %range% (CONSTANT) which is 255 / %~1 ------------------------------------------------------------------------------------------------------------------------------------------ /gfx Provides functions for gfx work %frames% - use with set /a to get %frameCount% Example: set /a "%frames%" %loop% - begin infinite loop (NOT A MATH OPERATION) SEE LINE: :MISC/loop in Library.bat %framedLoop% - infinite loop that counts and loops at the 32bit limit %throttle% - provide x to THROTTLE the script. (this can make animations that are too fast look better) (NOT A MATH OPERATION) SEE LINE: :MISC/throttle in Library.bat %point% - x y _scrn_ draws %pixel% at x y to %_scrn_% %plot% - x y 0-255 CHAR _scrn_ draws CHAR at x y to %_scrn_% %RGBpoint% - x y 0-255 0-255 0-255 CHAR _scrn_ draws CHAR at x y in color specified to %_scrn_% %translate% - x Xoffset y Yoffset shift x and y by their offset %Bvector% - name[ID] diameter character/sprite %~2 & %~3 not necessary %~1.x %~1.y %~1.td %~1.tr %~1.m %~1.i %~1.j %~1.rgb creates vector[ID] with the following attributes x - x position 1 to wid unless %~2 is provided where %~2 to wid-%~2 y - y position 1 to hei unless %~2 is provided where %~2 to hei-%~2 td - thetaDegrees 0 to 360 tr - thetaRadians 0 to 62832 m - magnitude 2 to 4 i - x increment -2 to 2 j - y increment -2 to 2 rgb - vectors color 0 to 255 fcol - vectors color 0 to 255 if %~2 is defined vd - diameter vr - radius vmw - vectors Max Width vmh - vectors Max Height if %~3 is defined ch - character or spriteVariable usage: %Bvector% this echo %this.x% %this.y% %this.td% %this.tr% %this.m% %this.i% %this.j% echo %this.rgb% %this.fcol% %this.vd% %this.vr% %this.vmw% %this.vmh% %this.ch% %lerpRGB% - 1 2 (1-100:blend amount) $r $g $b blend two RGB values together using r[] g[] b[] %~1 - r[1] g[1] b[1] %~2 - r[2] g[2] b[2] %~3 - blend amount %getDistance% - x2 x1 y2 y1 youNameIt get the distance between two points no need to define x2 x1 y2 y1 first like when using %dist% from :math %exp% - num pow youNameIt calculate exponents %circle% - x y ch cw $circle draw a circle to $circle at x y at the size of CHxCW %rect% - x r wid hei $rect draw a rectangle to $rect at x y the size of HEIxWID %line% - x0 y0 x1 y1 color $line draw a line to $line from x0 y0 to x1 y1 %bezier% - x1 y1 x2 y2 x3 y3 x4 y4 length $bezier draw a bezier curve from x1 y1, x2 y2, x3 y3, x4 y4 at your desired length %RGBezier% - x1 y1 x2 y2 x3 y3 x4 y4 length $RGBezier draw a bezier curve from x1 y1, x2 y2, x3 y3, x4 y4 at your desired length works with :colorRange %arc% - x y size DEGREES(0-360) arcRotationDegrees(0-360) lineThinness color _scrn_ draws an ARC on the screen %plot_HSL_RGB% - x y 0-360 0-10000 0-10000 _scrn_ plot in HUE SATURATION LUMINOUSITY %plot_HSV_RGB% - x y 0-360 0-10000 0-10000 _scrn_ plot in HUE SATURATION VALUE %clamp% - x min max youNameIt clamp x between MIN and MAX ------------------------------------------------------------------------------------------------------------------------------------------ /util Provides functions for gfx work %sort[fwd]% - sort a string forward %sort[rev]% - sort a string backward %hexToRGB% - '00a2ed' no quotes R G B converts hex to to R G B values %getLen% - "string" $length get the length of a string %pad% - "string".int $padding padding function to get nice spacing in "menus". %encode% - "string" base64 encode a string in base64 using certutil %decode% - %decode:?=!base64!% decode a given string in base64 old name: $string_ %string_properties% - "string" $_len, $_rev $_upp $_low use to get the length, reverse, upper, and lower version of the provided string old name: injectStringIntoFile %fart% - %fart:?=FILE NAME.EXT% "String":LineNumber Use to inject/swap specific lines in files %getLatency% - %latency% use to see your current ping %download% - %url% %file% download a file via url %zip% - file.ext zipFileName zipping tool using TAR %unzip% - zipFileName unzipping tool using TAR %license% - "mySignature" NOTE: You MUST add at least 1 signature to your script ":::mySignature" without the quotes It is important that you do NOT add this to your code until you are COMPLETELY finished editiing it, and ready to release. This function calculates a magic number based on the script itself, and stores the value in a file in %temp% Once you add this to your script, AND RUN IT, you can NOT modify your script. It WILL delete itself. This is to protect the creators work from being tampered with. USE AT YOUR OWN RISK!!! ------------------------------------------------------------------------------------------------------------------------------------------