User's Guide
Reference Manual
Release Notes
PDF
Top

STDLIB
Reference Manual
Version 2.7

Expand All
Contract All

Table of Contents

- STDLIB (App)
- array
  - Top of manual page
  - default/1
  - fix/1
  - foldl/3
  - foldr/3
  - from_list/1
  - from_list/2
  - from_orddict/1
  - from_orddict/2
  - get/2
  - is_array/1
  - is_fix/1
  - map/2
  - new/0
  - new/1
  - new/2
  - relax/1
  - reset/2
  - resize/1
  - resize/2
  - set/3
  - size/1
  - sparse_foldl/3
  - sparse_foldr/3
  - sparse_map/2
  - sparse_size/1
  - sparse_to_list/1
  - sparse_to_orddict/1
  - to_list/1
  - to_orddict/1
- assert.hrl
- base64
  - Top of manual page
  - encode/1
  - encode_to_string/1
  - decode/1
  - decode_to_string/1
  - mime_decode/1
  - mime_decode_to_string/1
- beam_lib
  - Top of manual page
  - all_chunks/1
  - chunks/2
  - chunks/3
  - build_module/1
  - version/1
  - md5/1
  - info/1
  - cmp/2
  - cmp_dirs/2
  - diff_dirs/2
  - strip/1
  - strip_files/1
  - strip_release/1
  - format_error/1
  - crypto_key_fun/1
  - clear_crypto_key_fun/0
- binary
  - Top of manual page
  - at/2
  - bin_to_list/1
  - bin_to_list/2
  - bin_to_list/3
  - compile_pattern/1
  - copy/1
  - copy/2
  - decode_unsigned/1
  - decode_unsigned/2
  - encode_unsigned/1
  - encode_unsigned/2
  - first/1
  - last/1
  - list_to_bin/1
  - longest_common_prefix/1
  - longest_common_suffix/1
  - match/2
  - match/3
  - matches/2
  - matches/3
  - part/2
  - part/3
  - referenced_byte_size/1
  - replace/3
  - replace/4
  - split/2
  - split/3
- c
  - Top of manual page
  - bt/1
  - c/1
  - c/2
  - cd/1
  - flush/0
  - help/0
  - i/0
  - ni/0
  - i/3
  - l/1
  - lc/1
  - ls/0
  - ls/1
  - m/0
  - m/1
  - memory/0
  - memory/1
  - nc/1
  - nc/2
  - nl/1
  - pid/3
  - pwd/0
  - q/0
  - regs/0
  - nregs/0
  - uptime/0
  - xm/1
  - y/1
  - y/2
- calendar
  - Top of manual page
  - date_to_gregorian_days/1
  - date_to_gregorian_days/3
  - datetime_to_gregorian_seconds/1
  - day_of_the_week/1
  - day_of_the_week/3
  - gregorian_days_to_date/1
  - gregorian_seconds_to_datetime/1
  - is_leap_year/1
  - iso_week_number/0
  - iso_week_number/1
  - last_day_of_the_month/2
  - local_time/0
  - local_time_to_universal_time/1
  - local_time_to_universal_time_dst/1
  - now_to_local_time/1
  - now_to_universal_time/1
  - now_to_datetime/1
  - seconds_to_daystime/1
  - seconds_to_time/1
  - time_difference/2
  - time_to_seconds/1
  - universal_time/0
  - universal_time_to_local_time/1
  - valid_date/1
  - valid_date/3
- dets
  - Top of manual page
  - all/0
  - bchunk/2
  - close/1
  - delete/2
  - delete_all_objects/1
  - delete_object/2
  - first/1
  - foldl/3
  - foldr/3
  - from_ets/2
  - info/1
  - info/2
  - init_table/2
  - init_table/3
  - insert/2
  - insert_new/2
  - is_compatible_bchunk_format/2
  - is_dets_file/1
  - lookup/2
  - match/1
  - match/2
  - match/3
  - match_delete/2
  - match_object/1
  - match_object/2
  - match_object/3
  - member/2
  - next/2
  - open_file/1
  - open_file/2
  - pid2name/1
  - repair_continuation/2
  - safe_fixtable/2
  - select/1
  - select/2
  - select/3
  - select_delete/2
  - slot/2
  - sync/1
  - table/1
  - table/2
  - to_ets/2
  - traverse/2
  - update_counter/3
- dict
  - Top of manual page
  - append/3
  - append_list/3
  - erase/2
  - fetch/2
  - fetch_keys/1
  - filter/2
  - find/2
  - fold/3
  - from_list/1
  - is_key/2
  - map/2
  - merge/3
  - new/0
  - size/1
  - is_empty/1
  - store/3
  - to_list/1
  - update/3
  - update/4
  - update_counter/3
- digraph
  - Top of manual page
  - add_edge/3
  - add_edge/4
  - add_edge/5
  - add_vertex/1
  - add_vertex/2
  - add_vertex/3
  - del_edge/2
  - del_edges/2
  - del_path/3
  - del_vertex/2
  - del_vertices/2
  - delete/1
  - edge/2
  - edges/1
  - edges/2
  - get_cycle/2
  - get_path/3
  - get_short_cycle/2
  - get_short_path/3
  - in_degree/2
  - in_edges/2
  - in_neighbours/2
  - info/1
  - new/0
  - new/1
  - no_edges/1
  - no_vertices/1
  - out_degree/2
  - out_edges/2
  - out_neighbours/2
  - vertex/2
  - vertices/1
- digraph_utils
  - Top of manual page
  - arborescence_root/1
  - components/1
  - condensation/1
  - cyclic_strong_components/1
  - is_acyclic/1
  - is_arborescence/1
  - is_tree/1
  - loop_vertices/1
  - postorder/1
  - preorder/1
  - reachable/2
  - reachable_neighbours/2
  - reaching/2
  - reaching_neighbours/2
  - strong_components/1
  - subgraph/2
  - subgraph/3
  - topsort/1
- epp
  - Top of manual page
  - open/1
  - open/2
  - open/3
  - close/1
  - parse_erl_form/1
  - parse_file/2
  - parse_file/3
  - default_encoding/0
  - encoding_to_string/1
  - read_encoding/1
  - read_encoding/2
  - read_encoding_from_binary/1
  - read_encoding_from_binary/2
  - set_encoding/1
  - set_encoding/2
  - format_error/1
- erl_anno
  - Top of manual page
  - column/1
  - end_location/1
  - file/1
  - from_term/1
  - generated/1
  - is_anno/1
  - line/1
  - location/1
  - new/1
  - set_file/2
  - set_generated/2
  - set_line/2
  - set_location/2
  - set_record/2
  - set_text/2
  - text/1
  - to_term/1
- erl_eval
  - Top of manual page
  - exprs/2
  - exprs/3
  - exprs/4
  - expr/2
  - expr/3
  - expr/4
  - expr/5
  - expr_list/2
  - expr_list/3
  - expr_list/4
  - new_bindings/0
  - bindings/1
  - binding/2
  - add_binding/3
  - del_binding/2
- erl_expand_records
  - Top of manual page
  - module/2
- erl_id_trans
  - Top of manual page
  - parse_transform/2
- erl_internal
  - Top of manual page
  - bif/2
  - guard_bif/2
  - type_test/2
  - arith_op/2
  - bool_op/2
  - comp_op/2
  - list_op/2
  - send_op/2
  - op_type/2
- erl_lint
  - Top of manual page
  - module/1
  - module/2
  - module/3
  - is_guard_test/1
  - format_error/1
- erl_parse
  - Top of manual page
  - parse_form/1
  - parse_exprs/1
  - parse_term/1
  - format_error/1
  - tokens/1
  - tokens/2
  - normalise/1
  - abstract/1
  - abstract/2
  - map_anno/2
  - fold_anno/3
  - mapfold_anno/3
  - new_anno/1
  - anno_from_term/1
  - anno_to_term/1
- erl_pp
  - Top of manual page
  - form/1
  - form/2
  - attribute/1
  - attribute/2
  - function/1
  - function/2
  - guard/1
  - guard/2
  - exprs/1
  - exprs/2
  - exprs/3
  - expr/1
  - expr/2
  - expr/3
  - expr/4
- erl_scan
  - Top of manual page
  - string/1
  - string/2
  - string/3
  - tokens/3
  - tokens/4
  - reserved_word/1
  - category/1
  - symbol/1
  - column/1
  - end_location/1
  - line/1
  - location/1
  - text/1
  - token_info/1
  - token_info/2
  - attributes_info/1
  - attributes_info/2
  - set_attribute/3
  - format_error/1
- erl_tar
  - Top of manual page
  - add/3
  - add/4
  - close/1
  - create/2
  - create/3
  - extract/1
  - extract/2
  - format_error/1
  - open/2
  - init/3
  - table/1
  - table/2
  - t/1
  - tt/1
- ets
  - Top of manual page
  - all/0
  - delete/1
  - delete/2
  - delete_all_objects/1
  - delete_object/2
  - file2tab/1
  - file2tab/2
  - first/1
  - foldl/3
  - foldr/3
  - from_dets/2
  - fun2ms/1
  - give_away/3
  - i/0
  - i/1
  - info/1
  - info/2
  - init_table/2
  - insert/2
  - insert_new/2
  - is_compiled_ms/1
  - last/1
  - lookup/2
  - lookup_element/3
  - match/2
  - match/3
  - match/1
  - match_delete/2
  - match_object/2
  - match_object/3
  - match_object/1
  - match_spec_compile/1
  - match_spec_run/2
  - member/2
  - new/2
  - next/2
  - prev/2
  - rename/2
  - repair_continuation/2
  - safe_fixtable/2
  - select/2
  - select/3
  - select/1
  - select_count/2
  - select_delete/2
  - select_reverse/2
  - select_reverse/3
  - select_reverse/1
  - setopts/2
  - slot/2
  - tab2file/2
  - tab2file/3
  - tab2list/1
  - tabfile_info/1
  - table/1
  - table/2
  - test_ms/2
  - take/2
  - to_dets/2
  - update_counter/3
  - update_counter/4
  - update_element/3
- file_sorter
  - Top of manual page
  - sort/1
  - sort/2
  - sort/3
  - keysort/2
  - keysort/3
  - keysort/4
  - merge/2
  - merge/3
  - keymerge/3
  - keymerge/4
  - check/1
  - check/2
  - keycheck/2
  - keycheck/3
- filelib
  - Top of manual page
  - ensure_dir/1
  - file_size/1
  - fold_files/5
  - is_dir/1
  - is_file/1
  - is_regular/1
  - last_modified/1
  - wildcard/1
  - wildcard/2
- filename
  - Top of manual page
  - absname/1
  - absname/2
  - absname_join/2
  - basename/1
  - basename/2
  - dirname/1
  - extension/1
  - flatten/1
  - join/1
  - join/2
  - nativename/1
  - pathtype/1
  - rootname/1
  - rootname/2
  - split/1
  - find_src/1
  - find_src/2
- gb_sets
  - Top of manual page
  - add/2
  - add_element/2
  - balance/1
  - delete/2
  - delete_any/2
  - del_element/2
  - difference/2
  - subtract/2
  - empty/0
  - new/0
  - filter/2
  - fold/3
  - from_list/1
  - from_ordset/1
  - insert/2
  - intersection/2
  - intersection/1
  - is_disjoint/2
  - is_empty/1
  - is_member/2
  - is_element/2
  - is_set/1
  - is_subset/2
  - iterator/1
  - iterator_from/2
  - largest/1
  - next/1
  - singleton/1
  - size/1
  - smallest/1
  - take_largest/1
  - take_smallest/1
  - to_list/1
  - union/2
  - union/1
- gb_trees
  - Top of manual page
  - balance/1
  - delete/2
  - delete_any/2
  - empty/0
  - enter/3
  - from_orddict/1
  - get/2
  - insert/3
  - is_defined/2
  - is_empty/1
  - iterator/1
  - iterator_from/2
  - keys/1
  - largest/1
  - lookup/2
  - map/2
  - next/1
  - size/1
  - smallest/1
  - take_largest/1
  - take_smallest/1
  - to_list/1
  - update/3
  - values/1
- gen_event
  - Top of manual page
  - start_link/0
  - start_link/1
  - start/0
  - start/1
  - add_handler/3
  - add_sup_handler/3
  - notify/2
  - sync_notify/2
  - call/3
  - call/4
  - delete_handler/3
  - swap_handler/3
  - swap_sup_handler/3
  - which_handlers/1
  - stop/1
  - stop/3
  - Module:init/1
  - Module:handle_event/2
  - Module:handle_call/2
  - Module:handle_info/2
  - Module:terminate/2
  - Module:code_change/3
  - Module:format_status/2
- gen_fsm
  - Top of manual page
  - start_link/3
  - start_link/4
  - start/3
  - start/4
  - stop/1
  - stop/3
  - send_event/2
  - send_all_state_event/2
  - sync_send_event/2
  - sync_send_event/3
  - sync_send_all_state_event/2
  - sync_send_all_state_event/3
  - reply/2
  - send_event_after/2
  - start_timer/2
  - cancel_timer/1
  - enter_loop/4
  - enter_loop/5
  - enter_loop/5
  - enter_loop/6
  - Module:init/1
  - Module:StateName/2
  - Module:handle_event/3
  - Module:StateName/3
  - Module:handle_sync_event/4
  - Module:handle_info/3
  - Module:terminate/3
  - Module:code_change/4
  - Module:format_status/2
- gen_server
  - Top of manual page
  - start_link/3
  - start_link/4
  - start/3
  - start/4
  - stop/1
  - stop/3
  - call/2
  - call/3
  - multi_call/2
  - multi_call/3
  - multi_call/4
  - cast/2
  - abcast/2
  - abcast/3
  - reply/2
  - enter_loop/3
  - enter_loop/4
  - enter_loop/4
  - enter_loop/5
  - Module:init/1
  - Module:handle_call/3
  - Module:handle_cast/2
  - Module:handle_info/2
  - Module:terminate/2
  - Module:code_change/3
  - Module:format_status/2
- io
  - Top of manual page
  - columns/0
  - columns/1
  - put_chars/1
  - put_chars/2
  - nl/0
  - nl/1
  - get_chars/2
  - get_chars/3
  - get_line/1
  - get_line/2
  - getopts/0
  - getopts/1
  - printable_range/0
  - setopts/1
  - setopts/2
  - write/1
  - write/2
  - read/1
  - read/2
  - read/3
  - read/4
  - fwrite/1
  - fwrite/2
  - fwrite/3
  - format/1
  - format/2
  - format/3
  - fread/2
  - fread/3
  - rows/0
  - rows/1
  - scan_erl_exprs/1
  - scan_erl_exprs/2
  - scan_erl_exprs/3
  - scan_erl_exprs/4
  - scan_erl_form/1
  - scan_erl_form/2
  - scan_erl_form/3
  - scan_erl_form/4
  - parse_erl_exprs/1
  - parse_erl_exprs/2
  - parse_erl_exprs/3
  - parse_erl_exprs/4
  - parse_erl_form/1
  - parse_erl_form/2
  - parse_erl_form/3
  - parse_erl_form/4
- io_lib
  - Top of manual page
  - nl/0
  - write/1
  - write/2
  - print/1
  - print/4
  - fwrite/2
  - format/2
  - fread/2
  - fread/3
  - write_atom/1
  - write_string/1
  - write_string_as_latin1/1
  - write_latin1_string/1
  - write_char/1
  - write_char_as_latin1/1
  - write_latin1_char/1
  - scan_format/2
  - unscan_format/1
  - build_text/1
  - indentation/2
  - char_list/1
  - latin1_char_list/1
  - deep_char_list/1
  - deep_latin1_char_list/1
  - printable_list/1
  - printable_latin1_list/1
  - printable_unicode_list/1
- lib
  - Top of manual page
  - flush_receive/0
  - error_message/2
  - progname/0
  - nonl/1
  - send/2
  - sendw/2
- lists
  - Top of manual page
  - all/2
  - any/2
  - append/1
  - append/2
  - concat/1
  - delete/2
  - droplast/1
  - dropwhile/2
  - duplicate/2
  - filter/2
  - filtermap/2
  - flatlength/1
  - flatmap/2
  - flatten/1
  - flatten/2
  - foldl/3
  - foldr/3
  - foreach/2
  - keydelete/3
  - keyfind/3
  - keymap/3
  - keymember/3
  - keymerge/3
  - keyreplace/4
  - keysearch/3
  - keysort/2
  - keystore/4
  - keytake/3
  - last/1
  - map/2
  - mapfoldl/3
  - mapfoldr/3
  - max/1
  - member/2
  - merge/1
  - merge/2
  - merge/3
  - merge3/3
  - min/1
  - nth/2
  - nthtail/2
  - partition/2
  - prefix/2
  - reverse/1
  - reverse/2
  - seq/2
  - seq/3
  - sort/1
  - sort/2
  - split/2
  - splitwith/2
  - sublist/2
  - sublist/3
  - subtract/2
  - suffix/2
  - sum/1
  - takewhile/2
  - ukeymerge/3
  - ukeysort/2
  - umerge/1
  - umerge/2
  - umerge/3
  - umerge3/3
  - unzip/1
  - unzip3/1
  - usort/1
  - usort/2
  - zip/2
  - zip3/3
  - zipwith/3
  - zipwith3/4
- log_mf_h
  - Top of manual page
  - init/3
  - init/4
- maps
  - Top of manual page
  - filter/2
  - find/2
  - fold/3
  - from_list/1
  - get/2
  - get/3
  - is_key/2
  - keys/1
  - map/2
  - merge/2
  - new/0
  - put/3
  - remove/2
  - size/1
  - to_list/1
  - update/3
  - values/1
  - with/2
  - without/2
- math
  - Top of manual page
  - pi/0
  - sin/1
  - cos/1
  - tan/1
  - asin/1
  - acos/1
  - atan/1
  - atan2/2
  - sinh/1
  - cosh/1
  - tanh/1
  - asinh/1
  - acosh/1
  - atanh/1
  - exp/1
  - log/1
  - log2/1
  - log10/1
  - pow/2
  - sqrt/1
  - erf/1
  - erfc/1
- ms_transform
  - Top of manual page
  - parse_transform/2
  - transform_from_shell/3
  - format_error/1
- orddict
  - Top of manual page
  - append/3
  - append_list/3
  - erase/2
  - fetch/2
  - fetch_keys/1
  - filter/2
  - find/2
  - fold/3
  - from_list/1
  - is_key/2
  - map/2
  - merge/3
  - new/0
  - size/1
  - is_empty/1
  - store/3
  - to_list/1
  - update/3
  - update/4
  - update_counter/3
- ordsets
  - Top of manual page
  - new/0
  - is_set/1
  - size/1
  - to_list/1
  - from_list/1
  - is_element/2
  - add_element/2
  - del_element/2
  - union/2
  - union/1
  - intersection/2
  - intersection/1
  - is_disjoint/2
  - subtract/2
  - is_subset/2
  - fold/3
  - filter/2
- pool
  - Top of manual page
  - start/1
  - start/2
  - attach/1
  - stop/0
  - get_nodes/0
  - pspawn/3
  - pspawn_link/3
  - get_node/0
- proc_lib
  - Top of manual page
  - spawn/1
  - spawn/2
  - spawn/3
  - spawn/4
  - spawn_link/1
  - spawn_link/2
  - spawn_link/3
  - spawn_link/4
  - spawn_opt/2
  - spawn_opt/3
  - spawn_opt/4
  - spawn_opt/5
  - start/3
  - start/4
  - start/5
  - start_link/3
  - start_link/4
  - start_link/5
  - init_ack/1
  - init_ack/2
  - format/1
  - format/2
  - format/3
  - initial_call/1
  - translate_initial_call/1
  - hibernate/3
  - stop/1
  - stop/3
- proplists
  - Top of manual page
  - append_values/2
  - compact/1
  - delete/2
  - expand/2
  - get_all_values/2
  - get_bool/2
  - get_keys/1
  - get_value/2
  - get_value/3
  - is_defined/2
  - lookup/2
  - lookup_all/2
  - normalize/2
  - property/1
  - property/2
  - split/2
  - substitute_aliases/2
  - substitute_negations/2
  - unfold/1
- qlc
  - Top of manual page
  - append/1
  - append/2
  - cursor/1
  - cursor/2
  - delete_cursor/1
  - eval/1
  - eval/2
  - e/1
  - e/2
  - fold/3
  - fold/4
  - format_error/1
  - info/1
  - info/2
  - keysort/2
  - keysort/3
  - next_answers/1
  - next_answers/2
  - q/1
  - q/2
  - sort/1
  - sort/2
  - string_to_handle/1
  - string_to_handle/2
  - string_to_handle/3
  - table/2
- queue
  - Top of manual page
  - new/0
  - is_queue/1
  - is_empty/1
  - len/1
  - in/2
  - in_r/2
  - out/1
  - out_r/1
  - from_list/1
  - to_list/1
  - reverse/1
  - split/2
  - join/2
  - filter/2
  - member/2
  - get/1
  - get_r/1
  - drop/1
  - drop_r/1
  - peek/1
  - peek_r/1
  - cons/2
  - head/1
  - tail/1
  - snoc/2
  - daeh/1
  - last/1
  - liat/1
  - init/1
  - lait/1
- rand
  - Top of manual page
  - seed/1
  - seed_s/1
  - seed/2
  - seed_s/2
  - export_seed/0
  - export_seed_s/1
  - uniform/0
  - uniform_s/1
  - uniform/1
  - uniform_s/2
  - normal/0
  - normal_s/1
- random
  - Top of manual page
  - seed/0
  - seed/3
  - seed/1
  - seed0/0
  - uniform/0
  - uniform/1
  - uniform_s/1
  - uniform_s/2
- re
  - Top of manual page
  - compile/1
  - compile/2
  - inspect/2
  - run/2
  - run/3
  - replace/3
  - replace/4
  - split/2
  - split/3
- sets
  - Top of manual page
  - new/0
  - is_set/1
  - size/1
  - to_list/1
  - from_list/1
  - is_element/2
  - add_element/2
  - del_element/2
  - union/2
  - union/1
  - intersection/2
  - intersection/1
  - is_disjoint/2
  - subtract/2
  - is_subset/2
  - fold/3
  - filter/2
- shell
  - Top of manual page
  - history/1
  - results/1
  - catch_exception/1
  - prompt_func/1
  - start_restricted/1
  - stop_restricted/0
  - strings/1
- shell_default
- slave
  - Top of manual page
  - start/1
  - start/2
  - start/3
  - start_link/1
  - start_link/2
  - start_link/3
  - stop/1
  - pseudo/1
  - pseudo/2
  - relay/1
- sofs
  - Top of manual page
  - a_function/1
  - a_function/2
  - canonical_relation/1
  - composite/2
  - constant_function/2
  - converse/1
  - difference/2
  - digraph_to_family/1
  - digraph_to_family/2
  - domain/1
  - drestriction/2
  - drestriction/3
  - empty_set/0
  - extension/3
  - family/1
  - family/2
  - family_difference/2
  - family_domain/1
  - family_field/1
  - family_intersection/1
  - family_intersection/2
  - family_projection/2
  - family_range/1
  - family_specification/2
  - family_to_digraph/1
  - family_to_digraph/2
  - family_to_relation/1
  - family_union/1
  - family_union/2
  - field/1
  - from_external/2
  - from_sets/1
  - from_term/1
  - from_term/2
  - image/2
  - intersection/1
  - intersection/2
  - intersection_of_family/1
  - inverse/1
  - inverse_image/2
  - is_a_function/1
  - is_disjoint/2
  - is_empty_set/1
  - is_equal/2
  - is_set/1
  - is_sofs_set/1
  - is_subset/2
  - is_type/1
  - join/4
  - multiple_relative_product/2
  - no_elements/1
  - partition/1
  - partition/2
  - partition/3
  - partition_family/2
  - product/1
  - product/2
  - projection/2
  - range/1
  - relation/1
  - relation/2
  - relation_to_family/1
  - relative_product/1
  - relative_product/2
  - relative_product1/2
  - restriction/2
  - restriction/3
  - set/1
  - set/2
  - specification/2
  - strict_relation/1
  - substitution/2
  - symdiff/2
  - symmetric_partition/2
  - to_external/1
  - to_sets/1
  - type/1
  - union/1
  - union/2
  - union_of_family/1
  - weak_relation/1
- string
  - Top of manual page
  - len/1
  - equal/2
  - concat/2
  - chr/2
  - rchr/2
  - str/2
  - rstr/2
  - span/2
  - cspan/2
  - substr/2
  - substr/3
  - tokens/2
  - join/2
  - chars/2
  - chars/3
  - copies/2
  - words/1
  - words/2
  - sub_word/2
  - sub_word/3
  - strip/1
  - strip/2
  - strip/3
  - left/2
  - left/3
  - right/2
  - right/3
  - centre/2
  - centre/3
  - sub_string/2
  - sub_string/3
  - to_float/1
  - to_integer/1
  - to_lower/1
  - to_upper/1
- supervisor
  - Top of manual page
  - start_link/2
  - start_link/3
  - start_child/2
  - terminate_child/2
  - delete_child/2
  - restart_child/2
  - which_children/1
  - count_children/1
  - check_childspecs/1
  - get_childspec/2
  - Module:init/1
- supervisor_bridge
  - Top of manual page
  - start_link/2
  - start_link/3
  - Module:init/1
  - Module:terminate/2
- sys
  - Top of manual page
  - log/2
  - log/3
  - log_to_file/2
  - log_to_file/3
  - statistics/2
  - statistics/3
  - trace/2
  - trace/3
  - no_debug/1
  - no_debug/2
  - suspend/1
  - suspend/2
  - resume/1
  - resume/2
  - change_code/4
  - change_code/5
  - get_status/1
  - get_status/2
  - get_state/1
  - get_state/2
  - replace_state/2
  - replace_state/3
  - install/2
  - install/3
  - remove/2
  - remove/3
  - terminate/2
  - terminate/3
  - debug_options/1
  - get_debug/3
  - handle_debug/4
  - handle_system_msg/6
  - print_log/1
  - Mod:system_continue/3
  - Mod:system_terminate/4
  - Mod:system_code_change/4
  - Mod:system_get_state/1
  - Mod:system_replace_state/2
- timer
  - Top of manual page
  - start/0
  - apply_after/4
  - send_after/2
  - send_after/3
  - kill_after/1
  - kill_after/2
  - exit_after/2
  - exit_after/3
  - apply_interval/4
  - send_interval/2
  - send_interval/3
  - cancel/1
  - sleep/1
  - tc/1
  - tc/2
  - tc/3
  - now_diff/2
  - seconds/1
  - minutes/1
  - hours/1
  - hms/3
- unicode
  - Top of manual page
  - bom_to_encoding/1
  - characters_to_list/1
  - characters_to_list/2
  - characters_to_binary/1
  - characters_to_binary/2
  - characters_to_binary/3
  - encoding_to_bom/1
- win32reg
  - Top of manual page
  - change_key/2
  - change_key_create/2
  - close/1
  - current_key/1
  - delete_key/1
  - delete_value/2
  - expand/1
  - format_error/1
  - open/1
  - set_value/3
  - sub_keys/1
  - value/2
  - values/1
- zip
  - Top of manual page
  - zip/2
  - zip/3
  - create/2
  - create/3
  - unzip/1
  - unzip/2
  - extract/1
  - extract/2
  - foldl/3
  - list_dir/1
  - list_dir/2
  - table/1
  - table/2
  - t/1
  - tt/1
  - zip_open/1
  - zip_open/2
  - zip_list_dir/1
  - zip_get/1
  - zip_get/2
  - zip_close/1

# io

### MODULE

io

### MODULE SUMMARY

Standard I/O Server Interface Functions

### DESCRIPTION

This module provides an interface to standard Erlang I/O servers. The output functions all return ok if they are successful, or exit if they are not.

In the following description, all functions have an optional parameter IoDevice. If included, it must be the pid of a process which handles the IO protocols. Normally, it is the IoDevice returned by file:open/2.

For a description of the IO protocols refer to the STDLIB User's Guide.

Warning

As of R13A, data supplied to the put_chars function should be in the unicode:chardata() format. This means that programs supplying binaries to this function need to convert them to UTF-8 before trying to output the data on an IO device.

If an IO device is set in binary mode, the functions get_chars and get_line may return binaries instead of lists. The binaries will, as of R13A, be encoded in UTF-8.

To work with binaries in ISO-latin-1 encoding, use the file module instead.

For conversion functions between character encodings, see the unicode module.

### DATA TYPES

device() = atom() | pid()

An IO device. Either standard_io, standard_error, a registered name, or a pid handling IO protocols (returned from file:open/2).

opt_pair() =
{binary, boolean()} |
{echo, boolean()} |
{expand_fun, expand_fun()} |
{encoding, encoding()}

expand_fun() =
fun((term()) -> {yes | no, string(), [string(), ...]})

encoding() =
latin1 |
unicode |
utf8 |
utf16 |
utf32 |
{utf16, big | little} |
{utf32, big | little}

setopt() = binary | list | opt_pair()

format() = atom() | string() | binary()

location() = erl_anno:location()

prompt() = atom() | unicode:chardata()

server_no_data() = {error, ErrorDescription :: term()} | eof

What the I/O-server sends when there is no data.

### EXPORTS

columns() -> {ok, integer() >= 1} | {error, enotsup}
columns(IoDevice) -> {ok, integer() >= 1} | {error, enotsup}

Types:

IoDevice = device()

Retrieves the number of columns of the IoDevice (i.e. the width of a terminal). The function only succeeds for terminal devices, for all other IO devices the function returns {error, enotsup}

put_chars(CharData) -> ok
put_chars(IoDevice, CharData) -> ok

Types:

IoDevice = device()
CharData = unicode:chardata()

Writes the characters of CharData to the I/O server (IoDevice).

nl() -> ok
nl(IoDevice) -> ok

Types:

IoDevice = device()

Writes new line to the standard output (IoDevice).

get_chars(Prompt, Count) -> Data | server_no_data()
get_chars(IoDevice, Prompt, Count) -> Data | server_no_data()

Types:

IoDevice = device()
Prompt = prompt()
Count = integer() >= 0
Data = string() | unicode:unicode_binary()
server_no_data() = {error, ErrorDescription :: term()} | eof

Reads Count characters from standard input (IoDevice), prompting it with Prompt. It returns:

Data

  The input characters. If the IO device supports Unicode, the data may represent codepoints larger than 255 (the latin1 range). If the I/O server is set to deliver binaries, they will be encoded in UTF-8 (regardless of if the IO device actually supports Unicode or not).

eof

  End of file was encountered.

{error, ErrorDescription}

  Other (rare) error condition, for instance {error, estale} if reading from an NFS file system.

get_line(Prompt) -> Data | server_no_data()
get_line(IoDevice, Prompt) -> Data | server_no_data()

Types:

IoDevice = device()
Prompt = prompt()
Data = string() | unicode:unicode_binary()
server_no_data() = {error, ErrorDescription :: term()} | eof

Reads a line from the standard input (IoDevice), prompting it with Prompt. It returns:

Data

  The characters in the line terminated by a LF (or end of file). If the IO device supports Unicode, the data may represent codepoints larger than 255 (the latin1 range). If the I/O server is set to deliver binaries, they will be encoded in UTF-8 (regardless of if the IO device actually supports Unicode or not).

eof

  End of file was encountered.

{error, ErrorDescription}

  Other (rare) error condition, for instance {error, estale} if reading from an NFS file system.

getopts() -> [opt_pair()] | {error, Reason}
getopts(IoDevice) -> [opt_pair()] | {error, Reason}

Types:

IoDevice = device()
Reason = term()

This function requests all available options and their current values for a specific IO device. Example:

    1> {ok,F} = file:open("/dev/null",[read]).
    {ok,<0.42.0>}
    2> io:getopts(F).
    [{binary,false},{encoding,latin1}]

Here the file I/O-server returns all available options for a file, which are the expected ones, encoding and binary. The standard shell however has some more options:

    3> io:getopts().
    [{expand_fun,#Fun<group.0.120017273>},
     {echo,true},
     {binary,false},
     {encoding,unicode}]

This example is, as can be seen, run in an environment where the terminal supports Unicode input and output.

printable_range() -> unicode | latin1

Return the user requested range of printable Unicode characters.

The user can request a range of characters that are to be considered printable in heuristic detection of strings by the shell and by the formatting functions. This is done by supplying +pc <range> when starting Erlang.

Currently the only valid values for <range> are latin1 and unicode. latin1 means that only code points below 256 (with the exception of control characters etc) will be considered printable. unicode means that all printable characters in all unicode character ranges are considered printable by the io functions.

By default, Erlang is started so that only the latin1 range of characters will indicate that a list of integers is a string.

The simplest way to utilize the setting is to call io_lib:printable_list/1, which will use the return value of this function to decide if a list is a string of printable characters or not.

Note

In the future, this function may return more values and ranges. It is recommended to use the io_lib:printable_list/1 function to avoid compatibility problems.

setopts(Opts) -> ok | {error, Reason}
setopts(IoDevice, Opts) -> ok | {error, Reason}

Types:

IoDevice = device()
Opts = [setopt()]
Reason = term()

Set options for the standard IO device (IoDevice).

Possible options and values vary depending on the actual IO device. For a list of supported options and their current values on a specific IO device, use the getopts/1 function.

The options and values supported by the current OTP IO devices are:

binary, list or {binary, boolean()}

  If set in binary mode (binary or {binary, true}), the I/O server sends binary data (encoded in UTF-8) as answers to the get_line, get_chars and, if possible, get_until requests (see the I/O protocol description in STDLIB User's Guide for details). The immediate effect is that get_chars/2,3 and get_line/1,2 return UTF-8 binaries instead of lists of chars for the affected IO device.

  By default, all IO devices in OTP are set in list mode, but the I/O functions can handle any of these modes and so should other, user written, modules behaving as clients to I/O-servers.

  This option is supported by the standard shell (group.erl), the 'oldshell' (user.erl) and the file I/O servers.

{echo, boolean()}

  Denotes if the terminal should echo input. Only supported for the standard shell I/O-server (group.erl)

{expand_fun, expand_fun()}

  Provide a function for tab-completion (expansion) like the Erlang shell. This function is called when the user presses the TAB key. The expansion is active when calling line-reading functions such as get_line/1,2.

  The function is called with the current line, upto the cursor, as a reversed string. It should return a three-tuple: {yes|no, string(), [string(), ...]}. The first element gives a beep if no, otherwise the expansion is silent, the second is a string that will be entered at the cursor position, and the third is a list of possible expansions. If this list is non-empty, the list will be printed and the current input line will be written once again.

  Trivial example (beep on anything except empty line, which is expanded to "quit"):

       fun("") -> {yes, "quit", []};
          (_) -> {no, "", ["quit"]} end

  This option is supported by the standard shell only (group.erl).

{encoding, latin1 | unicode}

  Specifies how characters are input or output from or to the actual IO device, implying that i.e. a terminal is set to handle Unicode input and output or a file is set to handle UTF-8 data encoding.

  The option does not affect how data is returned from the I/O functions or how it is sent in the I/O-protocol, it only affects how the IO device is to handle Unicode characters towards the "physical" device.

  The standard shell will be set for either Unicode or latin1 encoding when the system is started. The actual encoding is set with the help of the LANG or LC_CTYPE environment variables on Unix-like system or by other means on other systems. The bottom line is that the user can input Unicode characters and the IO device will be in {encoding, unicode} mode if the IO device supports it. The mode can be changed, if the assumption of the runtime system is wrong, by setting this option.

  The IO device used when Erlang is started with the "-oldshell" or "-noshell" flags is by default set to latin1 encoding, meaning that any characters beyond codepoint 255 will be escaped and that input is expected to be plain 8-bit ISO-latin-1. If the encoding is changed to Unicode, input and output from the standard file descriptors will be in UTF-8 (regardless of operating system).

  Files can also be set in {encoding, unicode}, meaning that data is written and read as UTF-8. More encodings are possible for files, see below.

  {encoding, unicode | latin1} is supported by both the standard shell (group.erl including werl on Windows®), the 'oldshell' (user.erl) and the file I/O servers.

{encoding, utf8 | utf16 | utf32 | {utf16,big} | {utf16,little} | {utf32,big} | {utf32,little}}

  For disk files, the encoding can be set to various UTF variants. This will have the effect that data is expected to be read as the specified encoding from the file and the data will be written in the specified encoding to the disk file.

  {encoding, utf8} will have the same effect as {encoding, unicode} on files.

  The extended encodings are only supported on disk files (opened by the file:open/2 function)

write(Term) -> ok
write(IoDevice, Term) -> ok

Types:

IoDevice = device()
Term = term()

Writes the term Term to the standard output (IoDevice).

read(Prompt) -> Result
read(IoDevice, Prompt) -> Result

Types:

IoDevice = device()
Prompt = prompt()
Result =
{ok, Term :: term()} | server_no_data() | {error, ErrorInfo}
ErrorInfo = erl_scan:error_info() | erl_parse:error_info()
server_no_data() = {error, ErrorDescription :: term()} | eof

Reads a term Term from the standard input (IoDevice), prompting it with Prompt. It returns:

{ok, Term}

  The parsing was successful.

eof

  End of file was encountered.

{error, ErrorInfo}

  The parsing failed.

{error, ErrorDescription}

  Other (rare) error condition, for instance {error, estale} if reading from an NFS file system.

read(IoDevice, Prompt, StartLocation) -> Result
read(IoDevice, Prompt, StartLocation, Options) -> Result

Types:

IoDevice = device()
Prompt = prompt()
StartLocation = location()
Options = erl_scan:options()
Result =
{ok, Term :: term(), EndLocation :: location()} |
{eof, EndLocation :: location()} |
server_no_data() |
{error, ErrorInfo, ErrorLocation :: location()}
ErrorInfo = erl_scan:error_info() | erl_parse:error_info()
server_no_data() = {error, ErrorDescription :: term()} | eof

Reads a term Term from IoDevice, prompting it with Prompt. Reading starts at location StartLocation. The argument Options is passed on as the Options argument of the erl_scan:tokens/4 function. It returns:

{ok, Term, EndLocation}

  The parsing was successful.

{eof, EndLocation}

  End of file was encountered.

{error, ErrorInfo, ErrorLocation}

  The parsing failed.

{error, ErrorDescription}

  Other (rare) error condition, for instance {error, estale} if reading from an NFS file system.

fwrite(Format) -> ok
fwrite(Format, Data) -> ok
fwrite(IoDevice, Format, Data) -> ok
format(Format) -> ok
format(Format, Data) -> ok
format(IoDevice, Format, Data) -> ok

Types:

IoDevice = device()
Format = format()
Data = [term()]

Writes the items in Data ([]) on the standard output (IoDevice) in accordance with Format. Format contains plain characters which are copied to the output device, and control sequences for formatting, see below. If Format is an atom or a binary, it is first converted to a list with the aid of atom_to_list/1 or binary_to_list/1.

    1> io:fwrite("Hello world!~n", []).
    Hello world!
    ok

The general format of a control sequence is ~F.P.PadModC. The character C determines the type of control sequence to be used, F and P are optional numeric arguments. If F, P, or Pad is *, the next argument in Data is used as the numeric value of F or P.

F is the field width of the printed argument. A negative value means that the argument will be left justified within the field, otherwise it will be right justified. If no field width is specified, the required print width will be used. If the field width specified is too small, then the whole field will be filled with * characters.

P is the precision of the printed argument. A default value is used if no precision is specified. The interpretation of precision depends on the control sequences. Unless otherwise specified, the argument within is used to determine print width.

Pad is the padding character. This is the character used to pad the printed representation of the argument so that it conforms to the specified field width and precision. Only one padding character can be specified and, whenever applicable, it is used for both the field width and precision. The default padding character is ' ' (space).

Mod is the control sequence modifier. It is either a single character (currently only t, for Unicode translation, and l, for stopping p and P from detecting printable characters, are supported) that changes the interpretation of Data.

The following control sequences are available:

~

  The character ~ is written.

c

  The argument is a number that will be interpreted as an ASCII code. The precision is the number of times the character is printed and it defaults to the field width, which in turn defaults to 1. The following example illustrates:

      1> io:fwrite("|~10.5c|~-10.5c|~5c|~n", [$a, $b, $c]).
      |     aaaaa|bbbbb     |ccccc|
      ok

  If the Unicode translation modifier (t) is in effect, the integer argument can be any number representing a valid Unicode codepoint, otherwise it should be an integer less than or equal to 255, otherwise it is masked with 16#FF:

      2> io:fwrite("~tc~n",[1024]).
      \x{400}
      ok
      3> io:fwrite("~c~n",[1024]).
      ^@
      ok

f

  The argument is a float which is written as [-]ddd.ddd, where the precision is the number of digits after the decimal point. The default precision is 6 and it cannot be less than 1.

e

  The argument is a float which is written as [-]d.ddde+-ddd, where the precision is the number of digits written. The default precision is 6 and it cannot be less than 2.

g

  The argument is a float which is written as f, if it is >= 0.1 and < 10000.0. Otherwise, it is written in the e format. The precision is the number of significant digits. It defaults to 6 and should not be less than 2. If the absolute value of the float does not allow it to be written in the f format with the desired number of significant digits, it is also written in the e format.

s

  Prints the argument with the string syntax. The argument is, if no Unicode translation modifier is present, an iolist(), a binary(), or an atom(). If the Unicode translation modifier (t) is in effect, the argument is unicode:chardata(), meaning that binaries are in UTF-8. The characters are printed without quotes. The string is first truncated by the given precision and then padded and justified to the given field width. The default precision is the field width.

  This format can be used for printing any object and truncating the output so it fits a specified field:

      1> io:fwrite("|~10w|~n", [{hey, hey, hey}]).
      |**********|
      ok
      2> io:fwrite("|~10s|~n", [io_lib:write({hey, hey, hey})]).
      |{hey,hey,h|
      3> io:fwrite("|~-10.8s|~n", [io_lib:write({hey, hey, hey})]).
      |{hey,hey  |
      ok

  A list with integers larger than 255 is considered an error if the Unicode translation modifier is not given:

      4> io:fwrite("~ts~n",[[1024]]).
      \x{400}
      ok
      5> io:fwrite("~s~n",[[1024]]).
      ** exception exit: {badarg,[{io,format,[<0.26.0>,"~s~n",[[1024]]]},
         ...

w

  Writes data with the standard syntax. This is used to output Erlang terms. Atoms are printed within quotes if they contain embedded non-printable characters, and floats are printed accurately as the shortest, correctly rounded string.

p

  Writes the data with standard syntax in the same way as ~w, but breaks terms whose printed representation is longer than one line into many lines and indents each line sensibly. Left justification is not supported. It also tries to detect lists of printable characters and to output these as strings. The Unicode translation modifier is used for determining what characters are printable. For example:

      1> T = [{attributes,[[{id,age,1.50000},{mode,explicit},
      {typename,"INTEGER"}], [{id,cho},{mode,explicit},{typename,'Cho'}]]},
      {typename,'Person'},{tag,{'PRIVATE',3}},{mode,implicit}].
      ...
      2> io:fwrite("~w~n", [T]).
      [{attributes,[[{id,age,1.5},{mode,explicit},{typename,
      [73,78,84,69,71,69,82]}],[{id,cho},{mode,explicit},{typena
      me,'Cho'}]]},{typename,'Person'},{tag,{'PRIVATE',3}},{mode
      ,implicit}]
      ok
      3> io:fwrite("~62p~n", [T]).
      [{attributes,[[{id,age,1.5},
                     {mode,explicit},
                     {typename,"INTEGER"}],
                    [{id,cho},{mode,explicit},{typename,'Cho'}]]},
       {typename,'Person'},
       {tag,{'PRIVATE',3}},
       {mode,implicit}]
      ok

  The field width specifies the maximum line length. It defaults to 80. The precision specifies the initial indentation of the term. It defaults to the number of characters printed on this line in the same call to io:fwrite or io:format. For example, using T above:

      4> io:fwrite("Here T = ~62p~n", [T]).
      Here T = [{attributes,[[{id,age,1.5},
                              {mode,explicit},
                              {typename,"INTEGER"}],
                             [{id,cho},
                              {mode,explicit},
                              {typename,'Cho'}]]},
                {typename,'Person'},
                {tag,{'PRIVATE',3}},
                {mode,implicit}]
      ok

  When the modifier l is given no detection of printable character lists will take place. For example:

      5> S = [{a,"a"}, {b, "b"}].
      6> io:fwrite("~15p~n", [S]).
      [{a,"a"},
       {b,"b"}]
      ok
      7> io:fwrite("~15lp~n", [S]).
      [{a,[97]},
       {b,[98]}]
      ok

  Binaries that look like UTF-8 encoded strings will be output with the string syntax if the Unicode translation modifier is given:

      9> io:fwrite("~p~n",[[1024]]).
      [1024]
      10> io:fwrite("~tp~n",[[1024]]).
      "\x{400}"
      11> io:fwrite("~tp~n", [<<128,128>>]).
      <<128,128>>
      12> io:fwrite("~tp~n", [<<208,128>>]).
      <<"\x{400}"/utf8>>
      ok

W

  Writes data in the same way as ~w, but takes an extra argument which is the maximum depth to which terms are printed. Anything below this depth is replaced with .... For example, using T above:

      8> io:fwrite("~W~n", [T,9]).
      [{attributes,[[{id,age,1.5},{mode,explicit},{typename,...}],
      [{id,cho},{mode,...},{...}]]},{typename,'Person'},
      {tag,{'PRIVATE',3}},{mode,implicit}]
      ok

  If the maximum depth has been reached, then it is impossible to read in the resultant output. Also, the ,... form in a tuple denotes that there are more elements in the tuple but these are below the print depth.

P

  Writes data in the same way as ~p, but takes an extra argument which is the maximum depth to which terms are printed. Anything below this depth is replaced with .... For example:

      9> io:fwrite("~62P~n", [T,9]).
      [{attributes,[[{id,age,1.5},{mode,explicit},{typename,...}],
                    [{id,cho},{mode,...},{...}]]},
       {typename,'Person'},
       {tag,{'PRIVATE',3}},
       {mode,implicit}]
      ok

B

  Writes an integer in base 2..36, the default base is 10. A leading dash is printed for negative integers.

  The precision field selects base. For example:

      1> io:fwrite("~.16B~n", [31]).
      1F
      ok
      2> io:fwrite("~.2B~n", [-19]).
      -10011
      ok
      3> io:fwrite("~.36B~n", [5*36+35]).
      5Z
      ok

X

  Like B, but takes an extra argument that is a prefix to insert before the number, but after the leading dash, if any.

  The prefix can be a possibly deep list of characters or an atom.

      1> io:fwrite("~X~n", [31,"10#"]).
      10#31
      ok
      2> io:fwrite("~.16X~n", [-31,"0x"]).
      -0x1F
      ok

#

  Like B, but prints the number with an Erlang style #-separated base prefix.

      1> io:fwrite("~.10#~n", [31]).
      10#31
      ok
      2> io:fwrite("~.16#~n", [-31]).
      -16#1F
      ok

b

  Like B, but prints lowercase letters.

x

  Like X, but prints lowercase letters.

+

  Like #, but prints lowercase letters.

n

  Writes a new line.

i

  Ignores the next term.

Returns:

ok

  The formatting succeeded.

If an error occurs, there is no output. For example:

    1> io:fwrite("~s ~w ~i ~w ~c ~n",['abc def', 'abc def', {foo, 1},{foo, 1}, 65]).
    abc def 'abc def'  {foo,1} A
    ok
    2> io:fwrite("~s", [65]).
    ** exception exit: {badarg,[{io,format,[<0.22.0>,"~s","A"]},
                                {erl_eval,do_apply,5},
                                {shell,exprs,6},
                                {shell,eval_exprs,6},
                                {shell,eval_loop,3}]}
         in function  io:o_request/2

In this example, an attempt was made to output the single character 65 with the aid of the string formatting directive "~s".

fread(Prompt, Format) -> Result
fread(IoDevice, Prompt, Format) -> Result

Types:

IoDevice = device()
Prompt = prompt()
Format = format()
Result =
{ok, Terms :: [term()]} |
{error, {fread, FreadError :: io_lib:fread_error()}} |
server_no_data()
server_no_data() = {error, ErrorDescription :: term()} | eof

Reads characters from the standard input (IoDevice), prompting it with Prompt. Interprets the characters in accordance with Format. Format contains control sequences which directs the interpretation of the input.

Format may contain:

- White space characters (SPACE, TAB and NEWLINE) which cause input to be read to the next non-white space character.

- Ordinary characters which must match the next input character.

- Control sequences, which have the general format ~*FMC. The character * is an optional return suppression character. It provides a method to specify a field which is to be omitted. F is the field width of the input field, M is an optional translation modifier (of which t is the only currently supported, meaning Unicode translation) and C determines the type of control sequence.

  Unless otherwise specified, leading white-space is ignored for all control sequences. An input field cannot be more than one line wide. The following control sequences are available:

  ~

    A single ~ is expected in the input.

  d

    A decimal integer is expected.

  u

    An unsigned integer in base 2..36 is expected. The field width parameter is used to specify base. Leading white-space characters are not skipped.

  -

    An optional sign character is expected. A sign character - gives the return value -1. Sign character + or none gives 1. The field width parameter is ignored. Leading white-space characters are not skipped.

  #

    An integer in base 2..36 with Erlang-style base prefix (for example "16#ffff") is expected.

  f

    A floating point number is expected. It must follow the Erlang floating point number syntax.

  s

    A string of non-white-space characters is read. If a field width has been specified, this number of characters are read and all trailing white-space characters are stripped. An Erlang string (list of characters) is returned.

    If Unicode translation is in effect (~ts), characters larger than 255 are accepted, otherwise not. With the translation modifier, the list returned may as a consequence also contain integers larger than 255:

        1> io:fread("Prompt> ","~s").
        Prompt> <Characters beyond latin1 range not printable in this medium>
        {error,{fread,string}}
        2> io:fread("Prompt> ","~ts").
        Prompt> <Characters beyond latin1 range not printable in this medium>
        {ok,[[1091,1085,1080,1094,1086,1076,1077]]}

  a

    Similar to s, but the resulting string is converted into an atom.

    The Unicode translation modifier is not allowed (atoms can not contain characters beyond the latin1 range).

  c

    The number of characters equal to the field width are read (default is 1) and returned as an Erlang string. However, leading and trailing white-space characters are not omitted as they are with s. All characters are returned.

    The Unicode translation modifier works as with s:

        1> io:fread("Prompt> ","~c").
        Prompt> <Character beyond latin1 range not printable in this medium>
        {error,{fread,string}}
        2> io:fread("Prompt> ","~tc").
        Prompt> <Character beyond latin1 range not printable in this medium>
        {ok,[[1091]]}

  l

    Returns the number of characters which have been scanned up to that point, including white-space characters.

  It returns:

  {ok, Terms}

    The read was successful and Terms is the list of successfully matched and read items.

  eof

    End of file was encountered.

  {error, FreadError}

    The reading failed and FreadError gives a hint about the error.

  {error, ErrorDescription}

    The read operation failed and the parameter ErrorDescription gives a hint about the error.

Examples:

    20> io:fread('enter>', "~f~f~f").
    enter>1.9 35.5e3 15.0
    {ok,[1.9,3.55e4,15.0]}
    21> io:fread('enter>', "~10f~d").
    enter>     5.67899
    {ok,[5.678,99]}
    22> io:fread('enter>', ":~10s:~10c:").
    enter>:   alan   :   joe    :
    {ok, ["alan", "   joe    "]}

rows() -> {ok, integer() >= 1} | {error, enotsup}
rows(IoDevice) -> {ok, integer() >= 1} | {error, enotsup}

Types:

IoDevice = device()

Retrieves the number of rows of the IoDevice (i.e. the height of a terminal). The function only succeeds for terminal devices, for all other IO devices the function returns {error, enotsup}

scan_erl_exprs(Prompt) -> Result
scan_erl_exprs(Device, Prompt) -> Result
scan_erl_exprs(Device, Prompt, StartLocation) -> Result
scan_erl_exprs(Device, Prompt, StartLocation, Options) -> Result

Types:

Device = device()
Prompt = prompt()
StartLocation = location()
Options = erl_scan:options()
Result = erl_scan:tokens_result() | server_no_data()
server_no_data() = {error, ErrorDescription :: term()} | eof

Reads data from the standard input (IoDevice), prompting it with Prompt. Reading starts at location StartLocation (1). The argument Options is passed on as the Options argument of the erl_scan:tokens/4 function. The data is tokenized as if it were a sequence of Erlang expressions until a final dot (.) is reached. This token is also returned. It returns:

{ok, Tokens, EndLocation}

  The tokenization succeeded.

{eof, EndLocation}

  End of file was encountered by the tokenizer.

eof

  End of file was encountered by the I/O-server.

{error, ErrorInfo, ErrorLocation}

  An error occurred while tokenizing.

{error, ErrorDescription}

  Other (rare) error condition, for instance {error, estale} if reading from an NFS file system.

Example:

    23> io:scan_erl_exprs('enter>').
    enter>abc(), "hey".
    {ok,[{atom,1,abc},{'(',1},{')',1},{',',1},{string,1,"hey"},{dot,1}],2}
    24> io:scan_erl_exprs('enter>').
    enter>1.0er.
    {error,{1,erl_scan,{illegal,float}},2}

scan_erl_form(Prompt) -> Result
scan_erl_form(IoDevice, Prompt) -> Result
scan_erl_form(IoDevice, Prompt, StartLocation) -> Result
scan_erl_form(IoDevice, Prompt, StartLocation, Options) -> Result

Types:

IoDevice = device()
Prompt = prompt()
StartLocation = location()
Options = erl_scan:options()
Result = erl_scan:tokens_result() | server_no_data()
server_no_data() = {error, ErrorDescription :: term()} | eof

Reads data from the standard input (IoDevice), prompting it with Prompt. Starts reading at location StartLocation (1). The argument Options is passed on as the Options argument of the erl_scan:tokens/4 function. The data is tokenized as if it were an Erlang form - one of the valid Erlang expressions in an Erlang source file - until a final dot (.) is reached. This last token is also returned. The return values are the same as for scan_erl_exprs/1,2,3 above.

parse_erl_exprs(Prompt) -> Result
parse_erl_exprs(IoDevice, Prompt) -> Result
parse_erl_exprs(IoDevice, Prompt, StartLocation) -> Result
parse_erl_exprs(IoDevice, Prompt, StartLocation, Options) ->
Result

Types:

IoDevice = device()
Prompt = prompt()
StartLocation = location()
Options = erl_scan:options()
Result = parse_ret()
parse_ret() =
{ok,
ExprList :: erl_parse:abstract_expr(),
EndLocation :: location()} |
{eof, EndLocation :: location()} |
{error,
ErrorInfo :: erl_scan:error_info() | erl_parse:error_info(),
ErrorLocation :: location()} |
server_no_data()
server_no_data() = {error, ErrorDescription :: term()} | eof

Reads data from the standard input (IoDevice), prompting it with Prompt. Starts reading at location StartLocation (1). The argument Options is passed on as the Options argument of the erl_scan:tokens/4 function. The data is tokenized and parsed as if it were a sequence of Erlang expressions until a final dot (.) is reached. It returns:

{ok, ExprList, EndLocation}

  The parsing was successful.

{eof, EndLocation}

  End of file was encountered by the tokenizer.

eof

  End of file was encountered by the I/O-server.

{error, ErrorInfo, ErrorLocation}

  An error occurred while tokenizing or parsing.

{error, ErrorDescription}

  Other (rare) error condition, for instance {error, estale} if reading from an NFS file system.

Example:

    25> io:parse_erl_exprs('enter>').
    enter>abc(), "hey".
    {ok, [{call,1,{atom,1,abc},[]},{string,1,"hey"}],2}
    26> io:parse_erl_exprs ('enter>').
    enter>abc("hey".
    {error,{1,erl_parse,["syntax error before: ",["'.'"]]},2}

parse_erl_form(Prompt) -> Result
parse_erl_form(IoDevice, Prompt) -> Result
parse_erl_form(IoDevice, Prompt, StartLocation) -> Result
parse_erl_form(IoDevice, Prompt, StartLocation, Options) -> Result

Types:

IoDevice = device()
Prompt = prompt()
StartLocation = location()
Options = erl_scan:options()
Result = parse_form_ret()
parse_form_ret() =
{ok,
AbsForm :: erl_parse:abstract_form(),
EndLocation :: location()} |
{eof, EndLocation :: location()} |
{error,
ErrorInfo :: erl_scan:error_info() | erl_parse:error_info(),
ErrorLocation :: location()} |
server_no_data()
server_no_data() = {error, ErrorDescription :: term()} | eof

Reads data from the standard input (IoDevice), prompting it with Prompt. Starts reading at location StartLocation (1). The argument Options is passed on as the Options argument of the erl_scan:tokens/4 function. The data is tokenized and parsed as if it were an Erlang form - one of the valid Erlang expressions in an Erlang source file - until a final dot (.) is reached. It returns:

{ok, AbsForm, EndLocation}

  The parsing was successful.

{eof, EndLocation}

  End of file was encountered by the tokenizer.

eof

  End of file was encountered by the I/O-server.

{error, ErrorInfo, ErrorLocation}

  An error occurred while tokenizing or parsing.

{error, ErrorDescription}

  Other (rare) error condition, for instance {error, estale} if reading from an NFS file system.

### Standard Input/Output

All Erlang processes have a default standard IO device. This device is used when no IoDevice argument is specified in the above function calls. However, it is sometimes desirable to use an explicit IoDevice argument which refers to the default IO device. This is the case with functions that can access either a file or the default IO device. The atom standard_io has this special meaning. The following example illustrates this:

    27> io:read('enter>').
    enter>foo.
    {ok,foo}
    28> io:read(standard_io, 'enter>').
    enter>bar.
    {ok,bar}

There is always a process registered under the name of user. This can be used for sending output to the user.

### Standard Error

In certain situations, especially when the standard output is redirected, access to an I/O-server specific for error messages might be convenient. The IO device standard_error can be used to direct output to whatever the current operating system considers a suitable IO device for error output. Example on a Unix-like operating system:

    $ erl -noshell -noinput -eval 'io:format(standard_error,"Error: ~s~n",["error 11"]),'\
    'init:stop().' > /dev/null
    Error: error 11

### Error Information

The ErrorInfo mentioned above is the standard ErrorInfo structure which is returned from all IO modules. It has the format:

    {ErrorLocation, Module, ErrorDescriptor}

A string which describes the error is obtained with the following call:

    Module:format_error(ErrorDescriptor)