&sin, &isin, &rsin, &risin - String in string test functions
&sin str1 str2
&isin str1 str2
&rsin str1 str2
&risin str1 str2
These functions test for the existence of str1 in str2, returning the position of the string in str2 or 0 if not found.
The functions may all be abbreviated to their three letter abbreviation (i.e. &risin may be expressed as &ris). In all cases the first argument is completely evaluated before the second argument.
&sin str1 str2
&isin str1 str2
&rsin str1 str2
&risin str1 str2
The &sin and similar functions are useful for two different purposes. Consider the following example, this utilizes &sin in two different contexts. !while ¬ &sin @wc " \t\n" is a test for the end of the number, i.e. a white space character (<tab>, <SPACE> or <NL>).
The invocation set-variable #l1 &isin @wc "0123456789abcdef" is subtly different. In this case the return value is used to convert the character to it's integer hex value by using the value returned by &isin.
; ; calc-hexnum ; Convert the sting from the current position in the buffer ; to a hexadecimal number. define-macro calc-hexnum forward-delete-char forward-delete-char set-variable #l0 0 !while ¬ &sin @wc " \t\n" set-variable #l1 &isin @wc "0123456789abcdef" !if ¬ #l1 ml-write "Bad Hex number found" !abort !endif set-variable #l0 &mul #l0 16 set-variable #l0 &add #l0 &sub #l1 1 forward-delete-char !done insert-string #l0 !emacro
The &rsin function is very similar to sin except the value return is the position of the last occurrence of the string in the given string instead of the first. This is particularly useful when extracting the path or file name from a complete file name. For example, given a UNIX style file name such as "/usr/local/bin/me" the path can be obtained using set-variable %path &lef %pathfile &rsin "/" %pathfile and the file name by using set-variable %file &rig %pathfile &rsin "/" %pathfile
(c) Copyright JASSPA 1999
Last Modified: 1999/01/05
Generated On: 1999/12/01