============================================ Save this library as "token_lib.mv" in your Miva HTML directory. ============================================ Written By: Brian R. Bullock brian@wwwebweaver.com http://wwwebweaver.com Released to Public Domain Jan 26, 2000 ============================================ Table Of Contents for NoteTab v4.0+ (http://www.notetab.com/) Control "doubleclick" on function name: -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= [::count_token] [::overwrite_token] [::insert_token] [::delete_token] [::swap_token] [::shuffle_token] [::sort_token] ============================================ ______find_token______ Finds a given value in an existing token list. Returns the position number is the value is found. Returns null if the value is not found. Note, the search expression is always constructed thus: "value to find" "Miva operator" "list value". PARAMETERS lfindtoken - The value to find in the token list. (literal or varname). loperator - The Miva operator to use in the search. Valid operators are: 'IN', 'CIN', 'EQ', 'NE', 'LT', 'LE', 'GT' or 'GE' (literal or varname). llist - the token list (literal or varname). ldelim - The list delimiter (literal or varname). lstart - The position to start searching from (usually 1). To find subsequent positions for the same value, input 'lstart' using the previously found position number plus 1 then run the function again. SAMPLE CODE ______count_token______ Trival but fast. Returns the number of tokens in the token list. PARAMETERS llist - the token list (literal or varname) ldelim - The list delimiter (literal or varname) SAMPLE CODE ______overwrite_token______ Overwrites an existing token with a new value. If the token number doesn't exist then no changes are made. PARAMETERS llist - the token list (literal or varname). ldelim - The list delimiter (literal or varname). loverwriteno - The token number to overwrite (literal or varname). loverwritetoken - The new value to write (literal or varname). SAMPLE CODE ______insert_token______ Insert a new token into an existing token list. For example, if you insert a new token at position number three then the old token at position 3 will move to position 4 ,the old #4 will move to #5, etc. If the token number doesn't exist then the new token is added to the end of the list. PARAMETERS llist - the token list (literal or varname). ldelim - The list delimiter (literal or varname). linsertno - The insert postion number (literal or varname). linserttoken - The new value to insert (literal or varname). SAMPLE CODE ______delete_token______ Delete a token from an existing token list. For example, if you delete the token at position number 3 then the old token at position 4 will move to #3 ,the old #5 will move to #4, etc. If the token number doesn't exist then no changes are made. PARAMETERS llist - the token list (literal or varname). ldelim - The list delimiter (literal or varname). ldeleteno - The postion number to delete (literal or varname). SAMPLE CODE ______swap_token______ Swaps the stored value of two position numbers in an existing token list. If one or both of the position numbers do not exist then the function returns a null and the 'swap_token_error' variable contains an error message. PARAMETERS llist - the token list (literal or varname). ldelim - The list delimiter (literal or varname). lswapno1 - The 1st postion number to swap (literal or varname). lswapno2 - The 2nd postion number to swap (literal or varname). SAMPLE CODE ______shuffle_token______ Randomly shuffles the values in an existing token list. Returns the shuffled list. PARAMETERS llist - the token list (literal or varname) ldelim - The list delimiter (literal or varname) SAMPLE CODE ______sort_token______ Sorts the values in an existing token list in either ascending or decending order (For ascending string tokens, 'A' is first; for ascending number tokens, the lowest numbers are first. Descending is the reverse of ascending). This function has been tested on lists with 1000+ values (9 secs on a wintel 300mhz pentium MMX) but it is recursive and may have trouble with extremely large lists. If necessary you can set the function depth greater that the Miva default '23'. See the Miva engine administration docs for more info. PARAMETERS llist - the token list (literal or varname) ldelim - The list delimiter (literal or varname) ldirection - the direction to sort (string = ascending or decending) SAMPLE CODE ______do_sort______ This is a modified version of Luis Mosquera's (luism@simplenet.com) "asort" function.