devxlogo

Tip Bank

Passing a unction as an argument

Question: How do I pass a function as a parameter? Answer: First, let’s distinguish between a parameter and an argument. The parameter is the type of the object passed. An

Strong Types

Question: How do you make the compiler generate an error when a variable is set to a value outide the range of the constrained type? For example; strong x; //strong

Extract null-delimited strings

Most API function that return a string require that you pass a buffer where they can place the result as a null-terminated ANSI string (a.k.a. ASCIIZ string). The calling code

Count substrings with the Replace function

You can often use the Replace function in a smewhat unorthodox ways to simplify (and sometimes optimize) your code. For example, in order to count the number of occurrences of

Avoid append operations with the Replace function

I find the Replace function very useful when I want to avoid too many append operations just to insert non-printable characters. For example, the following statement: MsgBox “Disk not ready.”

Convert a Number to a String

Question: How do I convert an integer/float type into a string? Answer: Converting numbers to strings is much easier than you think. Because JavaScript is an untyped language, the interpreter