% [cr_basic_header "colin roald : tech : utilities.tcl cheat sheet"] %>
This is a complete list of the procs defined in
utilities.tcl
as of 1999/09/16, including the ones not
specified with proc_doc
. The peculiar ordering is the way
they're arranged in utilities.tcl
. Where
proc_doc
documentation strings exist, they have been included.
- proc_doc {name args doc_string body}
- proc_source_file_full_path {proc_name}
- util_report_library_entry {{extra_message ""}}
Should be called at beginning of private Tcl library files so that it is easy to see in the error log whether or not private Tcl library files contain errors.
- ReturnHeaders {{content_type text/html}}
- ReturnHeadersNoCache {{content_type text/html}}
- ReturnHeadersWithCookie {cookie_content {content_type text/html}}
- ReturnHeadersWithCookieNoCache {cookie_content {content_type text/html}}
- set_form_variables {{error_if_not_found_p 1}}
- DoubleApos {string}
- set_form_variables_string_trim_DoubleAposQQ {}
- set_the_usual_form_variables {{error_if_not_found_p 1}}
- set_form_variables_string_trim_DoubleApos {}
- set_form_variables_string_trim {}
- NsSettoTclString {set_id}
- get_referrer {}
- post_args_to_query_string {}
- get_referrer_and_query_string {}
- util_GetCheckboxValues {form checkbox_name {default_return 0}}
For getting all the boxes from a set of checkboxes in a form. This procedure takes the complete ns_conn form and returns a list of checkbox values. It returns 0 if none are found (or some other default return value if specified).
- nmc_GetCheckboxValues {form checkbox_name {default_return 0}}
- nmc_GetNewIDNumber {id_name db}
- set_variables_after_query {}
- set_variables_after_subquery {}
- set_variables_after_query_not_selection {selection_variable {name_prefix ""}}
- database_to_tcl_string {db sql}
- database_to_tcl_string_or_null {db sql {null_value ""}}
- database_cols_to_tcl_string {db sql}
- database_to_tcl_list {db sql}
- database_to_tcl_list_list {db sql}
- database_1row_to_tcl_list {db sql}
- nmc_IllustraDatetoPrettyDate {sql_date}
- util_IllustraDatetoPrettyDate {sql_date}
- util_AnsiDatetoPrettyDate {sql_date}
Converts 1998-09-05 to September 5, 1998
- remove_nulls_from_ns_set {old_set_id}
- merge_form_with_ns_set {form set_id}
- merge_form_with_query {form db query}
- bt_mergepiece {htmlpiece values}
- GetColumnNames {db table}
returns a list with the column names of the table
- util_GetNewIDNumber {id_name db}
- util_prepare_update {db table_name primary_key_name primary_key_value form}
- util_prepare_update_multi_key {db table_name primary_key_name_list primary_key_value_list form}
- util_prepare_insert {db table_name primary_key_name primary_key_value form}
- util_prepare_insert_string_trim {db table_name primary_key_name primary_key_value form}
- util_prepare_insert_no_primary_key {db table_name form}
- util_PrettySex {m_or_f}
- util_PrettySexManWoman {m_or_f}
- util_PrettyBoolean {t_or_f}
- util_PrettyTclBoolean {zero_or_one}
Turns a 1 (or anything else that makes a Tcl IF happy) into Yes; anything else into No
- Memoize {tcl_statement}
Returns the result of evaluating the Tcl statement argument and then remembers that value in a cache; the memory persists until the server is restarted or until someone calls Memoize_Force with the same Tcl statement.
- Memoize_Force {tcl_statement}
- Memoize_for_Awhile {tcl_statement oldest_acceptable_value_in_seconds}
- current_year {db}
- current_year_internal {db}
- philg_server_default_pool {}
- philg_urldecode_form_variable {form variable_name}
- util_convert_plaintext_to_html {raw_string}
- util_maybe_convert_to_html {raw_string html_p}
very useful for info pulled from the news, neighbor, events subsystems.
- philg_quote_double_quotes {arg}
- util_striphtml {html}
Returns a best-guess plain text version of an HTML fragment. Better than ns_striphtml because it doesn't replace & g t ; and & l t ; with empty string.
- util_remove_html_tags {html}
- util_expand_entities {html}
- util_GetUserAgentHeader {}
- msie_p {}
- submit_button_if_msie_p {}
- randomInit {seed}
- random {}
- randomRange {range}
- capitalize {word}
- html_select_options {options {select_option ""}}
- db_html_select_options {db query {select_option ""}}
- html_select_value_options {options {select_option ""} {value_index 0} {option_index 1}}
- db_html_select_value_options {db query {select_option ""} {value_index 0} {option_index 1}}
- philg_hidden_input {name value}
- philg_email_valid_p {query_email}
Returns 1 if an email address has more or less the correct form
- philg_url_valid_p {query_url}
Returns 1 if a URL has more or less the correct form.
- philg_date_valid_p {query_date}
- export_form_vars args
- export_entire_form {}
- export_ns_set_vars {{format "url"} {exclusion_list ""} {setid ""}}
Returns all the params in an ns_set with the exception of those in exclusion_list. If no setid is provide, ns_getform is used. If format = url, a url parameter string will be returned. If format = form, a block of hidden form fragments will be returned.
- export_url_vars args
Returns a string of key=value pairs suitable for inclusion in a URL; you can pass it any number of variables as arguments. If any are defined in the caller's environment, they are included. See also export_entire_form_as_url_vars
- export_entire_form_as_url_vars {}
Use this after the ? when you when to pass everything from one page into another using a standard link.
- philg_development_p {}
- philg_keywords_match {keywords string_to_search}
- philg_keywords_score {keywords string_to_search}
Takes space-separated keywords and returns 0 if none are found or a count of how many matched. If a keyword occurs twice then it is weighted 2.
- philg_dateentrywidget {column {default_date "1940-11-03"}}
- philg_dateentrywidget_default_to_today {column}
- do_dml_transactions {db sql_list}
- with_transaction {db body on_error}
- with_catch {error_var body on_error}
- empty_string_p {query_string}
returns 1 if a string is empty; this is better than using == because it won't fail on long strings of numbers
- string_contains_p {small_string big_string}
Returns 1 if the BIG_STRING contains the SMALL_STRING, 0 otherwise; syntactic sugar for string first != -1
- wrap_string {input {threshold 80}}
wraps a string to be no wider than 80 columns by inserting line breaks
- remove_whitespace {input_string}
- util_just_the_digits {input_string}
- philg_format_phone_number {just_the_digits}
- util_commify_number { num }
Returns the number with commas inserted where appropriate. Number can be positive or negative and can have a decimal point. e.g. -1465.98 => -1,465.98
- util_limit_to_4000_chars {input_string}
- leap_year_p {year}
- ad_proc args
- shift {list_name}
- format_as_list {some_list}
- generate_argument_parser {proc_name argdesc}
- util_search_list_of_lists {list_of_lists query_string {sublist_element_pos 0}}
Returns position of sublist that contains QUERY_STRING at SUBLIST_ELEMENT_POS.
- util_get_http_status {url {use_get_p 1} {timeout 30}}
Returns the HTTP status code, e.g., 200 for a normal response or 500 for an error, of a URL. By default this uses the GET method instead of HEAD since not all servers will respond properly to a HEAD request even when the URL is perfectly valid. Note that this means AOLserver may be sucking down a lot of bits that it doesn't need.
- util_link_responding_p {url {list_of_bad_codes "404"}}
Returns 1 if the URL is responding (generally we think that anything other than 404 (not found) is okay).
- util_httpopen {method url {rqset ""} {timeout 30} {http_referer ""}}
Like ns_httpopen but works for POST as well; called by util_httppost
- util_httppost {url formvars {timeout 30} {depth 0} {http_referer ""}} "Returns the result of POSTing to another Web server or -1 if there is an error or timeout. formvars should be in the form \"arg1=value1&arg2=value2\""
- util_report_successful_library_load {{extra_message ""}}
Should be called at end of private Tcl library files so that it is easy to see in the error log whether or not private Tcl library files contain errors.
- exists_and_not_null { varname }
Returns 1 if the
variable name exists in the caller's environment and is not the empty string.