using_symbolctl
no way to compare when less than two revisions
Differences
This shows you the differences between two versions of the page.
— | using_symbolctl [2008/11/30 19:14] (current) – created - external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | #$EPIC: using_symbolctl.txt, | ||
+ | ======Things you can do with symbolctl: | ||
+ | |||
+ | =====Create your own SETs====== | ||
+ | You can create your own [[set]] with symbolctl. | ||
+ | this very simple for you. | ||
+ | |||
+ | alias addset (name, type, ...) { | ||
+ | if (@name && type) { | ||
+ | @ symbolctl(create $name); | ||
+ | @ symbolctl(set $name 1 builtin_variable type $type); | ||
+ | if (@) { | ||
+ | @ symbolctl(set $name 1 builtin_variable script $*); | ||
+ | }; | ||
+ | }; | ||
+ | }; | ||
+ | |||
+ | Creating a set requires three steps: | ||
+ | @ symbolctl(create $name) | ||
+ | First you have to make sure that the symbol name exists in the symbol table. | ||
+ | You can't manipulate a symbol name that doesn' | ||
+ | |||
+ | @ symbolctl(set $name 1 builtin_variable type $type) | ||
+ | Next you have to define the type of [[set]] that your [[set]] will be. This | ||
+ | can either be BOOL, CHAR, INT, or STR. BOOL mean you can [[set]] it to OFF | ||
+ | or ON. CHAR means you can set it to a single character. | ||
+ | set it to a number. | ||
+ | its type, you implicitly create the [[set]]. | ||
+ | |||
+ | @ symbolctl(set $name 1 builtin_variable script $*) | ||
+ | Finally you can give it some code that you want to have executed every time the | ||
+ | [[set]] is changed. | ||
+ | by curly braces {....}. | ||
+ | and you can overrule it by changing the set in your own code. | ||
+ | |||
+ | =====Example: | ||
+ | addset cantturnmeoff bool { | ||
+ | if (* == [ON]) { | ||
+ | echo Sorry dave, I can't let you do that. | ||
+ | set cantturnmeoff off | ||
+ | } | ||
+ | } | ||
+ | |||
+ | =====Doing command completion: | ||
+ | $symbolctl(PMATCH < | ||
+ | | ||
+ | returns | ||
+ | " | ||
+ | |||
+ | |||
+ | =====Checking to see if something exists before using it:===== | ||
+ | ====Usage: | ||
+ | $symbolctl(GET < | ||
+ | $symbolctl(GET < | ||
+ | $symbolctl(GET < | ||
+ | ====Synopsis: | ||
+ | Returns 0 if these types are not in use (ie, if there is not a | ||
+ | built in command), and returns non-zero if there is. If you' | ||
+ | smart, you won't try to do anything with the non-zero value. | ||
+ | |||
+ | |||
using_symbolctl.txt · Last modified: 2008/11/30 19:14 by 127.0.0.1