ref: 1d174f37da1407b7fbcbe46f48cf2697181c39ec
dir: /doc/asm/expr_str.htm/
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html;charset=UTF-8"> <title>xAsm String expressions</title> <link rel="stylesheet" type="text/css" href="../style.css"> </head> <body> <h1>String Expressions</h1> <p>The most basic string expression is any number of characters contained in double quotes ("for instance"). As in C the escape character is <b>\</b> and there is a number of commands you can use within a string:</p> <table> <caption>Escape characters:</caption> <thead> <tr> <th scope="col">Character sequence</th> <th scope="col">Meaning</th> <th scope="col">Notes</th> </tr> </thead> <tr> <td>\\</td> <td>Backslash</td> <td></td> </tr> <tr> <td>\"</td> <td>Double-quote</td> <td></td> </tr> <tr> <td>\{</td> <td>Curly bracket left</td> <td></td> </tr> <tr> <td>\}</td> <td>Curly bracket right</td> <td></td> </tr> <tr> <td>\n</td> <td>Newline ($0A)</td> <td></td> </tr> <tr> <td>\t</td> <td>Tab ($09)</td> <td></td> </tr> <tr> <td>\1-\9</td> <td>Macroargument</td> <td>Only in macros</td> </tr> <tr> <td>\@</td> <td>Labelname suffix</td> <td>Only in macros and repts</td> </tr> </table> <p>A funky feature is <b>{symbol}</b> withing a string. This will examine the type of the symbol and insert its value accordingly. If symbol is a string symbol the symbols value is simply copied. If it's a numeric symbol the value is converted to hexadecimal notation and inserted as a string.</p> <p><strong>HINT:</strong> The <b>{symbol}</b> construct can also be used outside strings. The symbols value is again inserted as a string. This is just a short way of doing "{symbol}".</p> <p>Whenever the macro-language expects a string you can actually use a string expression. This consists of one or more of these function. Yes, you can nest them. Note that some of these functions actually return an integer and can be used as part of an integer expression!</p> <table> <caption>String functions:</caption> <thead> <tr> <th scope="col">Name</th> <th scope="col">Operation</th> </tr> </thead> <tr> <td>STRLEN(<i>stringexpr</i>)</td> <td>Returns the number of characters in <i>string</i></td> </tr> <tr> <td>STRCAT(<i>stringexpr1,stringexpr2</i>)</td> <td>Appends <i>stringexpr2</i> to <i>stringexpr1</i>.</td> </tr> <tr> <td>STRCMP(<i>stringexpr1,stringexpr2</i>)</td> <td>Returns negative if <i>stringexpr1</i> is alphabetically less than <i>stringexpr2</i><BR>Zero if they match<BR>Positive if greater than</td> </tr> <tr> <td>STRIN(<i>haystack,needle</i>)</td> <td>Returns <i>needle</i>s position within <i>haystack</i> or zero if it's not present</td> </tr> <tr> <td>STRSUB(<i>stringexpr,pos,count</i>)</td> <td>Returns a substring of <i>stringexpr</i> starting at <i>pos</i> (first character is position 1) and with <i>count</i> characters</td> </tr> <tr> <td>STRUPR(<i>stringexpr</i>)</td> <td>Converts all characters in <i>string</i> to capitals and returns the new string</td> </tr> <tr> <td>STRLWR(<i>string</i>)</td> <td>Converts all characters in <i>string</i> to lower case and returns the new string</td> </tr> </table> <h1>See also:</h1> <ul> <li><a href="symbols.htm">Symbols</a> <li><a href="expr_int.htm">Integer and Boolean expressions</a> <li><a href="expr_fix.htm">Fixed-point expressions and functions</a> <li><a href="miscfunc.htm">Other functions</a> </ul> <hr> <p>Last updated 21 June 1997 by <a href="mailto:[email protected]">Carsten Sorensen</a></p> </body> </html>