# Introduction to Variable Functions

[Home] [Commands] [Variables] [Macro-Dev] [Glossary]

## VARIABLE FUNCTIONS

Functions can be used to manipulate variables in various ways. Functions have in general one, two, or three arguments. These arguments will always be placed after the function on the current command line. For example, if we wanted to increase the current fill column by two, using MicroEmacs's set-variable(2) (C-x v) command, we would write:

    set-variable $fill-col &add $fill-col 2
        \            \      \       \     \____second operand
         \            \      \       \_________first operand
          \            \      \________________function to execute
           \            \______________________variable to set
            \__________________________________set-variable (C-x v) command

Functions always begin with an ampersand (&) character, and are only significant to the first 3 characters after the ampersand. Functions will normally expect one of three types of arguments, and will automatically convert types when needed.

<num>

An ASCII string of digits which is interpreted as a numeric value. Any string which does not start with a digit or a minus sign (-) will be considered zero.

<str>

An arbitrary string of characters. At the moment, strings are limited to 128 characters in length.

<log>

A logical value consisting of a non-zero number for TRUE (e.g. "`1`"), anything else is considered FALSE (e.g. "`0`" or "`foo`"). This differs from earlier versions of MicroEmacs where the strings "`TRUE`" and "`FALSE`" were used.

A list of the currently available functions follows:

Numeric Functions (returns <num>)

&abs(4) Absolute value of a number
&add(4) Add two numbers
&dec(4) Pre-decrement variable
&divide(4) Division of two numbers
&inc(4) Pre-increment variable
&mod(4) Modulus of two numbers
&multiply(4) Multiply two numbers
&negate(4) Negation of two numbers
&pdec(4) Post-decrement variable
&pinc(4) Post-increment variable
&sub(4) Subtract two numbers

Bitwise Functions (returns <num>)

&band(4) Bitwise AND operator
&bnot(4) Bitwise NOT operator
&bor(4) Bitwise OR operator
&bxor(4) Bitwise XOR operator

String manipulation functions (returns <str>)

&cat(4) Concatenate two strings together
&left(4) Return the left most characters from a string
&len(4) Return the length of a string
&mid(4) Return a portion (middle) of a string
&right(4) Return the right most characters from a string
&slower(4) Return the string converted to lower case
&sprintf(4) Formatted string construction
&supper(4) Return the string converted to upper case
&trboth(4) Return string trimmed of white chars on both sides
&trleft(4) Return string trimmed of white chars on left side
&trright(4) Return string trimmed of white chars on right side

List manipulation functions (returns <str>)

&ldel(4) Delete list item
&lfind(4) Find list item
&lget(4) Get list item
&linsert(4) Insert list item
&lset(4) Set list item

Logical testing functions (returns <log>)

&and(4) Logical AND operator
&equal(4) Numerical equivalence operator
&great(4) Numerical greater than operator
&isequal(4) Case insensitive String equivalence operator
&less(4) Numerical less than operator
&not(4) Logical NOT operator
&or(4) Logical OR operator
&sequal(4) String equivalence operator
&sgreat(4) String greater than operator
&sless(4) String less than operator
&xisequal(4) Case insensitive regex String equivalence operator
&xsequal(4) Regex string equivalence operator

Miscellaneous functions

&atoi(4) ASCII to integer conversion
&bmode(4) Determine buffer mode
&bstat(4) Retrieve current buffer statistic
&cbind(4) Return the command a key is bound to
&cond(4) Conditional expression operator
&exist(4) Test if a variable or command exists
&find(4) Find a file on the search path
&gmode(4) Determine global mode
&indirect(4) Evaluate a string as a variable
&inword(4) Test for a word character
&irep(4) Case insensitive replace string in string
&isin(4) Case insensitive test for string in string
&itoa(4) Integer to ASCII conversion
&kbind(4) Return the key a command is bound to
&nbind(4) Return the numerial argument of a binding
&nbmode(4) Determine named buffer mode
&opt(4) MicroEmacs optional feature test
&rep(4) Replace string in string
&risin(4) Recursive case insensitive test for string in string
&rsin(4) Recursively test for string in string
&set(4) In-line macro variable assignment
&sin(4) Test for string in string
&stat(4) Retrieve a file statistic
&which(4) Find a program on the path
&xirep(4) Regex case insensitive Replace string in string
&xrep(4) Regex replace string in string

## SEE ALSO

Directives

(c) Copyright JASSPA 2009
Last Modified: 2009/10/12
Generated On: 2009/10/12

</HMTL>