Other methods
Parameters in brackets are optional. As a general rule, you can't omit a parameter if the one following it is present. The only exception is the Offset parameter in NumGet, NumPut, StrGet, and StrPut. It can be omitted from the middle of the parameter list (together with its comma).ArrPtr( Array ) — returns a pointer to the SAFEARRAY structure of an array.
- Array — an array variable. Does not work for JScript arrays because they are actually objects.
LastError( [Flag] ) — if the function you have just called was registered with the "l" flag (last error), the method returns the error code obtained from a call to the GetLastError API made immediately after the return of the registered function.
- Flag — if set to 1, the method will return a text description for the error.
Before the registered function is called, this code is set to 0 via SetLastError(0). See in the function's documentation whether or not it sets this code and it makes sense to check it.
- Bytes — the size of the memory block, in bytes.
- ZeroMem — if set to 1, the memory will be filled with binary zeros.
- MemPtr — a pointer returned by MemAlloc.
- Address — the address of the block.
- Bytes — the size of the block, in bytes.
- SrcAddr — source address.
- DestAddr — destination address.
- Bytes — the number of bytes to copy.
The blocks can overlap.
The return value will be the address just after the last written byte.
- Address — the address of the block.
- Bytes — the size of the block, in bytes.
- BytesPerGroup — the number of bytes in each group.
- GroupsPerLine — the number of groups on each line.
Groups will be separated by spaces, and lines by newlines (CRLF).
- HexStr — the source string.
- DestAddr — the destination address.
- Bytes — the number of bytes to write. If omitted or set to 0, the entire string is written.
In a hex string each byte is represented by two characters. The string can contain spaces, tabs, newlines, and comments allowed for the RegisterCode method.
The return value will be the address just after the last written byte. If DestAddress is 0, the method returns the size in bytes of the buffer required for the binary representation of the hex string. This can be useful if you write the entire string and it contains spaces, etc., which will not be written.
- Address — the address to read from.
- Offset — a displacement in bytes from Address, positive or negative; 0 by default.
- Type — the type of the retrieved number (see the list
here); "l" by default. Only input types can be used.
The number is put in the value returned by the method.
- Var — either a literal number or the name of a variable holding it.
- Address — the address to write to.
- Offset — a displacement in bytes from Address, positive or negative; 0 by default.
- Type — the type of the number (see the list
here); "l" by default. Only input types can be used.
The return value of the method will be the address just after the last written byte.
- Object — an object variable.
- ObjPtr — a pointer to an object. If the object supports the IDispatch interface, a VT_DISPATCH variable is returned, otherwise VT_UNKNOWN. The reference counter of the object is incremented.
- Var — a string variable.
- Type/Codepage — the type or encoding of the destination string. Can be: w (by default), s, z (see their meaning here); a codepage, e.g. "cp1252"; a codepage name, e.g. "UTF-8", "UTF-16 BE". If the name is unknown to the method, it will look it up under the registry key HKEY_CLASSES_ROOT\MIME\Database\Charset, so you can use the names of its subkeys for this parameter. For s, z, or a codepage the string is previously converted in place.
If the resulting string does not fit in the original string's buffer, it will be truncated. Since the original is in Unicode, where each character takes two bytes, there will be more than enough space in most cases. Maybe some East-Asian text can be longer in an ANSI or UTF-8 encoding than it is in UTF-16, but I am just guessing.
Whether or not it makes sense to obtain such a pointer depends on whether the scripting engine copies strings when passing them to a method. If it does, you will get a pointer to a temporary copy, which is useless.
- Address — the address to read from.
- Offset — a displacement in bytes from Address, positive or negative; 0 by default.
- Type/Codepage — the type or encoding of the source string. For options see StrPtr.
- Address — the address to write to.
- Offset — a displacement in bytes from Address, positive or negative; 0 by default.
- Type/Codepage — the type or encoding of the destination string. For options see StrPtr.
The method returns the address after the string's null terminator. If you set Address to 0 (Offset also 0 or omitted), the method will return the size in bytes of the buffer required for the destination string, including the terminating null character.
- Count — the number of Unicode (two-byte) characters in the string.
- Char — a character to fill the string with. By default the string is filled with spaces, just as the Space function in VBScript does. To use nulls instead of spaces, specify Char as an empty string ("").
Note: This method was originally designed for creating strings that would serve as memory buffers — for numbers, structures, or output strings. However, practice has revealed that this technique is generally unsafe. You never know how the scripting engine will treat the memory allocated for a string; in other words, you do not have full control over it and your data stored in there may get lost or damaged. For this reason I recommend using MemAlloc to allocate memory.
- Variable — a script variable. In languages that pass variables to methods by reference, like VBScript, you will get a pointer to the variable's VARIANT; in those that pass them by value, like JScript, it will be a poiter to a temporary copy and therefore useless.
- Field — set it to the appropriate value from the table below. If Field is omitted, it equals 0.
Suppose the full version is 2.5.7.10.
0 — version string: "2.5.7.10"
1 — major version number: 2
2 — minor version number: 5
3 — build number: 7
4 — revision number: 10 (0xA)
5 — major + minor number: 0x20005
6 — build + revision number: 0x7000A
7 — full version number: 0x200050007000A
As you can see, each field is a 16-bit integer and occupies two bytes.