Categories

If there are many global functions, writing and reading code can be easier if they are grouped into categories. Then you can use category.function syntax to access them, and have members popup when you type period after category name.

 

 

Most functions are added to categories (declared in System\Declarations\Categories). To view list of categories, type period somewhere in macro text.

 

How to define categories

A category is an user-defined type declared using special syntax. In type definition, instead of (or in addition to) normal member variables, you can add any global identifiers (user-defined functions, intrinsic functions, constants, etc) as members. Such identifiers aren't true members, but you can use category.identifier syntax to access them. They also are displayed in type-info popups. In type definition, names of global identifiers follow optional data members and colon (colon must be separated by spaces). You can optionally use keyword category instead of type (this only affects icon and placement in the popup list of global identifiers). Example:

 

 define category files:
category files : run cop ren del mkdir dir iff
	SetCurDir GetCurDir

 use functions from files category:
out files.GetCurDir   ;;same as out GetCurDir
files.iff("abc.exe") ;;same as iff("abc.exe")
	files.run "abc.exe" ;;same as run "abc.exe"

 

Syntax category.identifier is equivalent to simply identifier (category is ignored). The identifiers aren't strictly attached to the type. Actually, any global identifier may follow typename and period, and it will not generate error. Category declaration can even include nonexisting identifiers.

 

Category declaration can include other types as subcategories. One category can be derived from another category.

 

Category declaration can include dlls. Then the type-info popup also shows all declared functions from those dlls. Dll names must be enclosed in quotes. Example:

 

category api : "user32" "kernel32" "gdi32" "shell32"

 

Category declaration can include QM folders. Then the type-info popup also shows all functions and classes from those folders and subfolders (except private subfolders). Folder name or \path must be preceded by > and enclosed in quotes. Example:

 

category internet : ">\System\Functions\Internet" IeWait Ftp Http

 

Default categories include folders from the System\Functions folder and also from the User\Functions folder. If you want to add your functions to default categories, do the following: Open System\Declarations\Categories function, see what folders are defined for user functions, create such folders, and move your functions there. For example, to add a function to the defaut internet category, create folder User, folder Functions in it, folder Internet in it, and move the function there.

 

See also: declarations scope