Skip to content

Latest commit

 

History

History
47 lines (33 loc) · 1.38 KB

__ How to use my functions.md

File metadata and controls

47 lines (33 loc) · 1.38 KB

How to use my functions

Table of Contents


Copy the code in your script

Copy the lines contained between the ':::::::' marks (including them) at the end of your code.

To call the function:

CALL :<FunctionName> [<Param> ... ]

PROS:

  • All the code is in one file. Ideal for small scripts with only one or two functions.
  • Calling the function is simple.

CONS:

  • The file can become very long if you use multiple functions.
  • Difficult to update functions in case of new versions.
  • Cannot share code between different scripts.

Add the .CMD file to your project folder

Copy the function's CMD file to a folder in your project (for example, ".\Functions"), or a folder on your disk if you're sharing it with multiple projects (for example, "X:\Scripts\Functions").

To call the function:

:: Set a variable with your functions folder ending in '\'
SET "Func_=.\Functions\"

:: Call the function like this
CALL %Func_%<FunctionName> [<Param> ... ]

PROS:

  • Easy to update in case new versions of the functions are released.
  • Functions can be shared between multiple scripts.
  • Easier to read code.

CONS:

  • The way of calling functions can be a bit confusing.