home *** CD-ROM | disk | FTP | other *** search
/ PC Consument 1998 January / PCC11998.bin / demos / euphor.exe / LIBRARY.DOC < prev    next >
Encoding:
Text File  |  1997-03-20  |  123.8 KB  |  3,245 lines

  1.  
  2.             Part II - Library Routines
  3.  
  4.  1. Introduction
  5.  
  6.  A large number of library routines are provided. Some are built right into
  7.  the interpreter, ex.exe. Others are written in Euphoria and you must include
  8.  one of the .e files in euphoria\include to use them. Where this is the case, 
  9.  the appropriate include file is noted in the "Syntax" part of the description.
  10.  Of course an include file need only be included once in your program. The 
  11.  editor displays in magenta those routines that are built into the interpreter,
  12.  ex.exe, and require no include file. You can override the definition of these
  13.  built-in routines by defining your own routine with the same name. You will 
  14.  get a suppressible warning if you do this.
  15.  
  16.  To indicate what kind of object may be passed in and returned, the following 
  17.  prefixes are used:
  18.  
  19.    x - a general object (atom or sequence)
  20.    s - a sequence
  21.    a - an atom
  22.    i - an integer 
  23.   fn - an integer used as a file number
  24.   st - a string sequence, or single-character atom
  25.  
  26.  An error will result if an illegal argument value is passed to any of these 
  27.  routines.
  28.  
  29.  
  30.  2. Routines by Application Area
  31.  
  32.  2.1  Predefined Types         
  33.       
  34.       As well as declaring variables with these types, you can also call them 
  35.       just like ordinary functions, in order to test if a value is a certain 
  36.       type.
  37.  
  38.       integer     - test if an object is an integer
  39.       atom        - test if an object is an atom 
  40.       sequence     - test if an object is a sequence
  41.       
  42.  2.2  Sequence Manipulation   
  43.     
  44.       length     - return the length of a sequence
  45.       repeat     - repeat an object n times to form a sequence of length n
  46.       append     - add a new element to the end of a sequence
  47.       prepend     - add a new element to the beginning of a sequence
  48.       
  49.  2.3  Searching and Sorting  
  50.  
  51.       compare     - compare two objects
  52.       find        - find an object in a sequence
  53.       match       - find a sequence as a slice of another sequence
  54.       sort        - sort the elements of a sequence into ascending order
  55.  
  56.  2.4  Pattern Matching
  57.       
  58.       lower     - convert an atom or sequence to lower case
  59.       upper     - convert an atom or sequence to upper case
  60.       wildcard_match - match a pattern containing ? and * wildcards
  61.       wildcard_file  - match a file name against a wild card specification
  62.  
  63.  2.5  Math            
  64.  
  65.       These routines can be applied to individual atoms or to sequences of 
  66.       values. See "Operations on Sequences" in chapter 2 of REFMAN.DOC. 
  67.       
  68.       sqrt    - calculate the square root of an object
  69.       rand    - generate random numbers
  70.       sin    - calculate the sine of an angle
  71.       cos    - calculate the cosine of an angle
  72.       tan    - calculate the tangent of an angle
  73.       arctan    - calculate the arc tangent of a number
  74.       log    - calculate the natural logarithm 
  75.       floor    - round down to the nearest integer
  76.       remainder    - calculate the remainder when a number is divided by another
  77.       power    - calculate a number raised to a power
  78.  
  79.  2.6  Bitwise Logical Operations
  80.       
  81.       These routines treat numbers as collections of binary bits,
  82.       and logical operations are performed on corresponding
  83.       bits in the binary representation of the numbers. There are
  84.       no routines for shifting bits left or right, but you can
  85.       achieve the same effect by multiplying or dividing by
  86.       powers of 2.
  87.       
  88.       and_bits  - perform logical AND on corresponding bits
  89.       or_bits   - perform logical OR on corresponding bits
  90.       xor_bits  - perform logical XOR on corresponding bits
  91.       not_bits  - perform logical NOT on all bits
  92.  
  93.  2.7  File and Device I/O 
  94.  
  95.       To do input or output on a file or device you must first open the file
  96.       or device, then use the routines below to read or write to it, then close 
  97.       the file or device. open() will give you a file number to use as the 
  98.       first argument of the other I/O routines. Certain files/devices are 
  99.       opened for you automatically (as text files):
  100.  
  101.          0 - standard input
  102.          1 - standard output
  103.          2 - standard error
  104.  
  105.       Unless you redirect them on the command line, standard input comes from 
  106.       the keyboard, standard output and standard error go to the screen. When 
  107.       you write something to the screen it is written immediately without 
  108.       buffering. If you write to a file, your characters are put into a buffer 
  109.       until there are enough of them to write out efficiently. When you close 
  110.       the file or device, any remaining characters are written out. Input from
  111.       files is also buffered. When your program terminates, any files that are
  112.       still open will be closed for you automatically.
  113.       
  114.       Note: If a program (written in Euphoria or any other language) has a 
  115.       file open for writing, and you are forced to reboot your computer for 
  116.       any reason, you should immediately run CHKDSK or SCANDISK to repair any 
  117.       damage to the file system that may have occurred.
  118.  
  119.       open    - open a file or device
  120.       close    - close a file or device
  121.       print    - print a Euphoria object with {,,} to show the structure
  122.       ? x    - shorthand for print(1, x)
  123.       printf    - formatted print to a file or device
  124.       sprintf   - formatted print returned as a string sequence
  125.       puts    - output a string sequence to a file or device
  126.       getc    - read the next character from a file or device
  127.       gets    - read the next line from a file or device
  128.       get_key    - check for key pressed by the user, don't wait
  129.       wait_key  - wait for user to press a key
  130.       get    - read the representation of any Euphoria object from a file
  131.       value    - read the representation of any Euphoria object from a string
  132.       seek    - move to any character position within an open file
  133.       where    - report the current character position in an open file
  134.       current_dir - return the name of the current directory
  135.       dir      - return complete info on all files in a directory
  136.       allow_break - allow control-C/control-Break to terminate your program
  137.                     or not
  138.       check_break - check if user has pressed control-C or control-Break
  139.  
  140.  2.8  Mouse Support   
  141.  
  142.       get_mouse        - return mouse "events" (clicks, movements)
  143.       mouse_events  - select mouse events to watch for
  144.       mouse_pointer - display or hide the mouse pointer
  145.  
  146.  2.9  Operating System 
  147.  
  148.       time       - number of seconds since a fixed point in the past
  149.       tick_rate    - set the number of clock ticks per second
  150.       date       - current year, month, day, hour, minute, second etc.
  151.       command_line - DOS command-line used to run this program
  152.       getenv       - get value of an environment variable
  153.       system       - execute a DOS command line
  154.       abort       - terminate execution
  155.       
  156.  2.10 Special Machine-dependent routines
  157.       
  158.       machine_func - specialized operations in ex.exe with return value
  159.       machine_proc - specialized operations in ex.exe - no return value
  160.       
  161.  2.11 Debugging
  162.  
  163.       trace    - dynamically turns tracing on or off
  164.  
  165.  2.12 Graphics & Sound
  166.       
  167.       The following routines let you display information on the screen. The
  168.       PC screen can be placed into one of many graphics modes. See the top
  169.       of include\graphics.e for a description of the modes. There are two
  170.       basic types of graphics mode available. "Text" modes divide the screen
  171.       up into lines, where each line has a certain number of characters.
  172.       "Pixel-graphics" modes divide the screen up into many rows of dots, 
  173.       or "pixels". Each pixel can be a different color. In text modes you can 
  174.       display text only, with the choice of a foreground and a background 
  175.       color for each character. In pixel-graphics modes you can display lines, 
  176.       circles, dots, and also text.
  177.       
  178.       We've also included a routine for making sound on your PC speaker.
  179.       To make more sophisticated sounds, get the Sound Blaster library
  180.       developed by Jacques Deschenes. It's available on the Euphoria
  181.       Web page.
  182.       
  183.       The following routines work in all text and pixel-graphics modes:
  184.       
  185.         clear_screen     - clear the screen 
  186.         position     - set cursor line and column
  187.         get_position     - return cursor line and column
  188.         graphics_mode    - select a new pixel-graphics or text mode
  189.         video_config     - return parameters of current mode
  190.         scroll             - scroll text up or down
  191.         wrap             - control line wrap at right edge of screen
  192.         text_color       - set foreground text color
  193.         bk_color         - set background color
  194.         palette             - change color for one color number
  195.         all_palette      - change color for all color numbers
  196.         get_all_palette  - get the palette values for all colors
  197.         read_bitmap      - read a bitmap (.BMP) file and return a palette and
  198.                            a 2-d sequence of pixels
  199.         save_bitmap      - create a bitmap (.BMP) file, given a palette and
  200.                            a 2-d sequence of pixels
  201.         get_active_page  - return the page currently being written to
  202.         set_active_page  - change the page currently being written to    
  203.         get_display_page - return the page currently being displayed
  204.         set_display_page - change the page currently being displayed
  205.         sound             - make a sound on the PC speaker
  206.       
  207.       The following routines work in text modes only:
  208.  
  209.         cursor               - select cursor shape
  210.         text_rows       - set number of lines on text screen
  211.         save_text_image    - save a rectangular region from a text screen
  212.         display_text_image - display an image on the text screen
  213.       
  214.       The following routines work in pixel-graphics modes only.
  215.  
  216.         pixel          - set color of a pixel or set of pixels 
  217.         get_pixel     - read color of a pixel or set of pixels
  218.         draw_line     - connect a series of graphics points with a line
  219.         polygon          - draw an n-sided figure
  220.         ellipse          - draw an ellipse or circle 
  221.         save_screen   - save the screen to a bitmap (.BMP) file
  222.         save_image    - save a rectangular region from a pixel-graphics screen
  223.         display_image - display an image on the pixel-graphics screen
  224.       
  225.  2.13 Machine Level Interface 
  226.  
  227.       We've grouped here a number of routines that you can use to access your
  228.       machine at a low-level. With this low-level machine interface you can 
  229.       read and write to memory. You can also set up your own 386+ machine 
  230.       language routines and call them. 
  231.       
  232.       Some of the routines listed below are unsafe, in the sense that Euphoria 
  233.       can't protect you if you use them incorrectly. You could crash your 
  234.       program or even your system. If you reference a bad memory address it 
  235.       will often be safely caught by the Causeway DOS extender, and you'll 
  236.       get an error message on the screen plus a dump of machine-level 
  237.       information in the file CW.ERR.
  238.  
  239.       These routines are important because they allow Euphoria programmers 
  240.       to access low-level features of the hardware and operating system. 
  241.       For those with specialized applications this could be crucial. 
  242.  
  243.       Machine code routines can be written by hand, or taken from the 
  244.       disassembled output of a compiler for C or some other language. 
  245.       Remember that your machine code will be running in 32-bit protected 
  246.       mode. See demo\callmach.ex for an example.
  247.  
  248.       peek           - read one or more bytes from memory
  249.       poke          - write one or more bytes to memory
  250.       mem_copy        - copy a block of memory
  251.       mem_set         - set a block of memory to a value
  252.       call          - call a machine language routine
  253.       dos_interrupt   - call a DOS software interrupt routine
  254.       allocate          - allocate a block of memory
  255.       free          - deallocate a block of memory
  256.       allocate_low    - allocate a block of low memory (address less than 1Mb)
  257.       free_low          - free a block allocated with allocate_low
  258.       get_vector      - return address of interrupt handler
  259.       set_vector      - set address of interrupt handler
  260.       lock_memory     - ensure that a region of memory will never be swapped out
  261.       int_to_bytes    - convert an integer to 4 bytes
  262.       bytes_to_int    - convert 4 bytes to an integer
  263.       int_to_bits     - convert an integer to a sequence of bits
  264.       bits_to_int     - convert a sequence of bits to an integer
  265.       atom_to_float64 - convert an atom, to a sequence of 8 bytes in IEEE 
  266.                         64-bit floating-point format 
  267.       atom_to_float32 - convert an atom, to a sequence of 4 bytes in IEEE 
  268.                         32-bit floating-point format
  269.       float64_to_atom - convert a sequence of 8 bytes in IEEE 64-bit floating-
  270.                         point format, to an atom
  271.       float32_to_atom - convert a sequence of 4 bytes in IEEE 32-bit floating-
  272.                         point format, to an atom
  273.       set_rand          - set the random number generator so it will generate
  274.                       a repeatable series of random numbers
  275.       use_vesa        - force the use of the VESA graphics standard
  276.       crash_message   - specify a message to be printed if Euphoria detects an
  277.                       error in your program
  278.                     
  279.      
  280.  3. Alphabetical Listing of all Routines
  281.              
  282.              
  283.  
  284. ──────────────────────────────────────<?>───────────────────────────────────────
  285.  
  286.  Syntax:      ? x    
  287.  
  288.  Description: This is just a shorthand way of saying:  print(1, x)
  289.            i.e. printing the value of an expression to the standard output. 
  290.           
  291.  Example: 
  292.           ? {1, 2} + {3, 4}  
  293.           
  294.           would display {4, 6}. 
  295.  
  296.  Comments:    ? differs slightly from print() since it will add new-lines to 
  297.            make the output more readable on your screen or wherever you 
  298.            have directed standard output.  
  299.  
  300.  See Also:    print
  301.  
  302. ────────────────────────────────────<abort>─────────────────────────────────────
  303.  
  304.  Syntax:      abort(i)       
  305.     
  306.  Description: Abort execution of the program. The argument i is an integer 
  307.            status value to be returned to the operating system. A value of 0
  308.            generally indicates successful completion of the program. Other 
  309.            values can indicate various kinds of errors. DOS batch (.bat)
  310.            programs can read this value using the errorlevel feature.
  311.            
  312.  Comments:    abort() is useful when a program is many levels deep in 
  313.            subroutine calls, and execution must end immediately, perhaps
  314.            due to a severe error that has been detected.
  315.  
  316.           Normally ex.exe returns an exit status code of 0. If your program
  317.           fails with a Euphoria-detected compile-time or run-time error
  318.           then a code of 1 is returned.
  319.           
  320.  Example:     
  321.            if x = 0 then
  322.                puts(ERR, "can't divide by 0 !!!\n")
  323.                abort(1)
  324.            else
  325.                z = y / x
  326.            end if
  327.  
  328.  See Also:    crash_message
  329.  
  330. ─────────────────────────────────<all_palette>──────────────────────────────────
  331.  
  332.  Syntax:      include graphics.e
  333.           all_palette(s)
  334.       
  335.  Description: Specify new color intensities for the entire set of colors in the
  336.            current graphics mode. s is a sequence of the form:
  337.                
  338.                {{r,g,b}, {r,g,b}, ..., {r,g,b}}
  339.            
  340.            Each element specifies a new color intensity {red, green, blue}
  341.            for the corresponding color number, starting with color number 0.
  342.           The values for red, green and blue must be in the range 0 to 63.
  343.           
  344.  Comments:    This executes much faster than if you were to use palette() to 
  345.            set the new color intensities one by one. This procedure can
  346.            be used with read_bitmap() to quickly display a picture on the
  347.            screen.
  348.            
  349.  Example Program: demo\bitmap.ex
  350.  
  351.  See Also:    palette, read_bitmap, video_config, graphics_mode           
  352.            
  353. ───────────────────────────────────<allocate>───────────────────────────────────
  354.  
  355.  Syntax:      include machine.e
  356.            a = allocate(i)
  357.     
  358.  Description: Allocate i contiguous bytes of memory. Return the address of the
  359.           block of memory, or return 0 if the memory can't be allocated.
  360.           
  361.  Example:     buffer = allocate(100)
  362.            for i = 0 to 99 do
  363.                  poke(buffer+i, 0)
  364.            end for
  365.  
  366.  See Also:    free, allocate_low, peek, poke, call
  367.  
  368. ─────────────────────────────────<allocate_low>─────────────────────────────────
  369.  
  370.  Syntax:      include machine.e
  371.            i2 = allocate_low(i1)
  372.     
  373.  Description: Allocate i1 contiguous bytes of low memory, i.e. conventional
  374.             memory with an address below 1 megabyte. Return the address 
  375.            of the block of memory, or return 0 if the memory can't be 
  376.            allocated. 
  377.            
  378.  Comment:     Some DOS software interrupts require that you pass one or
  379.            more addresses in registers. These addresses must be 
  380.            conventional memory addresses for DOS to be able to read or 
  381.            write to them.
  382.           
  383.  Example Program: demo\dosint.ex
  384.  
  385.  See Also:    dos_interrupt, free_low, allocate, peek, poke
  386.  
  387. ─────────────────────────────────<allow_break>──────────────────────────────────
  388.  
  389.  Syntax:      include machine.e
  390.               allow_break(i)
  391.  
  392.  Description: When i is 1 (TRUE) control-c and control-break can terminate
  393.               your program when it tries to read input from the keyboard. When
  394.               i is 0 (FALSE) your program will not be terminated by control-c 
  395.               or control-break.
  396.  
  397.  Comments:    The operating system will still display ^C on the screen, even
  398.               when your program cannot be terminated. 
  399.  
  400.               Initially your program can be terminated at any point where
  401.               it tries to read from the keyboard. It could also be terminated
  402.               by other input/output operations depending on options the user 
  403.               has set in his CONFIG.SYS file. (See the MS-DOS BREAK command)
  404.               For some types of program this sudden termination could leave 
  405.               things in a messy state and might result in loss of data.
  406.               allow_break(0) lets you avoid this situation.
  407.               
  408.               You can find out if the user has pressed control-c or 
  409.               control-break by calling check_break(). 
  410.  
  411.  Example:     allow_break(0)  -- don't let the user kill me!
  412.  
  413.  See Also:    check_break
  414.  
  415. ───────────────────────────────────<and_bits>───────────────────────────────────
  416.  
  417.  Syntax:      x3 = and_bits(x1, x2)
  418.  
  419.  Description: Perform the logical AND operation on corresponding bits in
  420.               x1 and x2. A bit in x3 will be 1 only if the corresponding
  421.               bits in x1 and x2 are both 1.
  422.               
  423.  Comments:    The arguments to this function may be atoms or sequences. The
  424.            rules for arithmetic operations on sequences apply.
  425.  
  426.           The arguments must be representable as 32-bit numbers,
  427.           either signed or unsigned.
  428.           
  429.           If you intend to manipulate full 32-bit values, you should
  430.           declare your variables as atom, rather than integer. Euphoria's
  431.           integer type is limited to 31-bits.
  432.  
  433.               Results are treated as signed numbers. They will be
  434.               negative when the highest-order bit is 1.
  435.               
  436.               To understand the binary representation of a number you
  437.               should display it in hexadecimal notation. Use the %x format 
  438.               of printf().
  439.               
  440.  Example 1:   a = and_bits(#0F0F0000, #12345678)
  441.               -- a is #02040000
  442.  
  443.  Example 2:   a = and_bits(#FF, {#123456, #876543, #2211})
  444.               -- a is {#56, #43, #11}
  445.  
  446.  Example 3:   a = and_bits(#FFFFFFFF, #FFFFFFFF)
  447.            -- a is -1 
  448.            -- Note that #FFFFFFFF is a positive number, 
  449.            -- but the result of a bitwise logical operation is interpreted 
  450.            -- as a signed 32-bit number, so it's negative.
  451.  
  452.  See Also:    or_bits, xor_bits, not_bits, int_to_bits
  453.  
  454. ────────────────────────────────────<append>────────────────────────────────────
  455.  
  456.  Syntax:      s2 = append(s1, x)
  457.     
  458.  Description: Create a new sequence identical to s1 but with x added on the end
  459.            as the last element. The length of s2 will be length(s1) + 1. 
  460.           
  461.  Comments:    If x is an atom this is equivalent to s2 = s1 & x. If x is a 
  462.            sequence it is not equivalent. 
  463.           
  464.           The extra storage is allocated automatically and very 
  465.           efficiently with Euphoria's dynamic storage allocation. 
  466.           The case where s1 and s2 are actually the same variable 
  467.           (as in Example 1 below) is highly optimized.
  468.           
  469.  Example 1:   You can use append to dynamically grow a sequence, e.g.
  470.     
  471.           sequence x
  472.           
  473.           x = {}
  474.           for i = 1 to 10 do
  475.           x = append(x, i)
  476.           end for
  477.           -- x is now {1,2,3,4,5,6,7,8,9,10}
  478.  
  479.  Example 2:   Any kind of Euphoria object can be appended to a sequence, e.g.
  480.            
  481.            sequence x, y, z
  482.            
  483.            x = {"fred", "barney"}
  484.            y = append(x, "wilma")
  485.            -- y is now {"fred", "barney", "wilma"}
  486.     
  487.           z = append(append(y, "betty"), {"bam", "bam"})
  488.           -- z is now {"fred", "barney", "wilma", "betty", {"bam", "bam"}}
  489.           
  490.  See Also:    prepend, concatenation (&) and sequence-formation {,,} operators 
  491.            in refman.doc
  492.  
  493. ────────────────────────────────────<arctan>────────────────────────────────────
  494.  
  495.  Syntax:      x2 = arctan(x1)
  496.  
  497.  Description: Return the arctangent of x1.
  498.  
  499.  Comments:    The result will always be in the range -pi/2 to +pi/2 radians.
  500.  
  501.               This function may be applied to an atom or to all elements
  502.            of a sequence.
  503.  
  504.  Example:     s = arctan({1,2,3})
  505.               -- s is {0.785398, 1.10715, 1.24905}
  506.  
  507.  See Also:    tan, sin, cos
  508.  
  509. ─────────────────────────────────────<atom>─────────────────────────────────────
  510.  
  511.  Syntax:      i = atom(x)
  512.     
  513.  Description: Return 1 if x is an atom else return 0.
  514.  
  515.  Comments:    This serves to define the atom type. You can also call it
  516.           like an ordinary function to determine if an object is an
  517.           atom.
  518.          
  519.  Example 1:
  520.            atom a
  521.            a = 5.99
  522.            
  523.  Example 2:
  524.            line = gets(0)
  525.            if atom(line) then
  526.                 puts(SCREEN, "end of file\n")
  527.            end if
  528.           
  529.  See Also:    sequence
  530.  
  531. ───────────────────────────────<atom_to_float32>────────────────────────────────
  532.  
  533.  Syntax:      include machine.e
  534.               s = atom_to_float32(a1)
  535.  
  536.  Description: Convert a Euphoria atom to a sequence of 4 single-byte values.
  537.               These 4 bytes contain the representation of an IEEE floating-
  538.               point number in 32-bit format.
  539.  
  540.  Comments:    Euphoria atoms can have values which are 64-bit IEEE floating-
  541.               point numbers, so you may lose precision when you convert
  542.               to 32-bits (16 significant digits versus 7). The range of 
  543.               exponents is much larger in 64-bit format (10 to the 308, versus 
  544.               10 to the 38), so some atoms may be too large or too small to 
  545.               represent in 32-bit format. In this case you will get one of the 
  546.               special 32-bit values: inf or -inf (infinity or -infinity). 
  547.  
  548.               Integer values will also be converted to 32-bit floating-point 
  549.               format.
  550.  
  551.  Example:     fn = open("numbers.dat", "wb")
  552.               puts(fn, atom_to_float32(157.82)) -- write 4 bytes to a file
  553.               
  554.  See Also:    atom_to_float64, float32_to_atom
  555.  
  556. ───────────────────────────────<atom_to_float64>────────────────────────────────
  557.  
  558.  Syntax:      include machine.e
  559.               s = atom_to_float64(a1)
  560.  
  561.  Description: Convert a Euphoria atom to a sequence of 8 single-byte values.
  562.               These 8 bytes contain the representation of an IEEE floating-
  563.               point number in 64-bit format.
  564.  
  565.  Comments:    All Euphoria atoms have values which can be represented as 
  566.               64-bit IEEE floating-point numbers, so you can convert any atom
  567.               to 64-bit format without losing any precision. 
  568.                
  569.               Integer values will also be converted to 64-bit floating-point 
  570.               format.
  571.  
  572.  Example:     fn = open("numbers.dat", "wb")
  573.               puts(fn, atom_to_float32(157.82)) -- write 8 bytes to a file
  574.               
  575.  See Also:    atom_to_float32, float64_to_atom
  576.  
  577. ─────────────────────────────────<bits_to_int>──────────────────────────────────
  578.  
  579.  Syntax:      include machine.e
  580.            a = bits_to_int(s)
  581.            
  582.  Description: Convert a sequence of binary 1's and 0's into a positive
  583.             number. The least-significant bit is s[1].
  584.             
  585.  Comments:    If you print s the bits will appear in "reverse" order, but
  586.            it is convenient to have increasing subscripts access bits of 
  587.            increasing significance.
  588.            
  589.  Example:     a = bits_to_int({1,1,1,0,1})
  590.            -- a is 23 (binary 10111)
  591.  
  592.  See Also:    int_to_bits, and/or/not of sequences in refman.doc
  593.             
  594. ───────────────────────────────────<bk_color>───────────────────────────────────
  595.  
  596.  Syntax:      include graphics.e 
  597.            bk_color(i)
  598.     
  599.  Description: Set the background color. In pixel-graphics modes the whole 
  600.               screen is affected immediately. In text modes any new characters 
  601.               that you print will have the new background color.
  602.  
  603.  Comments:    The various colors are defined as constants in graphics.e
  604.         
  605.               In pixel-graphics modes, color 0 which is normally BLACK, will 
  606.               be set to the same {r,g,b} palette value as color number i.
  607.  
  608.            In text modes, to restore the original background color when 
  609.            your program finishes, e.g. 0 - BLACK, you must call bk_color(0).
  610.            If the cursor is at the bottom line of the screen, you may have 
  611.            to actually print something before terminating your program. 
  612.            Printing '\n' may be enough. 
  613.            
  614.  Example:     bk_color(BLACK)
  615.  
  616.  See Also:    text_color
  617.  
  618. ─────────────────────────────────<bytes_to_int>─────────────────────────────────
  619.  
  620.  Syntax:      include machine.e
  621.            a = bytes_to_int(s)
  622.            
  623.  Description: Convert a 4-element sequence of byte values to an atom.
  624.             The elements of s are in the order expected for a 32-bit
  625.             integer on the 386, i.e. least significant byte first. 
  626.  
  627.  Comments:    The result could be greater than the integer type allows,
  628.              so you should assign it to an atom.
  629.  
  630.             s would normally contain positive values that have been read 
  631.             using peek() from 4 consecutive memory locations. 
  632.              
  633.  Example:     atom int32
  634.            
  635.            int32 = bytes_to_int({37,1,0,0})
  636.            -- int32 is 37 + 256*1 = 293 
  637.  
  638.  See Also:    int_to_bytes, bits_to_int, peek, poke
  639.  
  640. ─────────────────────────────────────<call>─────────────────────────────────────
  641.  
  642.  Syntax:      call(a)
  643.     
  644.  Description: Call a machine language routine that starts at address a. This
  645.           routine must execute a RET instruction #C3 to return control
  646.           to Euphoria. The routine should save and restore any registers 
  647.           that it uses. 
  648.           
  649.  Comments:    You can allocate a block of memory for the routine and then poke
  650.             in the bytes of machine code. You might allocate other blocks of
  651.             memory for data and parameters that the machine code can operate
  652.             on. The addresses of these blocks could be poked into the 
  653.             machine code. 
  654.  
  655.  Example Program: see demo\callmach.ex
  656.  
  657.  See Also:    allocate, free, peek, poke
  658.  
  659. ─────────────────────────────────<check_break>──────────────────────────────────
  660.  
  661.  Syntax:      include machine.e
  662.               i = check_break()
  663.  
  664.  Description: Return the number of times that control-c or control-break have
  665.               been pressed since the last call to check_break(), or since the
  666.               beginning of the program if this is the first call.
  667.  
  668.  Comments:    This is useful after you have called allow_break(0) which
  669.               prevents control-c or control-break from terminating your
  670.               program. You can use check_break() to find out if the user
  671.               has pressed one of these keys. You might then perform some action
  672.               such as a graceful shutdown of your program. 
  673.               
  674.               Neither control-c nor control-break will be returned as input
  675.               characters when you read the keyboard. You can only detect
  676.               them by calling check_break().
  677.  
  678.  Example:     
  679.               k = get_key()
  680.               if check_break() then
  681.                   temp = graphics_mode(-1)
  682.                   puts(1, "Shutting down...")
  683.                   save_all_user_data()
  684.                   abort(1)
  685.               end if
  686.  
  687.  See Also: allow_break, get_key
  688.  
  689. ─────────────────────────────────<clear_screen>─────────────────────────────────
  690.  
  691.  Syntax:      clear_screen()
  692.     
  693.  Description: Clear the screen using the current background color (may be set 
  694.            by bk_color()). 
  695.  
  696.  Comments:    This works in all text and pixel-graphics modes.
  697.  
  698.  See Also:    bk_color, graphics_mode
  699.  
  700. ────────────────────────────────────<close>─────────────────────────────────────
  701.  
  702.  Syntax:      close(fn)
  703.     
  704.  Description: Close a file or device and flush out any still-buffered 
  705.            characters.
  706.  
  707.  Comments:    Any still-open files will be closed automatically when your 
  708.            program terminates.
  709.            
  710.  See Also:    open
  711.  
  712. ────────────────────────────────<command_line>──────────────────────────────────
  713.  
  714.  Syntax:      s = command_line() 
  715.  
  716.  Description: Return a sequence of strings, where each string is a word from 
  717.            the command line that started your program. The first word will
  718.            be the path to either the Euphoria executable, ex.exe or to
  719.            your bound .exe file. The next word is either the name of your 
  720.            Euphoria .ex file, or the path to your bound .exe file. After 
  721.            that will come any extra words typed by the user. You can use 
  722.            these words in your program. 
  723.  
  724.  Comments:    Euphoria (ex.exe) does not use any command line options. You
  725.            are free to use any options for your own program.
  726.  
  727.            If you bind your program you will find that all command line
  728.            arguments remain the same, except for the first two, even
  729.            though your user no longer types "ex" (see examples below).
  730.            
  731.  Example 1:   -- The user types:  ex myprog myfile.dat 12345
  732.            
  733.            cmd = command_line()
  734.            
  735.            -- cmd will be:  {"C:\EUPHORIA\BIN\EX.EXE", 
  736.                        "myprog",
  737.                        "myfile.dat",
  738.                        "12345"}
  739.  
  740.  Example 2:   -- Your program is bound with the name "myprog.exe"
  741.            -- and is stored in the directory c:\myfiles
  742.            -- The user types:  myprog myfile.dat 12345
  743.            
  744.            cmd = command_line()
  745.            
  746.            -- cmd will be:  {"C:\MYFILES\MYPROG.EXE",
  747.                        "C:\MYFILES\MYPROG.EXE", -- spacer
  748.                        "myfile.dat",
  749.                        "12345"}
  750.           
  751.           -- Note that all arguments remain the same as Example 1 
  752.           -- except for the first two. The second argument is always
  753.           -- the same as the first and is inserted to keep the numbering
  754.           -- of the subsequent arguments the same, whether your program
  755.           -- is bound as a .exe or not.
  756.           
  757.  See Also:    getenv
  758.  
  759. ───────────────────────────────────<compare>────────────────────────────────────
  760.  
  761.  Syntax:      i = compare(x1, x2)
  762.     
  763.  Description: Return 0 if objects x1 and x2 are identical, 1 if x1 is greater 
  764.           than x2, -1 if x1 is less than x2. Atoms are considered to be 
  765.           less than sequences. Sequences are compared "alphabetically" 
  766.           starting with the first element until a difference is found. 
  767.           
  768.  Example 1:   x = compare({1,2,{3,{4}},5}, {2-1,1+1,{3,{4}},6-1})
  769.            -- identical, x is 0
  770.                
  771.  Example 2:   if compare("ABC", "ABCD") < 0 then   -- -1
  772.          -- will be true: ABC is "less" because it is shorter
  773.            end if
  774.  
  775.  Example 3:   x = compare({12345, 99999, -1, 700, 2},
  776.                           {12345, 99999, -1, 699, 3, 0})
  777.               -- x will be 1 because 700 > 699
  778.                           
  779.  See Also:    equals (=) operator in refman.doc
  780.  
  781. ─────────────────────────────────────<cos>──────────────────────────────────────
  782.  
  783.  Syntax:      x2 = cos(x1)
  784.     
  785.  Description: Return the cosine of x1, where x1 is in radians.
  786.  
  787.  Comments:    This function may be applied to an atom or to all elements
  788.            of a sequence.
  789.  
  790.  Example:     x = cos({.5, .6, .7})
  791.            
  792.            -- x is {0.8775826, 0.8253356, 0.7648422}
  793.  
  794.  See Also:    sin, tan, log, sqrt
  795.  
  796. ────────────────────────────────<crash_message>─────────────────────────────────
  797.  
  798.  Syntax:      include machine.e
  799.            crash_message(s)
  800.  
  801.  Description: Specify a string, s, to be printed on the screen in the event
  802.            that Euphoria must stop your program due to a compile-time or
  803.            run-time error. 
  804.  
  805.  Comments:    Normally Euphoria prints a diagnostic message such as 
  806.            "syntax error" or "divide by zero" on the screen, as well as 
  807.            dumping debugging information into "ex.err". Euphoria's error 
  808.            messages will not be meaningful for your users unless they
  809.            happen to be Euphoria programmers. By calling crash_message()
  810.            you can control the message that will appear on the screen.
  811.            Debugging information will still be stored in ex.err. You won't
  812.            lose any information by doing this.
  813.            
  814.            s may contain '\n', new-line characters so your message can
  815.            span several lines on the screen. Euphoria will switch to the
  816.            top of a clear text-mode screen before printing your message.
  817.            
  818.            You can call crash_message() as many times as you like from
  819.            different parts of your program. The message specified by the
  820.            last call will be the one displayed.
  821.            
  822.            Your crash message will always be displayed if a compile-time
  823.            error (syntax, undeclared variable etc.) occurs. In the case of
  824.            a run-time error (subscript out of bounds, uninitialized 
  825.            variable, divide by zero etc.) your program must be executed
  826.            by the Complete Edition EX.EXE, or have been bound using
  827.            the Complete Edition PDEX.EXE, or be under 300 statements.
  828.  
  829.  Example:     crash_message("An unexpected error has occurred!\n" &
  830.                  "Please contact john_doe@whoops.com\n" & 
  831.                  "Do not delete the file \"ex.err\".\n")
  832.  
  833.  See Also:    abort
  834.            Debugging section of refman.doc
  835.  
  836. ─────────────────────────────────<current_dir>──────────────────────────────────
  837.  
  838.  Syntax:      include file.e
  839.            s = current_dir()
  840.     
  841.  Description: Return the name of the current working directory.
  842.  
  843.  Example:
  844.            sequence s
  845.            s = current_dir()
  846.            -- s would have "C:\EUPHORIA\DOC" if you were in that directory
  847.            
  848.  See Also:    dir, getenv
  849.  
  850. ────────────────────────────────────<cursor>────────────────────────────────────
  851.  
  852.  Syntax:      include graphics.e  
  853.            cursor(i)
  854.     
  855.  Description: Select a style of cursor. graphics.e contains:
  856.         
  857.         global constant NO_CURSOR      = #2000,
  858.              UNDERLINE_CURSOR       = #0607,
  859.              THICK_UNDERLINE_CURSOR = #0507,
  860.              HALF_BLOCK_CURSOR      = #0407,
  861.              BLOCK_CURSOR           = #0007
  862.            
  863.            The second and fourth hex digits (from the left) determine the 
  864.            top and bottom rows of pixels in the cursor. The first digit 
  865.            controls whether the cursor will be visible or not. For example,
  866.            #0407 turns on the 4th through 7th rows.
  867.            
  868.  Comments:    In pixel-graphics modes there is no cursor.
  869.  
  870.  Example:     cursor(BLOCK_CURSOR)
  871.  
  872. ─────────────────────────────────────<date>─────────────────────────────────────
  873.  
  874.  Syntax:      s = date()
  875.     
  876.  Description: Return a sequence with the following information:
  877.          { year (since 1900),
  878.            month (January = 1),
  879.            day (day of month, starting at 1),
  880.            hour (0 to 23),
  881.            minute (0 to 59),
  882.            second (0 to 59),
  883.            day of the week (Sunday = 1),
  884.            day of the year (January 1st = 1) }
  885.  
  886.  Example:     now = date()
  887.            -- now has: {95,3,24,23,47,38,6,83}
  888.            -- i.e. Friday March 24, 1995 at 11:47:38pm, day 83 of the year
  889.  
  890.  See Also:    time
  891.  
  892. ─────────────────────────────────────<dir>──────────────────────────────────────
  893.  
  894.  Syntax:      include file.e
  895.            x = dir(st)
  896.     
  897.  Description: Return directory information for the file or directory named by
  898.             st. If there is no file or directory with this name then -1 is
  899.             returned.
  900.             
  901.            This information is similar to what you would get from the DOS
  902.            DIR command. A sequence is returned where each element is a 
  903.            sequence that describes one file or subdirectory. 
  904.           
  905.           If st names a directory you may have entries for "." and "..",
  906.           just as with the DOS DIR command. If st names a file then x will
  907.           have just one entry, i.e. length(x) will be 1. 
  908.           
  909.           Each entry contains the name, attributes and file size as well 
  910.           as the year, month, day, hour, minute and second of the last 
  911.           modification. You can refer to the elements of an entry with 
  912.           the following constants defined in file.e:
  913.         
  914.         global constant 
  915.             D_NAME = 1,
  916.             D_ATTRIBUTES = 2,
  917.             D_SIZE = 3,
  918.  
  919.             D_YEAR = 4,
  920.             D_MONTH = 5,
  921.             D_DAY = 6,
  922.  
  923.             D_HOUR = 7,
  924.             D_MINUTE = 8,
  925.             D_SECOND = 9
  926.           
  927.           The attributes element is a string sequence containing 
  928.           characters chosen from:
  929.  
  930.             d - directory
  931.             r - read only file
  932.             h - hidden file
  933.             s - system file
  934.             v - volume-id entry
  935.             a - archive file
  936.  
  937.           A normal file without special attributes would just have an empty
  938.           string, "", in this field. 
  939.         
  940.  Comments:    The top level directory, e.g. c:\ does not have "." or ".."
  941.           entries. 
  942.           
  943.           This function is often used just to test if a file or 
  944.           directory exists.
  945.           
  946.           Under Windows 95, st can have a long file or directory name 
  947.           anywhere in the path.
  948.            
  949.           The file name returned in D_NAME will be a standard DOS 8.3 name,
  950.           even on Windows 95 or Windows NT. A new long-filename element
  951.           may be added in a future release of Euphoria.
  952.  
  953.  Example:      
  954.           d = dir(current_dir()) 
  955.           
  956.           -- d might have:
  957.         {
  958.              {".",    "d",     0  1994, 1, 18,  9, 30, 02},
  959.              {"..",   "d",     0  1994, 1, 18,  9, 20, 14},
  960.              {"fred", "ra", 2350, 1994, 1, 22, 17, 22, 40},
  961.              {"sub",  "d" ,    0, 1993, 9, 20,  8, 50, 12}
  962.         } 
  963.           
  964.           d[3][D_NAME] would be "fred"
  965.           
  966.  Example Programs: bin\search.ex, install.ex
  967.  
  968.  See Also: wildcard_file, current_dir, open
  969.  
  970. ────────────────────────────────<display_image>─────────────────────────────────
  971.  
  972.  Syntax:      include image.e
  973.            display_image(s1, s2)
  974.            
  975.  Description: Display at point s1 on a pixel-graphics screen the 2-d sequence 
  976.               of pixels contained in s2. s1 is a two-element sequence {x, y}. 
  977.               s2 is a sequence of sequences, where each sequence is one 
  978.               horizontal line of pixel colors to be displayed. The first pixel 
  979.               of the first sequence is displayed at s1. It is the top-left 
  980.               pixel. All other pixels appear to the right or below of this 
  981.               point.
  982.  
  983.  Comments:    s2 might be the result of a previous call to save_image(), or
  984.            read_bitmap(), or it could be something you have created.
  985.           
  986.           You could use save_image/display_image in a graphical user 
  987.           interface, to allow "pop-up" dialog boxes, and drop-down menus
  988.           to appear and disappear without losing what was previously on 
  989.           the screen.
  990.           
  991.           The sequences (rows) of the image do not have to all be the
  992.           same length.
  993.           
  994.  Example:     display_image({20,30}, {{1,5,9}, 
  995.                        {2,4}, 
  996.                        {1,0,1,0,4}, 
  997.                        {5,5,5}})
  998.            -- displays a small 4-line image at {20,30}, with the pixels
  999.               appearing in the same relative positions as the layout
  1000.               above would indicate
  1001.  
  1002.  Example Program: see demo\bitmap.ex
  1003.  
  1004.  See Also:    save_image, read_bitmap, display_text_image
  1005.  
  1006. ─────────────────────────────<display_text_image>───────────────────────────────
  1007.  
  1008.  Syntax:      include image.e
  1009.            display_text_image(s1, s2)
  1010.  
  1011.  Description: Display the 2-d sequence of characters and attributes contained
  1012.             in s2 at line s1[1], column s1[2]. s2 is a sequence of sequences,
  1013.             where each sequence is a string of characters and attributes to 
  1014.             be displayed. The top-left character is displayed at s1. Other 
  1015.             characters appear to the right or below of this position. The 
  1016.             attributes indicate the foreground and background color of the 
  1017.             preceding character.
  1018.             
  1019.  Comments:    s2 would normally be the result of a previous call to 
  1020.            save_text_image(), although you could construct it yourself.
  1021.           
  1022.           This routine only works in text modes.
  1023.           
  1024.           You might use save_text_image/display_text_image in a text-mode
  1025.           graphical user interface, to allow "pop-up" dialog boxes, and 
  1026.           drop-down menus to appear and disappear without losing what was
  1027.           previously on the screen.
  1028.  
  1029.            The sequences of the text image do not have to all be the same
  1030.            length.
  1031.            
  1032.  Example:     clear_screen()
  1033.            display_text_image({1,1}, {{'A', WHITE, 'B', GREEN},
  1034.                        {'C', RED+16*WHITE},
  1035.                        {'D', BLUE}})
  1036.            -- displays:  AB
  1037.                      C
  1038.                      D
  1039.              in the appropriate colors at the top left corner of the screen
  1040.  
  1041.  See Also:    save_text_image, display_image
  1042.  
  1043. ────────────────────────────────<dos_interrupt>─────────────────────────────────
  1044.  Syntax:      include machine.e
  1045.            s2 = dos_interrupt(i, s1)
  1046.            
  1047.  Description: Call DOS software interrupt number i. s1 is a 10-element 
  1048.           sequence of 16-bit register values to be used as input to the
  1049.           routine. s2 is a similar 10-element sequence containing
  1050.           output register values after the call returns. machine.e
  1051.           has the following declaration which shows the order of
  1052.           the register values in the input and output sequences.
  1053.  
  1054.         global constant REG_DI = 1,      
  1055.                 REG_SI = 2,
  1056.                 REG_BP = 3,
  1057.                 REG_BX = 4,
  1058.                 REG_DX = 5,
  1059.                 REG_CX = 6,
  1060.                 REG_AX = 7,
  1061.                 REG_FLAGS = 8, 
  1062.                 REG_ES = 9,
  1063.                 REG_DS = 10
  1064.  
  1065.  Comments:    The register values returned in s2 are always positive values 
  1066.            between 0 and #FFFF (65535). 
  1067.  
  1068.            The flags value in s1[REG_FLAGS] is ignored on input. On output
  1069.           the least significant bit of s2[REG_FLAGS] has the carry flag, 
  1070.           which usually indicates failure if it is set to 1.
  1071.  
  1072.           Certain interrupts require that you supply addresses of blocks of
  1073.           memory. These addresses must be conventional, low-memory
  1074.           addresses. You can allocate/deallocate low-memory using 
  1075.           allocate_low() and free_low().
  1076.           
  1077.           With DOS software interrupts you can perform a wide variety
  1078.           of specialized operations, anything from formatting your 
  1079.           floppy drive to rebooting your computer. For documentation
  1080.           on these interrupts consult a technical manual such as
  1081.           Peter Norton's "PC Programmer's Bible", or download Ralf
  1082.           Brown's Interrupt List from the WEB:
  1083.      
  1084.            http://www.cs.cmu.edu/afs/cs.cmu.edu/user/ralf/pub/WWW/files.html
  1085.  
  1086.  Example Program: demo\dosint.ex
  1087.  
  1088.  See Also:      allocate_low, free_low
  1089.  
  1090. ──────────────────────────────────<draw_line>───────────────────────────────────
  1091.  
  1092.  Syntax:      include graphics.e
  1093.            draw_line(i, s)
  1094.     
  1095.  Description: Draw a line on a pixel-graphics screen connecting two or more 
  1096.               points in s, using color i. 
  1097.  
  1098.  Example:     draw_line(WHITE, {{100, 100}, {200, 200}, {900, 700}}) 
  1099.  
  1100.           This would connect the three points in the sequence using a white
  1101.           line, i.e. a line would be drawn from {100, 100} to {200, 200} 
  1102.           and another line would be drawn from {200, 200} to {900, 700}.
  1103.  
  1104.  See Also:    polygon, ellipse, pixel
  1105.  
  1106. ───────────────────────────────────<ellipse>────────────────────────────────────
  1107.  
  1108.  Syntax:      include graphics.e
  1109.            ellipse(i1, i2, s1, s2)
  1110.     
  1111.  Description: Draw an ellipse with color i1 on a pixel-graphics screen. The 
  1112.               ellipse will neatly fit inside the rectangle defined by diagonal 
  1113.               points s1 {x1, y1} and s2 {x2, y2}. If the rectangle is a square 
  1114.               then the ellipse will be a circle. Fill the ellipse when i2 is 1.
  1115.               Don't fill when i2 is 0. 
  1116.  
  1117.  Example:     ellipse(MAGENTA, 0, {10, 10}, {20, 20})
  1118.  
  1119.           This would make a magenta colored circle just fitting inside the
  1120.           square: {10, 10}, {10, 20}, {20, 20}, {20, 10}.
  1121.  
  1122.  Example Program: demo\sb.ex
  1123.  
  1124.  See Also:    polygon, draw_line
  1125.  
  1126. ─────────────────────────────────────<find>─────────────────────────────────────
  1127.  
  1128.  Syntax:      i = find(x, s)
  1129.  
  1130.  Description: Find x as an element of s. If successful, return the index 
  1131.            of the first element of s that matches. If unsuccessful 
  1132.            return 0. 
  1133.     
  1134.  Example 1:   location = find(11, {5, 8, 11, 2, 3})
  1135.           -- location is set to 3
  1136.  
  1137.  Example 2:   names = {"fred", "rob", "george", "mary", ""}
  1138.           location = find("mary", names)
  1139.           -- location is set to 4
  1140.  
  1141.  See Also:    match, compare
  1142.  
  1143. ────────────────────────────────<float32_to_atom>───────────────────────────────
  1144.  
  1145.  Syntax:      include machine.e
  1146.               a1 = float32_to_atom(s)
  1147.               
  1148.  Description: Convert a sequence of 4 bytes to an atom. These 4 bytes must 
  1149.               contain an IEEE floating-point number in 32-bit format.
  1150.  
  1151.  Comments:    Any 32-bit IEEE floating-point number can be converted to an 
  1152.               atom.
  1153.  
  1154.  Example:     f = repeat(0, 4) 
  1155.               fn = open("numbers.dat", "rb") -- read binary 
  1156.               f[1] = getc(fn)
  1157.               f[2] = getc(fn)
  1158.               f[3] = getc(fn)
  1159.               f[4] = getc(fn)
  1160.               a = float32_to_atom(f)
  1161.  
  1162.  See Also: float64_to_atom, atom_to_float32
  1163.  
  1164. ────────────────────────────────<float64_to_atom>───────────────────────────────
  1165.  
  1166.  Syntax:      include machine.e
  1167.               a1 = float64_to_atom(s)
  1168.               
  1169.  Description: Convert a sequence of 8 bytes to an atom. These 8 bytes must 
  1170.               contain an IEEE floating-point number in 64-bit format.
  1171.  
  1172.  Comments:    Any 64-bit IEEE floating-point number can be converted to an 
  1173.               atom.
  1174.  
  1175.  Example:     f = repeat(0, 8) 
  1176.               fn = open("numbers.dat", "rb")  -- read binary
  1177.               for i = 1 to 8 do
  1178.                   f[i] = getc(fn)
  1179.           end for
  1180.               a = float64_to_atom(f)
  1181.  
  1182.  See Also: float32_to_atom, atom_to_float64
  1183.  
  1184. ────────────────────────────────────<floor>─────────────────────────────────────
  1185.  
  1186.  Syntax:      x2 = floor(x1)
  1187.     
  1188.  Description: Return the greatest integer less than or equal to x1. (Round
  1189.            down to an integer.)
  1190.  
  1191.  Comments:    This function may be applied to an atom or to all elements
  1192.            of a sequence.
  1193.            
  1194.  Example:     y = floor({0.5, -1.6, 9.99, 100})
  1195.            -- y is {0, -2, 9, 100}
  1196.  
  1197.  See Also:    remainder
  1198.  
  1199. ─────────────────────────────────────<free>─────────────────────────────────────
  1200.  
  1201.  Syntax:      include machine.e
  1202.            free(a)
  1203.     
  1204.  Description: Free up a previously allocated block of memory by specifying the
  1205.           address of the start of the block, i.e. the address that was
  1206.           returned by allocate(). 
  1207.  
  1208.  Comments:    Use free() to recycle blocks of memory during execution. This
  1209.             will reduce the chance of running out of memory or getting into 
  1210.             excessive virtual memory swapping to disk. Do not reference 
  1211.             a block of memory that has been freed. When your program 
  1212.             terminates, all allocated memory will be returned to the system. 
  1213.            
  1214.            Do not use free() to deallocate memory that was allocated using
  1215.            allocate_low(). Use free_low() for this purpose.
  1216.            
  1217.  Example Program: demo\callmach.ex
  1218.  
  1219.  See Also:    allocate, free_low
  1220.  
  1221. ───────────────────────────────────<free_low>───────────────────────────────────
  1222.  
  1223.  Syntax:      include machine.e
  1224.            free_low(i)
  1225.     
  1226.  Description: Free up a previously allocated block of conventional memory by 
  1227.            specifying the address of the start of the block, i.e. the 
  1228.            address that was returned by allocate_low(). 
  1229.  
  1230.  Comments:    Use free_low() to recycle blocks of conventional memory during 
  1231.            execution. This will reduce the chance of running out of 
  1232.            conventional memory. Do not reference a block of memory that has
  1233.            been freed. When your program terminates, all allocated memory 
  1234.            will be returned to the system. 
  1235.            
  1236.            Do not use free_low() to deallocate memory that was allocated 
  1237.            using allocate(). Use free() for this purpose.
  1238.            
  1239.  Example Program: demo\dosint.ex
  1240.  
  1241.  See Also:    allocate_low, dos_interrupt, free
  1242.  
  1243. ─────────────────────────────────────<get>──────────────────────────────────────
  1244.  
  1245.  Syntax:      include get.e
  1246.            s = get(fn)
  1247.  
  1248.  Description: Input, from file fn, a human-readable string of characters 
  1249.               representing a Euphoria object. Convert the string into the 
  1250.               numeric value of that object. s will be a 2-element sequence: 
  1251.             {error status, value}. Error status values are:
  1252.  
  1253.         GET_SUCCESS  -- object was read successfully
  1254.         GET_EOF      -- end of file before object was read
  1255.         GET_FAIL     -- object is not syntactically correct
  1256.  
  1257.           get() can read arbitrarily complicated Euphoria objects. You 
  1258.           could have a long sequence of values in braces and separated by 
  1259.           commas, e.g. {23, {49, 57}, 0.5, -1, 99, 'A', "john"}. A single
  1260.           call to get() will read in this entire sequence and return it's
  1261.           value as a result. 
  1262.     
  1263.           Each call to get() picks up where the previous call left off. For 
  1264.           instance, a series of 5 calls to get() would be needed to read 
  1265.           in: 
  1266.     
  1267.         99  5.2  {1,2,3}  "Hello"  -1
  1268.  
  1269.            On the sixth and any subsequent call to get() you would see a
  1270.            GET_EOF status. If you had something like:
  1271.            
  1272.              {1,2,xxx}
  1273.            
  1274.            in the input stream you would see a GET_FAIL error status
  1275.            because xxx is not a Euphoria object.
  1276.            
  1277.            Distinct "top-level" objects in the input stream must be 
  1278.            separated from each other with one or more "whitespace" 
  1279.            characters (blank, tab or \n). Whitespace is not necessary 
  1280.            *within* a top-level object.
  1281.            
  1282.  Comments:    The combination of print() and get() can be used to save any 
  1283.            Euphoria object to disk and later read it back. This technique
  1284.            could be used to implement a database as one or more large 
  1285.            Euphoria sequences stored in disk files. The sequences could be
  1286.            read into memory, updated and then written back to disk after
  1287.            each series of transactions is complete. 
  1288.  
  1289.            The value returned is not meaningful unless you have a 
  1290.            GET_SUCCESS status.
  1291.            
  1292.  Example:     Suppose your program asks the user to enter a number from the
  1293.             keyboard. If he types 77.5, get(0) would return:
  1294.                  
  1295.                  {GET_SUCCESS, 77.5} 
  1296.             
  1297.             whereas gets(0) would return
  1298.               
  1299.               "77.5\n" 
  1300.  
  1301.  Example Program: see demo\mydata.ex. 
  1302.  
  1303.  See Also:    print, value, gets, getc
  1304.  
  1305. ───────────────────────────────<get_active_page>────────────────────────────────
  1306.  
  1307.  Syntax:      include image.e
  1308.            i = get_active_page()
  1309.  
  1310.  Description: Some graphics modes on most video cards have multiple pages
  1311.            of memory. This lets you write screen output to one page
  1312.            while displaying a different page. get_active_page() returns
  1313.            the current page number that screen output is being sent to.
  1314.            
  1315.  Comments:    The active and display pages are both 0 by default.
  1316.           
  1317.           video_config() will tell you how many pages are available in
  1318.           the current graphics mode.
  1319.  
  1320.  See Also:    set_active_page, get_display_page, video_config
  1321.  
  1322. ───────────────────────────────<get_all_palette>────────────────────────────────
  1323.  
  1324.  Syntax:      include image.e
  1325.           s = get_all_palette()
  1326.         
  1327.  Description: Retrieve color intensities for the entire set of colors in the
  1328.               current graphics mode. s is a sequence of the form:
  1329.              
  1330.             {{r,g,b}, {r,g,b}, ..., {r,g,b}}
  1331.            
  1332.           Each element specifies a color intensity {red, green, blue}
  1333.           for the corresponding color number, starting with color 
  1334.           number 0. The values for red, green and blue will be in the
  1335.           range 0 to 63.
  1336.              
  1337.  Comments:    This function might be used to get the palette values needed
  1338.               by save_bitmap(). Remember to multiply these values by 4 before 
  1339.               calling save_bitmap(), since save_bitmap() expects values in the 
  1340.               range 0 to 255.
  1341.  
  1342.  See Also:    palette, all_palette, read_bitmap, save_bitmap, save_screen
  1343.  
  1344. ───────────────────────────────<get_display_page>───────────────────────────────
  1345.  
  1346.  Syntax:      include image.e
  1347.            i = get_display_page()
  1348.  
  1349.  Description: Some graphics modes on most video cards have multiple pages
  1350.            of memory. This lets you write screen output to one page
  1351.            while displaying another. get_display_page() returns the current
  1352.            page number that is being displayed on the monitor.
  1353.            
  1354.  Comments:    The active and display pages are both 0 by default.
  1355.  
  1356.           video_config() will tell you how many pages are available in
  1357.           the current graphics mode.
  1358.  
  1359.  See Also:    set_display_page, get_active_page, video_config
  1360.  
  1361. ───────────────────────────────────<get_key>────────────────────────────────────
  1362.  
  1363.  Syntax:      i = get_key()
  1364.     
  1365.  Description: Return the key that was pressed by the user, without waiting for 
  1366.           carriage return. Return -1 if no key was pressed. Special
  1367.           codes are returned for the function keys, arrow keys etc.
  1368.  
  1369.  Comments:    DOS can hold a small number of key-hits in its keyboard buffer. 
  1370.            get_key() will return the next one from the buffer, or -1 if 
  1371.            the buffer is empty.
  1372.  
  1373.            Run the key.bat program to see what key code is generated for
  1374.            each key on your keyboard.
  1375.            
  1376.  See Also:    wait_key, getc
  1377.  
  1378. ──────────────────────────────────<get_mouse>───────────────────────────────────
  1379.  
  1380.  Syntax:      include mouse.e
  1381.               x1 = get_mouse()
  1382.     
  1383.  Description: Return the last mouse event in the form:
  1384.           
  1385.           {event, x, y} 
  1386.             
  1387.             or return -1 if there has not been a mouse event since the last
  1388.             time get_mouse() was called. 
  1389.  
  1390.           Constants have been defined in mouse.e for the possible mouse
  1391.           events: 
  1392.     
  1393.             global constant MOVE = 1,  
  1394.                     LEFT_DOWN = 2,
  1395.                     LEFT_UP = 4,
  1396.                     RIGHT_DOWN = 8,
  1397.                     RIGHT_UP = 16,
  1398.                     MIDDLE_DOWN = 32,
  1399.                     MIDDLE_UP = 64
  1400.     
  1401.           x and y are the coordinates of the mouse pointer at the time that 
  1402.           the event occurred. get_mouse() returns immediately with either 
  1403.           a -1 or a mouse event. It does not wait for an event to occur. 
  1404.           You must check it frequently enough to avoid missing an event.
  1405.           When the next event occurs, the current event will be lost, if 
  1406.           you haven't read it. In practice it is not hard to catch almost
  1407.           all events, and the ones that are lost are usually lost at a 
  1408.           lower level in the system, beyond the control of your program.
  1409.           Losing a MOVE event is generally not too serious, as the next 
  1410.           MOVE will tell you where the mouse pointer is. 
  1411.  
  1412.  Comments:    You need a DOS mouse driver to use this routine.
  1413.             
  1414.            You can use get_mouse() in most text and pixel-graphics modes. 
  1415.           
  1416.             The first call that you make to get_mouse() will turn on a
  1417.             mouse pointer, or a highlighted character.
  1418.            
  1419.           In text modes you will probably want to scale the x and y 
  1420.           coordinates to get line and column positions.
  1421.           
  1422.           DOS generally does not support the use of a mouse in SVGA 
  1423.           graphics modes (beyond 640x480 pixels). This restriction
  1424.           has been removed in Windows 95 (DOS 7.0).
  1425.           
  1426.           The x,y coordinate returned could be that of the very tip of the
  1427.           mouse pointer or might refer to the pixel pointed-to by
  1428.           the mouse pointer. Test this if you are trying to read the
  1429.           pixel color using get_pixel. You may have to read x-1,y-1
  1430.           instead.
  1431.  
  1432.  Example:     a return value of:
  1433.          
  1434.          {2, 100, 50} 
  1435.            
  1436.            would indicate that the left button was pressed down while the
  1437.            mouse pointer was at position x=100, y=50 on the screen.     
  1438.  
  1439.  See Also:    mouse_events, mouse_pointer
  1440.  
  1441. ──────────────────────────────────<get_pixel>───────────────────────────────────
  1442.  
  1443.  Syntax:      include graphics.e
  1444.            x = get_pixel(s)
  1445.     
  1446.  Description: When s is a 2-element screen coordinate {x, y}, get_pixel() 
  1447.            returns the color of the pixel on the pixel-graphics screen 
  1448.            at that point. 
  1449.            
  1450.            When s is a 3-element sequence of the form: {x, y, n}
  1451.            get_pixel() returns a sequence of n color values for the
  1452.            points starting at {x, y} and moving to the right {x+1, y},
  1453.            {x+2, y} etc.
  1454.  
  1455.            Points off the screen have unpredictable color values.
  1456.  
  1457.  Comments:    When n is specified, a very fast algorithm is used to read the
  1458.            pixel colors on the screen. It is much faster to call get_pixel() 
  1459.            once, specifying a large value of n, than it is to call it many
  1460.            times, reading one pixel color at a time.
  1461.  
  1462.  Example:     object x
  1463.      
  1464.            x = get_pixel({30,40})
  1465.            -- x is set to the color value of point x=30, y=40
  1466.            
  1467.            x = get_pixel({30,40,100})
  1468.            -- x is set to a sequence of 100 integer values, representing
  1469.            -- the colors starting at {30,40} and going to the right
  1470.  
  1471.  See Also:    pixel, graphics_mode, get_position
  1472.  
  1473. ─────────────────────────────────<get_position>─────────────────────────────────
  1474.  
  1475.  Syntax:      include graphics.e
  1476.            s = get_position()
  1477.      
  1478.  Description: Return the current line and column position of the cursor as a 
  1479.            2-element sequence {line, column}.
  1480.  
  1481.  Comments:    In pixel-graphics modes no cursor will be displayed, but
  1482.               get_position() will return the line and column where the
  1483.               next character will be displayed.
  1484.  
  1485.               The coordinate system for displaying text is different from the 
  1486.               one for displaying pixels. Pixels are displayed such that the 
  1487.               top-left is (x=0,y=0) and the first coordinate controls the 
  1488.               horizontal, left-right location. In pixel-graphics modes
  1489.               you can display both text and pixels. get_position() returns the 
  1490.               current line and column for the text that you are displaying, 
  1491.               not the pixels that you may be plotting. There is no 
  1492.               corresponding routine for getting the current pixel position.
  1493.  
  1494.  See Also:    position, get_pixel
  1495.  
  1496. ──────────────────────────────────<get_vector>──────────────────────────────────
  1497.  
  1498.  Syntax:      include machine.e
  1499.               s = get_vector(i)
  1500.  
  1501.  Description: Return the current protected mode far address of the handler 
  1502.               for interrupt number i. s will be a 2-element sequence:
  1503.               {16-bit segment, 32-bit offset}.
  1504.               
  1505.  Example:     s = get_vector(#1C)
  1506.               -- s will be set to the far address of the clock tick 
  1507.               -- interrupt handler, for example: {59, 808}
  1508.  
  1509.  Example Program: demo\hardint.ex
  1510.  
  1511.  See Also:    set_vector, lock_memory
  1512.  
  1513. ─────────────────────────────────────<getc>─────────────────────────────────────
  1514.  
  1515.  Syntax:      i = getc(fn)
  1516.     
  1517.  Description: Get the next character (byte) from file fn. -1 is returned at end 
  1518.           of file.
  1519.           
  1520.  Comments:    File input using getc is buffered, i.e. getc does not actually 
  1521.            go out to the disk for each character. Instead, a large block of 
  1522.            characters will be read in at one time and returned to you one 
  1523.            by one from a memory buffer.
  1524.            
  1525.  See Also:    gets, get_key, wait_key, open
  1526.  
  1527. ────────────────────────────────────<getenv>────────────────────────────────────
  1528.  
  1529.  Syntax:      x = getenv(s)
  1530.     
  1531.  Description: Return the value of a DOS environment variable. If the variable
  1532.             is undefined return -1.
  1533.     
  1534.  Example:     e = getenv("EUDIR")
  1535.           -- e will be "C:\EUPHORIA" -- or perhaps D:, E: etc.
  1536.  
  1537.  Comments:    Because either a sequence or an atom (-1) might be returned, you 
  1538.            should probably assign the result to a variable declared as 
  1539.            object.
  1540.  
  1541.  See Also:    command_line
  1542.            
  1543. ─────────────────────────────────────<gets>─────────────────────────────────────
  1544.  
  1545.  Syntax:      x = gets(fn)
  1546.     
  1547.  Description: Get the next sequence (one line, including '\n') of characters 
  1548.            from file fn. The atom -1 is returned on end of file. 
  1549.           
  1550.  Comments:    Because either a sequence or an atom (-1) might be returned, you 
  1551.            should probably assign the result to a variable declared as 
  1552.            object.
  1553.  
  1554.            The last line in a file might not end with a new-line '\n' 
  1555.            character.
  1556.  
  1557.  Example:
  1558.           sequence buffer
  1559.           object line
  1560.         
  1561.           -- read a text file into a sequence
  1562.           buffer = {}
  1563.           while 1 do
  1564.                line = gets(0)
  1565.                if atom(line) then
  1566.               exit   -- end of file
  1567.                end if
  1568.                buffer = append(buffer, line)
  1569.           end while
  1570.  
  1571.  See Also:    getc, puts, open
  1572.  
  1573. ────────────────────────────────<graphics_mode>─────────────────────────────────
  1574.  
  1575.  Syntax:      include graphics.e
  1576.            i1 = graphics_mode(i2)
  1577.     
  1578.  Description: Select graphics mode i2. See graphics.e for a list of valid 
  1579.           graphics modes. If successful, i1 is set to 0, otherwise i1
  1580.           is set to 1.
  1581.  
  1582.  Comment:     Some modes are referred to as "text" modes because they only
  1583.            let you display text. Other modes are referred to as 
  1584.            "pixel-graphics" modes because you can display pixels, lines, 
  1585.            ellipses etc., as well as text.
  1586.             
  1587.            As a convenience to your users, it is usually a good idea to 
  1588.            switch back from a pixel-graphics mode to the standard text 
  1589.            mode before your program terminates. You can do this with 
  1590.            graphics_mode(-1). If a pixel-graphics program leaves your screen
  1591.            in a mess, you can clear it up with the DOS CLS command, or
  1592.            by running ex or ed.
  1593.            
  1594.  Example:     if graphics_mode(18) then
  1595.                puts(SCREEN, "need VGA graphics!\n")
  1596.                  abort(1)
  1597.            end if
  1598.            draw_line(BLUE, {{0,0}, {50,50}})
  1599.  
  1600.  See Also:    text_rows, video_config
  1601.  
  1602. ─────────────────────────────────<int_to_bits>──────────────────────────────────
  1603.  
  1604.  Syntax:      include machine.e
  1605.            s = int_to_bits(a, i)
  1606.  
  1607.  Description: Returns the low-order i bits of a, as a sequence of 1's and 0's.
  1608.            The least significant bits come first. For negative numbers
  1609.            the two's complement bit pattern is returned.
  1610.            
  1611.  Comments:    You can use subscripting, slicing, and/or/not of entire 
  1612.            sequences etc. to manipulate sequences of bits. Shifting 
  1613.            of bits and rotating of bits are easy to perform.
  1614.  
  1615.  Example:     s = int_to_bits(177, 8)
  1616.            -- s is {1,0,0,0,1,1,0,1} -- "reverse" order
  1617.             
  1618.  See Also:    bits_to_int, and_bits, or_bits, xor_bits, not_bits,
  1619.               and/or/not of entire sequences in refman.doc
  1620.  
  1621. ─────────────────────────────────<int_to_bytes>─────────────────────────────────
  1622.  
  1623.  Syntax:      include machine.e
  1624.            s = int_to_bytes(a)
  1625.     
  1626.  Description: Convert an integer into a sequence of 4 bytes. These bytes are in
  1627.           the order expected on the 386+, i.e. least significant byte 
  1628.           first.
  1629.     
  1630.  Comments:    You might use this routine prior to poking the 4 bytes into 
  1631.            memory for use by a machine language program.
  1632.      
  1633.           The integer can be negative. Negative byte-values will be
  1634.           returned, but after poking them into memory you will have 
  1635.           the correct (two's complement) representation for the 386+.
  1636.            
  1637.            This function will correctly convert integer values up to 
  1638.            32-bits. For larger values, only the low-order 32-bits are
  1639.            converted. Euphoria's integer type only allows values up to
  1640.            31-bits, so declare your variables as atom if you need a
  1641.            larger range.
  1642.            
  1643.  Example 1:   s = int_to_bytes(999)
  1644.            -- s is {231, 3, 0, 0}
  1645.  
  1646.  Example 2:   s = int_to_bytes(-999)
  1647.            -- s is {-231, -4, -1, -1}
  1648.            
  1649.  See Also:    bytes_to_int, int_to_bits, bits_to_int, peek, poke
  1650.  
  1651. ───────────────────────────────────<integer>────────────────────────────────────
  1652.                   
  1653.  Syntax:      i = integer(x)
  1654.     
  1655.  Description: Return 1 if x is an integer in the range -1073741824 to 
  1656.            +1073741823. Otherwise return 0.  
  1657.  
  1658.  Comments:    This serves to define the integer type. You can also call it 
  1659.            like an ordinary function to determine if an object is an
  1660.            integer.
  1661.       
  1662.  Example 1:   integer z
  1663.            z = -1
  1664.            
  1665.  Example 2:   if integer(y/x) then
  1666.                puts(SCREEN, "y is an exact multiple of x")
  1667.            end if
  1668.  
  1669.  See Also:    atom, sequence, floor
  1670.  
  1671. ────────────────────────────────────<length>────────────────────────────────────
  1672.  
  1673.  Syntax:      i = length(s)
  1674.     
  1675.  Description: Return the length of s. s must be a sequence. An error will
  1676.            occur if s is an atom.
  1677.  
  1678.  Comments:    The length of each sequence is stored internally by the
  1679.            interpreter for quick access. (In other languages this
  1680.            operation requires a search through memory for an end marker.)
  1681.         
  1682.  Example 1:   length({{1,2}, {3,4}, {5,6}})   -- 3
  1683.  
  1684.  Example 2:   length("")    -- 0
  1685.  
  1686.  Example 3:   length({})    -- 0
  1687.  
  1688.  See Also: sequence
  1689.  
  1690. ─────────────────────────────────<lock_memory>──────────────────────────────────
  1691.  
  1692.  Syntax:      include machine.e
  1693.               lock_memory(a, i)
  1694.  
  1695.  Description: Prevent the block of virtual memory starting at address a, 
  1696.               of length i, from ever being swapped out to disk. 
  1697.               
  1698.  Comments:    Use this to ensure that all code and data required for
  1699.               handling interrupts is kept in memory at all times
  1700.               while your program is running.
  1701.  
  1702.  Example Program: demo\hardint.ex
  1703.  
  1704.  See Also:    get_vector, set_vector
  1705.   
  1706. ─────────────────────────────────────<log>──────────────────────────────────────
  1707.  
  1708.  Syntax:      x2 = log(x1)
  1709.     
  1710.  Description: Return the natural logarithm of x1.
  1711.  
  1712.  Comments:    This function may be applied to an atom or to all elements
  1713.            of a sequence. Note that log is only defined for positive
  1714.            numbers. Your program will abort with a message if you
  1715.            try to take the log of a negative number or zero.
  1716.  
  1717.  Example:     a = log(100)
  1718.            -- a is 4.60517
  1719.  
  1720.  See Also:    sin, cos, tan, sqrt
  1721.  
  1722. ────────────────────────────────────<lower>─────────────────────────────────────
  1723.  
  1724.  Syntax:      include wildcard.e
  1725.            x2 = lower(x1)
  1726.  
  1727.  Description: Convert an atom or sequence to lower case.
  1728.  
  1729.  Example:     s = lower("Euphoria")
  1730.            -- s is "euphoria"
  1731.            
  1732.            a = lower('B')
  1733.            -- a is 'b'
  1734.            
  1735.            s = lower({"Euphoria", "Programming"})
  1736.            -- s is {"euphoria", "programming"}
  1737.  
  1738.  See Also:    upper
  1739.  
  1740. ─────────────────────────────────<machine_func>─────────────────────────────────
  1741.  
  1742.  Syntax:      x1 = machine_func(a, x)
  1743.  
  1744.  Description: see machine_proc() below
  1745.  
  1746. ─────────────────────────────────<machine_proc>─────────────────────────────────
  1747.  
  1748.  Syntax:      machine_proc(a, x) 
  1749.     
  1750.  Description: Perform a machine-specific operation such as graphics and sound
  1751.             effects. This routine should normally be called indirectly via 
  1752.             one of the library routines in a Euphoria include file. A direct
  1753.             call can cause a machine exception if done incorrectly.
  1754.  
  1755.  See Also:    machine_func
  1756.  
  1757. ────────────────────────────────────<match>─────────────────────────────────────
  1758.  
  1759.  Syntax:      i = match(s1, s2)
  1760.  
  1761.  Description: Try to match s1 against some slice of s2. If successful, return 
  1762.           the element number of s2 where the (first) matching slice begins, 
  1763.           else return 0. 
  1764.           
  1765.  Example:     location = match("pho", "Euphoria")
  1766.           -- location is set to 3
  1767.  
  1768.  See Also:    find, compare, wildcard_match
  1769.  
  1770. ───────────────────────────────────<mem_copy>───────────────────────────────────
  1771.  
  1772.  Syntax:      include machine.e
  1773.               mem_copy(a1, a2, i)
  1774.               
  1775.  Description: Copy a block of i bytes of memory from address a2 to address a1. 
  1776.  
  1777.  Comments:    The bytes of memory will be copied correctly even if the block 
  1778.               of memory at a2 overlaps with the block of memory at a1.
  1779.  
  1780.               mem_copy(a1, a2, i) is equivalent to: poke(a1, peek({a2, i})) 
  1781.               but is faster for i > 6, and is more than 10 times faster for 
  1782.               i > 1000.
  1783.  
  1784.  Example:     dest = allocate(50)
  1785.               src = allocate(100)
  1786.               poke(src, {1,2,3,4,5,6,7,8,9})
  1787.               mem_copy(dest, src, 9)
  1788.  
  1789.  See Also:    mem_set, peek, poke, allocate, allocate_low
  1790.  
  1791. ───────────────────────────────────<mem_set>────────────────────────────────────
  1792.  
  1793.  Syntax:      include machine.e
  1794.               mem_set(a1, i1, i2)
  1795.               
  1796.  Description: Set i2 bytes of memory, starting at address a1, to the value 
  1797.               of i1.
  1798.  
  1799.  Comments:    The low order 8 bits of i1 are actually stored in each byte.
  1800.  
  1801.               mem_set(a1, i1, i2) is equivalent to: poke(a1, repeat(i1, i2))
  1802.               but is faster for i2 > 12, and is more than 25 times faster for
  1803.               i2 > 1000.
  1804.  
  1805.  Example:     destination = allocate(1000)
  1806.               mem_set(destination, ' ', 1000)
  1807.  
  1808.  See Also:    mem_copy, peek, poke, allocate, allocate_low
  1809.  
  1810. ─────────────────────────────────<mouse_events>─────────────────────────────────
  1811.  
  1812.  Syntax:      include mouse.e
  1813.            mouse_events(i) 
  1814.     
  1815.  Description: Use this procedure to select the mouse events that you want 
  1816.           get_mouse() to report. By default, get_mouse() will report all
  1817.           events. mouse_events() can be called at various stages of the 
  1818.           execution of your program, as the need to detect events changes.
  1819.  
  1820.  Comments:    It is good practice to ignore events that you are not interested
  1821.               in, particularly the very frequent MOVE event, in order to reduce
  1822.               the chance that you will miss a significant event.
  1823.  
  1824.             The first call that you make to mouse_events() will turn on a
  1825.             mouse pointer, or a highlighted character.
  1826.  
  1827.  Example:     mouse_events(LEFT_DOWN + LEFT_UP + RIGHT_DOWN) 
  1828.            -- will restrict get_mouse() to reporting the left button 
  1829.              being pressed down or released, and the right button 
  1830.              being pressed down. All other events will be ignored. 
  1831.  
  1832.  See Also:    get_mouse, mouse_pointer
  1833.  
  1834. ────────────────────────────────<mouse_pointer>─────────────────────────────────
  1835.  
  1836.  Syntax:      include mouse.e
  1837.            mouse_pointer(i)
  1838.     
  1839.  Description: If i is 0 hide the mouse pointer, otherwise turn on the mouse 
  1840.            pointer. Multiple calls to hide the pointer will require
  1841.           multiple calls to turn it back on. The first call to either 
  1842.           get_mouse() or mouse_events() above, will also turn the pointer
  1843.           on (once).
  1844.     
  1845.  Comments:    It may be necessary to hide the mouse pointer temporarily when
  1846.             you update the screen. 
  1847.  
  1848.               After a call to text_rows() you may have to call mouse_pointer(1) 
  1849.               to see the mouse pointer again.
  1850.               
  1851.  See Also:    get_mouse, mouse_events
  1852.  
  1853. ───────────────────────────────────<not_bits>───────────────────────────────────
  1854.  
  1855.  Syntax:      x2 = not_bits(x1)
  1856.  
  1857.  Description: Perform the logical NOT operation on each bit in x1.
  1858.               A bit in x2 will be 1 when the corresponding bit in x1
  1859.               is 0, and will be 0 when the corresponding bit in x1 is 1.
  1860.               
  1861.  Comments:    The argument to this function may be an atom or a sequence. 
  1862.            The rules for arithmetic operations on sequences apply.
  1863.  
  1864.           The argument must be representable as a 32-bit number,
  1865.           either signed or unsigned.
  1866.           
  1867.           If you intend to manipulate full 32-bit values, you should
  1868.           declare your variables as atom, rather than integer. Euphoria's
  1869.           integer type is limited to 31-bits.
  1870.  
  1871.               Results are treated as signed numbers. They will be
  1872.               negative when the highest-order bit is 1.
  1873.               
  1874.  Example:     a = not_bits(#000000F7)
  1875.               -- a is -248 (i.e. FFFFFF08 interpreted as a negative number)
  1876.  
  1877.  See Also:    and_bits, or_bits, xor_bits, int_to_bits
  1878.  
  1879. ─────────────────────────────────────<open>─────────────────────────────────────
  1880.  
  1881.  Syntax:      fn = open(s1, s2)
  1882.     
  1883.  Description: Open a file or device, to get the file number. -1 is returned if
  1884.             the open fails. s1 is the path name of the file or device.  s2 is
  1885.             the mode in which the file is to be opened. Possible modes are:
  1886.           
  1887.           "r"  - open text file for reading
  1888.           "rb" - open binary file for reading
  1889.           "w"  - create text file for writing
  1890.           "wb" - create binary file for writing
  1891.           "u"  - open text file for update (reading and writing)
  1892.           "ub" - open binary file for update
  1893.           "a"  - open text file for appending
  1894.           "ab" - open binary file for appending
  1895.  
  1896.           Files opened for read or update must already exist. Files opened
  1897.           for write or append will be created if necessary. A file opened 
  1898.           for write will be set to 0 bytes. Output to a file opened for
  1899.           append will start at the end of file.
  1900.  
  1901.           Output to text files will have carriage-return characters 
  1902.           automatically added before linefeed characters. On input, these 
  1903.           carriage-return characters are removed. A control-z character 
  1904.           (ASCII 26) will signal an immediate end of file. 
  1905.     
  1906.           I/O to binary files is not modified in any way. Any byte values 
  1907.           from 0 to 255 can be read or written.
  1908.  
  1909.           Some typical devices that you can open are:
  1910.           
  1911.           "CON"    the console (screen)
  1912.           "AUX"    the serial auxiliary port 
  1913.           "COM1"   serial port 1
  1914.           "COM2"   serial port 2
  1915.           "PRN"    the printer on the parallel port
  1916.           "NUL"    a non-existent device that accepts and discards output 
  1917.  
  1918.  Comment:     When running under Windows 95, you can open any existing file
  1919.            that has a long file or directory name in its path (i.e. greater
  1920.            than the standard DOS 8.3 format) using any open mode - read, 
  1921.            write etc. However, if you try to create a *new* file (open with 
  1922.            "w" or "a" and the file does not already exist) then the name 
  1923.            will be truncated if necessary to an 8.3 style name. We hope to 
  1924.            support creation of new long-filename files in a future release.
  1925.            
  1926.  Example:     integer file_num, file_num95
  1927.            sequence first_line
  1928.            constant ERROR = 2
  1929.            
  1930.            file_num = open("myfile", "r")
  1931.           if file_num = -1 then           
  1932.                  puts(ERROR, "couldn't open myfile\n")
  1933.            else
  1934.                first_line = gets(file_num)
  1935.            end if
  1936.            
  1937.            file_num = open("PRN", "w") -- open printer for output
  1938.            
  1939.            -- on Windows 95:
  1940.            file_num95 = open("bigdirectoryname\\verylongfilename.abcdefg", 
  1941.                        "r")
  1942.            if file_num95 != -1 then
  1943.            puts(1, "it worked!\n")
  1944.            end if
  1945.  
  1946.  See Also:    close
  1947.  
  1948. ───────────────────────────────────<or_bits>────────────────────────────────────
  1949.  
  1950.  Syntax:      x3 = or_bits(x1, x2)
  1951.  
  1952.  Description: Perform the logical OR operation on corresponding bits in
  1953.               x1 and x2. A bit in x3 will be 1 when a corresponding
  1954.               bit in either x1 or x2 is 1.
  1955.               
  1956.  Comments:    The arguments to this function may be atoms or sequences. The
  1957.            rules for arithmetic operations on sequences apply.
  1958.  
  1959.           The arguments must be representable as 32-bit numbers,
  1960.           either signed or unsigned.
  1961.           
  1962.           If you intend to manipulate full 32-bit values, you should
  1963.           declare your variables as atom, rather than integer. Euphoria's
  1964.           integer type is limited to 31-bits.
  1965.  
  1966.               Results are treated as signed numbers. They will be
  1967.               negative when the highest-order bit is 1.
  1968.               
  1969.  Example 1:   a = or_bits(#0F0F0000, #12345678)
  1970.               -- a is #1F3F5678
  1971.  
  1972.  Example 2:   a = or_bits(#FF, {#123456, #876543, #2211})
  1973.               -- a is {#1234FF, #8765FF, #22FF}
  1974.  
  1975.  See Also:    and_bits, xor_bits, not_bits, int_to_bits
  1976.  
  1977. ───────────────────────────────────<palette>────────────────────────────────────
  1978.  
  1979.  Syntax:      include graphics.e     
  1980.            x = palette(i, s)
  1981.     
  1982.  Description: Change the color for color number i to s, where s is a sequence 
  1983.            of color intensities: {red, green, blue}. Each value in s can be
  1984.            from 0 to 63. If successful, a 3-element sequence containing the 
  1985.           previous color for i will be returned, and all pixels on the 
  1986.           screen with value i will be set to the new color. If 
  1987.           unsuccessful, the atom -1 will be returned. 
  1988.  Example:     
  1989.            x = palette(0, {15, 40, 10})
  1990.            -- color number 0 (normally black) is changed to a shade 
  1991.               of mainly green. 
  1992.            
  1993.  See Also:    all_palette 
  1994.  
  1995. ─────────────────────────────────────<peek>─────────────────────────────────────
  1996.  
  1997.  Syntax:      i = peek(a)
  1998.   or ...      s = peek({a, i})
  1999.        
  2000.  Description: Return a single byte value in the range 0 to 255 from machine 
  2001.            address a, or return a sequence containing i consecutive byte
  2002.            values starting at address a in memory.
  2003.  
  2004.  Comments:    Since addresses are 32-bit numbers, they can be larger than
  2005.            the largest value of type integer (31-bits). Variables that 
  2006.            hold an address should therefore be declared as atoms.
  2007.  
  2008.            It is faster to read several bytes at once using the second
  2009.            form of peek() than it is to read one byte at a time in a
  2010.            loop.
  2011.  
  2012.            Remember that peek takes just one argument, which in the
  2013.            second form is actually a 2-element sequence.
  2014.            
  2015.  Example:     The following are equivalent:
  2016.            
  2017.            -- method 1
  2018.            s = {peek(100), peek(101), peek(102), peek(103)}
  2019.            
  2020.            -- method 2
  2021.            s = peek({100, 4})
  2022.  
  2023.  See Also:    poke, allocate, free, allocate_low, free_low, call
  2024.  
  2025. ────────────────────────────────────<pixel>─────────────────────────────────────
  2026.  
  2027.  Syntax:      include graphics.e
  2028.            pixel(x1, s) 
  2029.     
  2030.  Description: Set one or more pixels on a pixel-graphics screen starting at 
  2031.               point s, where s is a 2-element screen coordinate {x, y}. If x1 
  2032.               is an atom, one pixel will be set to the color indicated by x1. 
  2033.               If x1 is a sequence then a number of pixels will be set, starting 
  2034.               at s and moving to the right (increasing x value, same y value).
  2035.  
  2036.  Comments:    When x1 is a sequence, a very fast algorithm is used to put the
  2037.            pixels on the screen. It is much faster to call pixel() once,
  2038.            with a sequence of pixel colors, than it is to call it many
  2039.            times, plotting one pixel color at a time.
  2040.            
  2041.  Example 1:   pixel(BLUE, {50, 60})
  2042.           -- the point {50,60} is set to the color BLUE    
  2043.  
  2044.  Example 2:   pixel({BLUE, GREEN, WHITE, RED}, {50,60})
  2045.            -- {50,60} set to BLUE
  2046.            -- {51,60} set to GREEN
  2047.            -- {52,60} set to WHITE
  2048.            -- {53,60} set to RED
  2049.  
  2050.  See Also:    get_pixel, graphics_mode
  2051.  
  2052. ─────────────────────────────────────<poke>─────────────────────────────────────
  2053.  
  2054.  Syntax:      poke(a, x)
  2055.   
  2056.  Description: If x is an atom, write a single byte value to memory address a. 
  2057.            
  2058.            If x is a sequence, write a sequence of byte values to 
  2059.            consecutive memory locations starting at location a.
  2060.           
  2061.  Comments:    The lower 8-bits of each byte value, i.e. remainder(value, 256), 
  2062.            is actually stored in memory. 
  2063.  
  2064.            It is faster to write several bytes at once by poking a sequence
  2065.            of values, than it is to write one byte at a time in a loop.
  2066.  
  2067.            Writing to the screen memory with poke() can be much faster than 
  2068.            using puts() or printf(), but the programming is more difficult. 
  2069.            In most cases the speed is not needed. For example, the Euphoria
  2070.            editor never uses poke().
  2071.  
  2072.  Example:     a = allocate(100)   -- allocate 100 bytes in memory
  2073.               
  2074.               -- poke one byte at a time:
  2075.               poke(a, 97)         
  2076.               poke(a+1, 98)
  2077.               poke(a+2, 99)
  2078.               
  2079.               -- poke 3 bytes at once:
  2080.               poke(a, {97, 98, 99})
  2081.  
  2082.  Example Program: see demo\callmach.ex
  2083.  
  2084.  See Also:    peek, allocate, free, allocate_low, free_low, call
  2085.  
  2086. ───────────────────────────────────<polygon>────────────────────────────────────
  2087.  
  2088.  Syntax:      include graphics.e
  2089.            polygon(i1, i2, s)
  2090.     
  2091.  Description: Draw a polygon with 3 or more vertices given in s, on a 
  2092.               pixel-graphics screen using a certain color i1. Fill the area if 
  2093.               i2 is 1. Don't fill if i2 is 0. 
  2094.  
  2095.  Example:     polygon(GREEN, 1, {{100, 100}, {200, 200}, {900, 700}})
  2096.           -- makes a solid green triangle.
  2097.  
  2098.  See Also:    draw_line, ellipse
  2099.  
  2100. ───────────────────────────────────<position>───────────────────────────────────
  2101.  
  2102.  Syntax:      position(i1, i2)
  2103.     
  2104.  Description: Set the cursor to line i1, column i2, where the top left corner 
  2105.           of the screen is line 1, column 1. The next character displayed 
  2106.           on the screen will be printed at this location. position() will 
  2107.           report an error if the location is off the screen. 
  2108.  
  2109.  Comments:    The coordinate system for displaying text is different from the 
  2110.               one for displaying pixels. Pixels are displayed such that the 
  2111.               top-left is (x=0,y=0) and the first coordinate controls the 
  2112.               horizontal, left-right location. In pixel-graphics modes
  2113.               you can display both text and pixels. position() only sets the 
  2114.               line and column for the text that you display, not the pixels 
  2115.               that you plot. There is no corresponding routine for setting 
  2116.               the next pixel position.
  2117.  
  2118.  Example:     position(2,1)
  2119.            -- the cursor moves to the beginning of the second line from 
  2120.               the top 
  2121.  
  2122.  See Also:    get_position, puts, print, printf
  2123.  
  2124. ────────────────────────────────────<power>─────────────────────────────────────
  2125.  
  2126.  Syntax:      x3 = power(x1, x2)
  2127.  
  2128.  Description: Raise x1 to the power x2
  2129.  
  2130.  Comments:    The arguments to this functions may be atoms or sequences. The
  2131.            rules for arithmetic operations on sequences apply.
  2132.  
  2133.            Powers of 2 are calculated very efficiently.
  2134.  
  2135.  Example 1:   ? power(5, 2)
  2136.            -- 25 is printed
  2137.  
  2138.  Example 2:   ? power({5, 4, 3.5}, {2, 1, -0.5})  
  2139.            -- {25, 4, 0.534522} is printed
  2140.  
  2141.  Example 3:   ? power(2, {1, 2, 3, 4})
  2142.            -- {2, 4, 8, 16}
  2143.  
  2144.  Example 4:   ? power({1, 2, 3, 4}, 2)
  2145.            -- {1, 4, 9, 16}
  2146.            
  2147.  See Also:    log, sqrt
  2148.  
  2149. ───────────────────────────────────<prepend>────────────────────────────────────
  2150.  
  2151.  Syntax:      s2 = prepend(s1, x)
  2152.     
  2153.  Description: Prepend x to the start of sequence s1. The length of s2 will be 
  2154.           length(s1) + 1. 
  2155.           
  2156.  Comments:    If x is an atom this is the same as s2 = x & s1. If x is a 
  2157.            sequence it is definitely not the same. e.g.
  2158.     
  2159.          prepend({1,2,3}, {0,0})    
  2160.              -- {{0,0}, 1, 2, 3}
  2161.  
  2162.          {0,0} & {1,2,3}        
  2163.                 -- {0, 0, 1, 2, 3}
  2164.  
  2165.            The case where s1 and s2 are the same variable is handled
  2166.            very efficiently.
  2167.  
  2168.  Example:     s = {}
  2169.            for i = 1 to 10 do
  2170.            s = prepend(s, i)
  2171.             end for
  2172.             -- s is {10,9,8,7,6,5,4,3,2,1}
  2173.             
  2174.  See Also:    append, concatenation (&) and sequence-formation {,,} operators 
  2175.            in refman.doc
  2176.  
  2177. ────────────────────────────────────<print>─────────────────────────────────────
  2178.  
  2179.  Syntax:      print(fn, x)
  2180.     
  2181.  Description: Print, to file or device fn, an object x with braces { , , , } 
  2182.            to show the structure.
  2183.           
  2184.  Comment:     If you want to see a string of characters, rather than just the 
  2185.           ASCII codes, you need to use puts or printf. 
  2186.  
  2187.  Example 1:   print(1, "ABC")  -- output is:  {65, 66, 67}
  2188.            puts(1, "ABC")   -- output is:  ABC
  2189.  
  2190.  Example 2:   print(1, repeat({10,20}, 3))
  2191.            -- output is: {{10,20},{10,20},{10,20}}
  2192.            
  2193.  See Also:    ?, puts, printf, get
  2194.  
  2195. ────────────────────────────────────<printf>────────────────────────────────────
  2196.  
  2197.  Syntax:      printf(fn, st, x)
  2198.     
  2199.  Description: Print x, to file or device fn, using format string st. If x is 
  2200.            an atom then a single value will be printed. If x is a sequence, 
  2201.            then formats from st are applied to successive elements of x. 
  2202.            Thus printf always takes exactly 3 arguments. Only the length of 
  2203.            the last argument, containing the values to be printed, will 
  2204.            vary. The basic formats are: 
  2205.           
  2206.           %d - print an atom as a decimal integer
  2207.           %x - print an atom as a hexadecimal integer
  2208.           %o - print an atom as an octal integer
  2209.           %s - print a sequence as a string of characters
  2210.           %e - print an atom as a floating point number with exponential 
  2211.                  notation
  2212.           %f - print an atom as a floating-point number with a decimal
  2213.                point but no exponent
  2214.           %g - print an atom as a floating point number using either
  2215.              the %f or %e format, whichever seems more appropriate
  2216.           %% - print the '%' character itself
  2217.  
  2218.           Field widths can be added to the basic formats, e.g. %5d, or 
  2219.           %8.2f. The number before the decimal point is the minimum field
  2220.           width to be used. The number after the decimal point is the 
  2221.           precision to be used.
  2222.  
  2223.           If the field width is negative, e.g. %-5d then the value will be 
  2224.           left-justified within the field. Normally it will be right-
  2225.           justified. If the field width starts with a leading 0, e.g. %08d
  2226.           then leading zeros will be supplied to fill up the field. If the
  2227.           field width starts with a '+' e.g. %+7d then a plus sign will be
  2228.           printed for positive values. 
  2229.  
  2230.  Example 1:   rate = 7.875
  2231.           printf(myfile, "The interest rate is: %8.2f\n", rate)
  2232.           
  2233.           The interest rate is:     7.88
  2234.  
  2235.  Example 2:   name="John Smith"
  2236.           score=97
  2237.           printf(1, "%15s, %5d\n", {name, score})
  2238.  
  2239.                John Smith,    97
  2240.                
  2241.  Comments:    Watch out for the following common mistake:
  2242.  
  2243.              printf(1, "%s", name)
  2244.  
  2245.           This will print only the first character of name, as each element 
  2246.           of name is taken to be a separate value to be formatted. You must 
  2247.           say this instead:
  2248.  
  2249.              printf(1, "%s", {name})
  2250.  
  2251.            Now, the third argument of printf is a one-element sequence
  2252.            containing a single value to be formatted.
  2253.  
  2254.  See Also:    sprintf, puts, open         
  2255.  
  2256. ─────────────────────────────────────<puts>─────────────────────────────────────
  2257.  
  2258.  Syntax:      puts(fn, x)
  2259.     
  2260.  Description: Output, to file or device fn, a single byte (atom) or sequence 
  2261.            of bytes. The low order 8-bits of each value is actually sent 
  2262.            out. If fn is the screen you will see text characters displayed.
  2263.  
  2264.  Comment:     When you output a sequence of bytes it must not have any 
  2265.            (sub)sequences within it. It must be a sequence of atoms only.
  2266.            (Typically a string of ASCII codes).
  2267.            
  2268.  Example 1:   puts(SCREEN, "Enter your first name: ")
  2269.  
  2270.  Example 2:   puts(output, 'A')  -- the single byte 65 will be sent to output  
  2271.  
  2272.  See Also:    printf, gets, open
  2273.  
  2274. ─────────────────────────────────────<rand>─────────────────────────────────────
  2275.  
  2276.  Syntax:      x2 = rand(x1) 
  2277.     
  2278.  Description: Return a random integer from 1 to x1, where x1 may be from 1 to 
  2279.           the largest positive value of type integer (1073741823).
  2280.  
  2281.  Comments:    This function may be applied to an atom or to all elements
  2282.            of a sequence.
  2283.  
  2284.  Example:     s = rand({10, 20, 30})
  2285.            -- s might be: {5, 17, 23} or {9, 3, 12} etc.
  2286.  
  2287.  See Also:    set_rand
  2288.  
  2289. ─────────────────────────────────<read_bitmap>──────────────────────────────────
  2290.  
  2291.  Syntax:      include image.e
  2292.            x = read_bitmap(st)
  2293.  
  2294.  Description: st is the name of a .BMP "bitmap" file. The file should be in
  2295.            the bitmap format. The most common variations of the format
  2296.            are supported. If the file is read successfully the result will
  2297.            be a 2-element sequence. The first element is the palette,
  2298.            containing intensity values in the range 0 to 255. The
  2299.            second element is a 2-d sequence of sequences containing a 
  2300.            pixel-graphics image. You can pass the palette to all_palette() 
  2301.            (after dividing it by 4 to scale it). The image can be passed 
  2302.            to display_image().
  2303.           
  2304.           Bitmaps of 2, 4, 16 or 256 colors are supported. If the file is 
  2305.           not in a good format, an error code (atom) is returned instead:
  2306.           
  2307.         global constant BMP_OPEN_FAILED = 1,
  2308.                 BMP_UNEXPECTED_EOF = 2,
  2309.                 BMP_UNSUPPORTED_FORMAT = 3
  2310.           
  2311.  Comments:    You can create your own bitmap picture files using Windows
  2312.            Paintbrush and many other graphics programs. You can then 
  2313.            incorporate these pictures into your Euphoria programs.
  2314.  
  2315.  Example:     x = read_bitmap("c:\\windows\\arcade.bmp")
  2316.            -- note: double backslash needed to get single backslash in
  2317.                       a string
  2318.  
  2319.  Example Program: demo\bitmap.ex
  2320.  
  2321.  See Also:    palette, display_image
  2322.  
  2323. ──────────────────────────────────<remainder>───────────────────────────────────
  2324.  
  2325.  Syntax:      x3 = remainder(x1, x2)
  2326.     
  2327.  Description: Compute the remainder after dividing x1 by x2. The result will 
  2328.            have the same sign as x1, and the magnitude of the result will
  2329.            be less than the magnitude of x2.
  2330.  
  2331.  Comments:    The arguments to this function may be atoms or sequences. The
  2332.            rules for arithmetic operations on sequences apply.
  2333.  
  2334.  Example 1:   a = remainder(9, 4)
  2335.            -- a is 1
  2336.            
  2337.  Example 2:   s = remainder({81, -3.5, -9, 5.5}, {8, -1.7, 2, -4})
  2338.           -- s is {1, -0.1, -1, 1.5}
  2339.  
  2340.  Example 3:   s = remainder({17, 12, 34}, 16)
  2341.            -- s is {1, 12, 2}
  2342.  
  2343.  Example 4:   s = remainder(16, {2, 3, 5})
  2344.            -- s is {0, 1, 1}
  2345.            
  2346. ────────────────────────────────────<repeat>────────────────────────────────────
  2347.  
  2348.  Syntax:      s = repeat(x, a)
  2349.     
  2350.  Description: Create a sequence of length a where each element is x.
  2351.     
  2352.  Comments:    When you repeat a sequence or a floating-point number the
  2353.            interpreter does not actually make multiple copies in memory.
  2354.            Rather, a single copy is "pointed to" a number of times. 
  2355.            
  2356.  Example 1:   repeat(0, 10)      -- {0,0,0,0,0,0,0,0,0,0}
  2357.         
  2358.  Example 2:   repeat("JOHN", 4)  -- {"JOHN", "JOHN", "JOHN", "JOHN"}
  2359.  
  2360.  See Also:    append, prepend, sequence-formation operator {,,} in refman.doc
  2361.  
  2362. ─────────────────────────────────<save_bitmap>──────────────────────────────────
  2363.  
  2364.  Syntax:      include image.e
  2365.           i = save_bitmap(s, st)
  2366.         
  2367.  Description: Create a Windows bitmap (.BMP) file from a 2-element sequence s.
  2368.            st is the name of a .BMP "bitmap" file. s[1] is the palette:
  2369.              
  2370.              {{r,g,b}, {r,g,b}, ..., {r,g,b}}
  2371.            
  2372.            Each red, green, or blue value is in the range 0 to 255. s[2] 
  2373.            is a 2-d sequence of sequences containing a pixel-graphics image.
  2374.            The sequences contained in s[2] must all have the same length. 
  2375.            s is in the same format as the value returned by read_bitmap(). 
  2376.                     
  2377.           The result will be one of the following codes: 
  2378.         
  2379.         global constant
  2380.             BMP_SUCCESS = 0,
  2381.             BMP_OPEN_FAILED = 1,
  2382.             BMP_INVALID_MODE = 4   -- either invalid graphics mode
  2383.                            or invalid argument
  2384.            
  2385.  Comments:    If you use get_all_palette() to get the palette before calling
  2386.            this function, you must multiply the returned intensity values  
  2387.            by 4 before calling save_bitmap().
  2388.  
  2389.            save_bitmap() produces bitmaps of 2, 4, 16, or 256 colors and
  2390.               these can all be read with read_bitmap(). Windows Paintbrush 
  2391.               and some other tools do not support 4-color bitmaps.
  2392.  
  2393.           save_bitmap() works in both pixel-graphics modes and text modes.
  2394.             
  2395.  Example:     paletteData = get_all_palette() * 4 
  2396.               code = save_bitmap({paletteData, imageData}, 
  2397.                               "c:\\example\\a1.bmp")
  2398.  
  2399.  See Also:    save_image, read_bitmap, save_screen, get_all_palette
  2400.  
  2401. ──────────────────────────────────<save_image>──────────────────────────────────
  2402.  
  2403.  Syntax:      include image.e
  2404.            s3 = save_image(s1, s2)
  2405.  
  2406.  Description: Save a rectangular image from a pixel-graphics screen. The result
  2407.            is a 2-d sequence of sequences containing all the pixels
  2408.            in the image. You can redisplay the image using display_image().
  2409.            s1 is a 2-element sequence {x1, y1} specifying the top-left 
  2410.            pixel in the image. s2 is a sequence {x2, y2} specifying the 
  2411.            bottom-right pixel.
  2412.  
  2413.  Comments:    You might use this in a graphical user interface to save a
  2414.            portion of the screen before you display a drop-down menu
  2415.            or dialog box.
  2416.            
  2417.  Example:     s = save_image({0,0}, {50,50})
  2418.            display_image({100,200}, s)
  2419.            display_image({300,400}, s)
  2420.            -- saves a 51x51 square image, then redisplays it at {100,200}
  2421.           -- and at {300,400}
  2422.  
  2423.  See Also:    display_image, save_text_image
  2424.  
  2425. ─────────────────────────────────<save_screen>──────────────────────────────────
  2426.  
  2427.  Syntax:      include image.e
  2428.           i = save_screen(x1, st)
  2429.  
  2430.  Description: Save the whole screen or a rectangular region of the screen as 
  2431.               a Windows bitmap (.BMP) file. To save the whole screen, pass the 
  2432.               integer 0 for x1. To save a rectangular region of the screen,
  2433.               x1 should be a sequence of 2 sequences: 
  2434.                 {{topLeftXPixel, topLeftYPixel},
  2435.              {bottomRightXPixel, bottomRightYPixel}}
  2436.  
  2437.           st is the name of a .BMP "bitmap" file. 
  2438.           
  2439.           The result will be one of the following codes: 
  2440.         
  2441.         global constant
  2442.             BMP_SUCCESS = 0,
  2443.             BMP_OPEN_FAILED = 1,
  2444.             BMP_INVALID_MODE = 4   -- either invalid graphics mode
  2445.                            or invalid argument
  2446.             
  2447.  Comments:    save_screen() produces bitmaps of 2, 4, 16, or 256 colors and
  2448.               these can all be read with read_bitmap(). Windows Paintbrush 
  2449.               and some other tools do not support 4-color bitmaps.
  2450.  
  2451.           save_screen() only works in pixel-graphics modes, not text modes.
  2452.           
  2453.  Example 1:   code = save_screen(0, "c:\\example\\a1.bmp")
  2454.            
  2455.  Example 2:   err = save_screen({{0,0},{200, 15}}, "b1.bmp")
  2456.  
  2457.  See Also:    save_image, read_bitmap
  2458.  
  2459. ───────────────────────────────<save_text_image>────────────────────────────────
  2460.  
  2461.  Syntax:      include image.e
  2462.            s3 = save_text_image(s1, s2)
  2463.  
  2464.  Description: Save a rectangular region of text from a text-mode screen.
  2465.            The result is a sequence of sequences containing ASCII characters
  2466.            and attributes from the screen. You can redisplay this text using 
  2467.            display_text_image(). s1 is a 2-element sequence {line1, column1}
  2468.            specifying the top-left character. s2 is a sequence 
  2469.            {line2, column2} specifying the bottom right character.
  2470.            
  2471.  Comments:    Because the character attributes are also saved, you will get 
  2472.             the correct foreground and background color for each character
  2473.             if you redisplay the text.
  2474.             
  2475.           An attribute byte is made up of two 4-bit fields that 
  2476.           encode the foreground and background color of a character.
  2477.           The high-order 4 bits determine the background color, while
  2478.           the low-order 4 bits determine the foreground color.
  2479.           
  2480.           This routine only works in text modes.
  2481.           
  2482.            You might use this function in a text-mode graphical user 
  2483.            interface to save a portion of the screen before displaying a 
  2484.            drop-down menu, dialog box, alert box etc.
  2485.  
  2486.            If you are flipping video pages, note that this function reads
  2487.            from the current active page.
  2488.            
  2489.  Example:     If the top 2 lines of the screen have: 
  2490.           Hello 
  2491.           World
  2492.            
  2493.            s = save_text_image({1,1}, {2,5})
  2494.            
  2495.            Then s is something like: 
  2496.                    {"H-e-l-l-o-",
  2497.                          "W-o-r-l-d-"}
  2498.            where we have indicated the attribute bytes by '-'
  2499.                
  2500.  See Also:    display_text_image, save_image, set_active_page
  2501.  
  2502. ────────────────────────────────────<scroll>────────────────────────────────────
  2503.  
  2504.  Syntax:      include graphics.e 
  2505.            scroll(i1, i2, i3)
  2506.  
  2507.  Description: Scroll a region of text on the screen either up (i1 positive) or
  2508.             down (i1 negative) by i1 lines. The region is the series of lines
  2509.           on the screen from i2 (top line) to i3 (bottom line), inclusive.
  2510.           A    new blank line will appear at the top or bottom.
  2511.  
  2512.  Example Program: see bin\ed.ex
  2513.  
  2514.  See Also:    clear_screen, text_rows
  2515.  
  2516. ─────────────────────────────────────<seek>─────────────────────────────────────
  2517.  
  2518.  Syntax:      include file.e
  2519.            i1 = seek(fn, i2)
  2520.  
  2521.  Description: Seek (move) to any byte position in the file fn or to the end of
  2522.             file if i2 is -1. For each open file there is a current byte 
  2523.             position that is updated as a result of I/O operations on the 
  2524.             file. The initial file position is 0 for files opened for read,
  2525.             write or update. The initial position is the end of file for 
  2526.             files opened for append. The value returned by seek() is 0 if the
  2527.             seek was successful, and non-zero if it was unsuccessful. It is 
  2528.             possible to seek past the    end of a file. In this case undefined 
  2529.             bytes will be added to the file to make it long enough for the 
  2530.             seek.
  2531.  
  2532.  See Also:    where, open
  2533.      
  2534. ───────────────────────────────────<sequence>───────────────────────────────────
  2535.  
  2536.  Syntax:      i = sequence(x)
  2537.     
  2538.  Description: Return 1 if x is a sequence else return 0.
  2539.  
  2540.  Comments:    This serves to define the sequence type. You can also call
  2541.            it like an ordinary function to determine if an object is
  2542.            a sequence.
  2543.  
  2544.  Example 1:
  2545.            sequence s
  2546.            s = {1,2,3}
  2547.        
  2548.  Example 2:
  2549.            if sequence(x) then
  2550.                  sum = 0
  2551.                  for i = 1 to length(x) do
  2552.                      sum = sum + x[i]
  2553.                  end for
  2554.            else
  2555.                -- x must be an atom
  2556.                sum = x     
  2557.            end if
  2558.  
  2559.  See Also:    atom, object type in refman.doc
  2560.  
  2561. ───────────────────────────────<set_active_page>────────────────────────────────
  2562.            
  2563.  Syntax:      include image.e
  2564.            set_active_page(i)
  2565.            
  2566.  Description: Select video page i to send all screen output to.           
  2567.  
  2568.  Comments:    With multiple pages you can instantaneously change the entire
  2569.            screen without causing any visible "flicker". You can also
  2570.            save the screen and bring it back quickly.
  2571.  
  2572.           video_config() will tell you how many pages are available in
  2573.           the current graphics mode.
  2574.  
  2575.            By default, the active page and the display page are both 0.
  2576.            
  2577.            This works under DOS, or full-screen under Windows. In a 
  2578.            partial-screen window you cannot change the active page.
  2579.            
  2580.  Example:     include image.e
  2581.            
  2582.            -- active & display pages are initially both 0
  2583.            puts(1, "\nThis is page 0\n")
  2584.            set_active_page(1)     -- screen output will now go to page 1
  2585.            clear_screen()
  2586.            puts(1, "\nNow we've flipped to page 1\n")
  2587.            if getc(0) then        -- wait for key-press
  2588.            end if
  2589.            set_display_page(1)    -- "Now we've ..." becomes visible
  2590.            if getc(0) then        -- wait for key-press
  2591.            end if
  2592.           set_display_page(0)    -- "This is ..." becomes visible again
  2593.           set_active_page(0)
  2594.  
  2595.  See Also:    get_active_page, set_display_page 
  2596.  
  2597. ──────────────────────────────<set_display_page>────────────────────────────────
  2598.            
  2599.  Syntax:      include image.e
  2600.            set_display_page(i)
  2601.  
  2602.  Description: Set video page i to be mapped to the visible screen.
  2603.  
  2604.  Comments:    With multiple pages you can instantaneously change the entire
  2605.            screen without causing any visible "flicker". You can also
  2606.            save the screen and bring it back quickly.
  2607.  
  2608.           video_config() will tell you how many pages are available in
  2609.           the current graphics mode.
  2610.  
  2611.            By default, the active page and the display page are both 0.
  2612.            
  2613.            This works under DOS, or full-screen under Windows. In a 
  2614.            partial-screen window you cannot change the active page.
  2615.            
  2616.  Example:     See set_active_page example.
  2617.  
  2618.  See Also:    get_display_page, set_active_page
  2619.            
  2620. ──────────────────────────────────<set_rand>────────────────────────────────────
  2621.  
  2622.  Syntax:      include machine.e
  2623.            set_rand(a1)
  2624.  
  2625.  Description: Set the random number generator to a certain state, a1, so that
  2626.            you will get a known series of random numbers on subsequent
  2627.            calls to rand(). The lower 32 bits of the value of a1 are
  2628.            used.
  2629.  
  2630.  Comments:    Normally the numbers returned by the rand() function are totally
  2631.             unpredictable, and will be different each time you run your
  2632.             program. Sometimes however you may wish to repeat the same
  2633.             series of numbers, perhaps because you are trying to debug
  2634.             your program, or maybe you want the ability to generate the
  2635.             same output (e.g. a random picture) for your user upon request. 
  2636.  
  2637.  Example:     sequence s, t
  2638.            s = repeat(0, 3)
  2639.            t = s
  2640.            
  2641.            set_rand(12345)
  2642.            s[1] = rand(10)
  2643.            s[2] = rand(100)
  2644.            s[3] = rand(1000)
  2645.            
  2646.            set_rand(12345)  -- same value for set_rand()
  2647.            t[1] = rand(10)  -- same arguments to rand() as before
  2648.            t[2] = rand(100)
  2649.            t[3] = rand(1000)
  2650.            -- at this point s and t will be identical
  2651.  
  2652.  See Also:    rand
  2653.  
  2654. ──────────────────────────────────<set_vector>──────────────────────────────────
  2655.  
  2656.  Syntax:      include machine.e
  2657.               set_vector(i, s)
  2658.  
  2659.  Description: Set s as the new address for handling interrupt number i.
  2660.               s must be a protected mode far address in the form:
  2661.               {16-bit segment, 32-bit offset}.
  2662.               
  2663.  Comments:    Before calling set_vector() you must store a machine-code
  2664.               interrupt handling routine at location s in memory.
  2665.  
  2666.               The 16-bit segment can be the code segment used by Euphoria.
  2667.               To get the value of this segment see demo\hardint.ex.
  2668.               The offset can be the 32-bit value returned by allocate().
  2669.               Euphoria runs in protected mode with the code segment 
  2670.               and data segment pointing to the same physical memory,
  2671.               but with different access modes.
  2672.               
  2673.               Interrupts occurring in either real-mode or protected mode
  2674.               will be passed to your handler. Your interrupt handler
  2675.               should immediately load the correct data segment before it
  2676.               tries to reference memory.
  2677.               
  2678.               Your handler might return from the interrupt using the 
  2679.               iretd instruction, or jump to the original interrupt handler. 
  2680.               It should save and restore any registers that it modifies.
  2681.               
  2682.               You should lock the memory used by your handler to ensure
  2683.               that it will never be swapped out. See lock_memory().
  2684.               
  2685.               It is highly recommended that you study demo\hardint.ex
  2686.               before trying to set up your own interrupt handler.
  2687.               
  2688.           You should have a good knowledge of machine-level programming
  2689.           before attempting to write your own handler.
  2690.           
  2691.               You can call set_vector() with the far address returned by
  2692.               get_vector(), when you want to restore the original handler.
  2693.               
  2694.  Example:     set_vector(#1C, {code_segment, my_handler_address})
  2695.  
  2696.  Example Program: demo\hardint.ex
  2697.  
  2698.  See Also:    get_vector, lock_memory 
  2699.  
  2700. ─────────────────────────────────────<sin>──────────────────────────────────────
  2701.  
  2702.  Syntax:      x2 = sin(x1)
  2703.     
  2704.  Description: Return the sine of x1, where x1 is in radians.
  2705.  
  2706.  Comments:    This function may be applied to an atom or to all elements
  2707.            of a sequence.
  2708.  
  2709.  Example:     sin_x = sin({.5, .9, .11})
  2710.            -- sin_x is {.479, .783, .110} 
  2711.  
  2712.  See Also:    cos, tan
  2713.  
  2714. ─────────────────────────────────────<sort>─────────────────────────────────────
  2715.  
  2716.  Syntax:      include sort.e
  2717.            s2 = sort(s1)
  2718.     
  2719.  Description: Sort s1 into ascending order using a fast sorting algorithm. The
  2720.             elements of s1 can be any mix of atoms or sequences. Atoms come 
  2721.             before sequences, and sequences are sorted "alphabetically" where
  2722.             the first elements are more significant than the later elements.
  2723.  
  2724.  Comments:    By defining your own compare function to override the built-in 
  2725.           compare(), you can change the ordering of values from sort(), and 
  2726.           perhaps choose a field or element number on which to base the 
  2727.           sort. Define your compare() as a global function before 
  2728.           including sort.e.
  2729.  
  2730.  Example 1:   x = 0 & sort({7,5,3,8}) & 0
  2731.           -- x is set to {0, 3, 5, 7, 8, 0}
  2732.  
  2733.  Example 2:   y = sort({"Smith", "Jones", "Doe", 5.5, 4, 6})
  2734.            -- y is {4, 5.5, 6, "Doe", "Jones", "Smith"}
  2735.            
  2736.  Example 3:   database = sort({{"Smith",   95.0, 29},
  2737.                           {"Jones",   77.2, 31},
  2738.                           {"Clinton", 88.7, 44}})
  2739.           
  2740.           -- The 3 database "records" will be sorted by the first "field"
  2741.           -- i.e. by name. Where the first field (element) is equal it 
  2742.           -- will be sorted by the second field etc.
  2743.           
  2744.           -- database is {{"Clinton", 88.7, 44},
  2745.                         {"Jones",   77.2, 31},
  2746.                         {"Smith",   95.0, 29}}
  2747.  
  2748.  See Also:    compare, match, find
  2749.   
  2750. ────────────────────────────────────<sound>─────────────────────────────────────
  2751.  
  2752.  Syntax:      include graphics.e
  2753.               sound(i)
  2754.     
  2755.  Description: Turn on the PC speaker at frequency i. If i is 0 the speaker 
  2756.            will be turned off.
  2757.  
  2758.  Example:     sound(1000) -- starts a fairly high pitched sound
  2759.  
  2760. ───────────────────────────────────<sprintf>────────────────────────────────────
  2761.  
  2762.  Syntax:      s = sprintf(st, x)
  2763.  
  2764.  Description: This is exactly the same as printf(), except that the output
  2765.            is returned as a sequence of characters, rather than being
  2766.            sent to a file or device. st is a format string, x is the
  2767.            value or sequence of values to be formatted. printf(fn, st, x) 
  2768.            is equivalent to puts(fn, sprintf(st, x)).
  2769.  
  2770.  Comments:    Some typical uses of sprintf are:
  2771.                 
  2772.                 1. Converting numbers to strings.
  2773.                 2. Creating strings to pass to system().
  2774.                 3. Creating formatted error messages and passing them to
  2775.                    a common error message handler.
  2776.  
  2777.  Example:     s = sprintf("%08d", 12345)
  2778.             -- s is "00012345"
  2779.             
  2780.  See Also:    printf, value, get
  2781.  
  2782. ─────────────────────────────────────<sqrt>─────────────────────────────────────
  2783.  
  2784.  Syntax:      x2 = sqrt(x1)   
  2785.     
  2786.  Description: Calculate the square root of x1.
  2787.  
  2788.  Comments:    This function may be applied to an atom or to all elements
  2789.            of a sequence.
  2790.  
  2791.            Taking the square root of a negative number will abort your
  2792.            program with a run-time error message.
  2793.            
  2794.  Example:     r = sqrt(16)
  2795.            -- r is 4
  2796.  
  2797.  See Also:    log, power
  2798.  
  2799. ────────────────────────────────────<system>────────────────────────────────────
  2800.  
  2801.  Syntax:      system(s, i)
  2802.     
  2803.  Description: Pass a command string s to the DOS command interpreter for 
  2804.            execution. The argument i indicates the manner in which to 
  2805.           return from the system call. 
  2806.         
  2807.         value of i      return action
  2808.         ----------    ------------- 
  2809.              0      - restore previous graphics mode
  2810.                   (clears the screen)
  2811.              1      - make a beep sound, wait for a
  2812.                   key press, then restore the
  2813.                   graphics mode
  2814.              2      - do not restore graphics mode
  2815.  
  2816.  Comments:    Action 2 should only be used when it is known that the system 
  2817.            call will not change the graphics mode. 
  2818.  
  2819.           You can use Euphoria as a sophisticated DOS "batch" language
  2820.           by making calls to system().
  2821.           
  2822.            A Euphoria program will start off using extended memory. If 
  2823.            extended memory runs out the program will consume conventional 
  2824.            memory. If conventional memory runs out it will use virtual 
  2825.            memory, i.e. swap space on disk. The DOS command run by system()
  2826.            will fail if there is not enough conventional memory available. 
  2827.            To avoid this situation you can reserve some conventional (low) 
  2828.            memory by typing:
  2829.                     
  2830.                     SET CAUSEWAY=LOWMEM:xxx
  2831.            
  2832.            where xxx is the number of K of conventional memory to reserve.
  2833.            Type this before running your program. You can also put this in 
  2834.            a .bat file that runs your program, or in AUTOEXEC.BAT. For
  2835.            example:
  2836.                     
  2837.                     SET CAUSEWAY=LOWMEM:80
  2838.                     ex myprog.ex
  2839.            
  2840.            This will reserve 80K of conventional memory, which should be
  2841.            enough to run simple DOS commands like COPY, MOVE, MKDIR etc.
  2842.            
  2843.  Example:     system("copy temp.txt a:\\temp.bak", 2)
  2844.            -- note use of double backslash in literal string to get 
  2845.               single backslash
  2846.  
  2847.  Example Program: see install.ex
  2848.  
  2849.  See Also:    dir, current_dir, getenv, command_line
  2850.  
  2851. ─────────────────────────────────────<tan>──────────────────────────────────────
  2852.  
  2853.  Syntax:      x2 = tan(x1) 
  2854.     
  2855.  Description: Return the tangent of x1, where x1 is in radians.
  2856.  
  2857.  Comments:    This function may be applied to an atom or to all elements
  2858.            of a sequence.
  2859.  
  2860.  Example:     t = tan(1.0)
  2861.            -- t is 1.55741
  2862.          
  2863.  See Also:    sin, cos, arctan
  2864.  
  2865. ──────────────────────────────────<text_color>──────────────────────────────────
  2866.  
  2867.  Syntax:      include graphics.e
  2868.            text_color(i)
  2869.     
  2870.  Description: Set the foreground text color. Add 16 to get blinking text
  2871.           in some modes. See graphics.e for a list of possible colors.
  2872.  
  2873.  Comments:    Text that you print *after* calling text_color will have the
  2874.            desired color. 
  2875.            
  2876.            When your program terminates, the last color that you selected
  2877.            and actually printed on the screen will remain in effect.
  2878.            Thus you may have to print something, maybe just '\n', in 
  2879.            WHITE to restore white text, especially if you are at the 
  2880.            bottom line of the screen, ready to scroll up.
  2881.            
  2882.  Example:     text_color(BRIGHT_BLUE)
  2883.  
  2884.  See Also:    bk_color
  2885.  
  2886. ──────────────────────────────────<text_rows>───────────────────────────────────
  2887.  
  2888.  Syntax:      include graphics.e
  2889.            i2 = text_rows(i1)
  2890.     
  2891.  Description: Set the number of lines on a text-mode screen to i1 if possible.
  2892.           i2 will be set to the actual new number of lines.
  2893.  
  2894.  Comments:    Values of 25, 28, 43 and 50 lines are supported by most video
  2895.            cards.
  2896.            
  2897.  See Also:    graphics_mode
  2898.  
  2899. ──────────────────────────────────<tick_rate>───────────────────────────────────
  2900.  
  2901.  Syntax:      include machine.e
  2902.            tick_rate(a)
  2903.            
  2904.  Description: Specify the number of clock-tick interrupts per second.
  2905.               This determines the precision of the time() library
  2906.               routine. It also affects the sampling rate for time
  2907.               profiling. 
  2908.  
  2909.  Comments:    On a PC the clock-tick interrupt normally occurs at 18.2
  2910.               interrupts per second. tick_rate() lets you increase
  2911.               that rate, but not decrease it. 
  2912.               
  2913.               tick_rate(0) will restore the rate to the normal 18.2 rate.
  2914.               Euphoria will also restore the rate automatically when it exits,
  2915.               even when it finds an error in your program. 
  2916.               
  2917.               While ex.exe is running, the system will maintain the correct 
  2918.               time of day. However if ex.exe should crash (e.g. you see
  2919.               a "Causeway..." error) while the tick rate is high, you (or 
  2920.               your user) may need to reboot the machine to restore the 
  2921.               proper rate. If you don't, the system time may advance too 
  2922.               quickly. This problem does not occur on Windows 95, only on DOS 
  2923.               or Windows 3.1. You will always get back the correct time of day 
  2924.               from the battery-operated clock in your system when you boot up 
  2925.               again.
  2926.               
  2927.  Example:     tick_rate(100)
  2928.            -- time() will now advance in steps of .01 seconds
  2929.            -- instead of the usual .055 seconds
  2930.            
  2931.  See Also:    time, discussion of time profiling in refman.doc
  2932.  
  2933. ─────────────────────────────────────<time>─────────────────────────────────────
  2934.  
  2935.  Syntax:      a = time()
  2936.     
  2937.  Description: Return the number of seconds since some fixed point in the past.
  2938.             The resolution on MS-DOS is normally about 0.05 seconds. 
  2939.  
  2940.  Comments:    Take the difference between two readings of time(), to
  2941.            measure, for example, how long a section of code takes to
  2942.            execute.
  2943.  
  2944.               You can improve the resolution by calling tick_rate().
  2945.               
  2946.  Example:     constant ITERATIONS = 1000000 
  2947.            integer p
  2948.            atom t0, loop_overhead
  2949.            
  2950.            t0 = time()
  2951.            for i = 1 to ITERATIONS do
  2952.            end for
  2953.            loop_overhead = time() - t0
  2954.      
  2955.           t0 = time()
  2956.            for i = 1 to ITERATIONS do
  2957.                  p = power(2, 20)
  2958.            end for
  2959.            ? (time() - t0 - loop_overhead)/ITERATIONS
  2960.            -- calculates time (in seconds) for one call to power
  2961.            
  2962.  See Also:    date, tick_rate
  2963.  
  2964. ────────────────────────────────────<trace>─────────────────────────────────────
  2965.  
  2966.  Syntax:      with trace
  2967.            trace(i) 
  2968.     
  2969.  Description: If i is 1 or 2 then turn on full-screen statement tracing. If i 
  2970.            is 0 then    turn off tracing. When i is 2 a monochrome trace 
  2971.            display is forced on. Tracing only occurs in subroutines that 
  2972.            were compiled "with trace". See the section on Debugging in 
  2973.            refman.doc.
  2974.  
  2975.  Comments:    Use trace(2) if the color display is hard to view on your system.
  2976.  
  2977.  Example:     if x < 0 then
  2978.            -- ok, here's the case I want to debug...
  2979.            trace(1)
  2980.            -- etc.
  2981.           ...
  2982.           end if           
  2983.                
  2984.  See Also:    Chapter 3 in refman.doc.
  2985.  
  2986. ────────────────────────────────────<upper>─────────────────────────────────────
  2987.  
  2988.  Syntax:      include wildcard.e
  2989.            x2 = upper(x1)
  2990.  
  2991.  Description: Convert an atom or sequence to upper case.
  2992.  
  2993.  Example:     s = upper("Euphoria")
  2994.            -- s is "EUPHORIA"
  2995.            
  2996.            a = upper('g')
  2997.            -- a is 'G'
  2998.            
  2999.            s = upper({"Euphoria", "Programming"})
  3000.            -- s is {"EUPHORIA", "PROGRAMMING"}
  3001.  
  3002.  See Also:    lower
  3003.  
  3004. ──────────────────────────────────<use_vesa>────────────────────────────────────
  3005.  
  3006.  Syntax:      include machine.e
  3007.            use_vesa(i)
  3008.            
  3009.  Description: use_vesa(1) will force Euphoria to use the VESA graphics
  3010.            standard. This may cause Euphoria programs to work better
  3011.            in SVGA graphics modes with certain video cards.
  3012.            use_vesa(0) will restore Euphoria's original method of
  3013.            using the video card.
  3014.            
  3015.  Comments:    Most people can ignore this. However if you experience
  3016.            difficulty in SVGA graphics modes you should try calling
  3017.            use_vesa(1) at the start of your program before any calls
  3018.            to graphics_mode().
  3019.  
  3020.            Arguments to use_vesa() other than 0 or 1 should not be used.
  3021.            
  3022.  Example:     use_vesa(1)
  3023.            fail = graphics_mode(261)
  3024.            
  3025.  See Also:    graphics_mode
  3026.  
  3027. ────────────────────────────────────<value>─────────────────────────────────────
  3028.  
  3029.  Syntax:      include get.e
  3030.            s = value(st)
  3031.  
  3032.  Description: Read the string representation of a Euphoria object, and compute
  3033.            the value of that object. A 2-element sequence, 
  3034.            {error_status, value} is actually returned, where error_status
  3035.            can be one of:
  3036.         
  3037.         GET_SUCCESS     -- a valid object representation was found
  3038.         GET_EOF        -- end of string reached too soon
  3039.         GET_FAIL    -- syntax is wrong 
  3040.                
  3041.  Comments:    This works the same as get(), but it reads from a string
  3042.            that you supply, rather than from a file or device.
  3043.            
  3044.  Example 1:   s = value("12345"}
  3045.            -- s is {GET_SUCCESS, 12345}
  3046.            
  3047.  Example 2:   s = value("{0, 1, -99.9}")
  3048.            -- s is {GET_SUCCESS, {0, 1, -99.9}}
  3049.            
  3050.  Example 3:   s = value("+++")
  3051.            -- s is {GET_FAIL, 0}
  3052.  
  3053.  See Also:    get, sprintf, print
  3054.  
  3055. ─────────────────────────────────<video_config>─────────────────────────────────
  3056.  
  3057.  Syntax:      include graphics.e
  3058.            s = video_config()
  3059.     
  3060.  Description: Return a sequence of values describing the current video
  3061.           configuration:
  3062.         {color monitor?, graphics mode, text rows, text columns,
  3063.          xpixels, ypixels, number of colors, number of pages}
  3064.            
  3065.            The following constants are defined in graphics.e:
  3066.             
  3067.             global constant VC_COLOR = 1,
  3068.                 VC_MODE  = 2,
  3069.                 VC_LINES = 3,
  3070.                 VC_COLUMNS = 4,
  3071.                 VC_XPIXELS = 5,
  3072.                 VC_YPIXELS = 6,
  3073.                 VC_NCOLORS = 7,
  3074.                 VC_PAGES = 8
  3075.            
  3076.  Comments:    This routine makes it easy for you to parameterize a program 
  3077.            so it will work in many different graphics modes.
  3078.            
  3079.            On the PC there are two types of graphics mode. The first type,
  3080.            text mode, lets you print text only. The second type, 
  3081.            pixel-graphics mode, lets you plot pixels, or points, in 
  3082.            various colors, as well as text. You can tell that you are in a 
  3083.            text mode, because the VC_XPIXELS and VC_YPIXELS fields will 
  3084.            be 0. Library routines such as polygon, draw_line, and ellipse 
  3085.            only work in a pixel-graphics mode.
  3086.            
  3087.  Example:     vc = video_config()  -- in mode 3 with 25-lines of text:
  3088.            -- vc is {1, 3, 25, 80, 0, 0, 32, 8}
  3089.  
  3090.  See Also:    graphics_mode
  3091.  
  3092. ──────────────────────────────────<wait_key>────────────────────────────────────
  3093.  
  3094.  Syntax:      include get.e
  3095.            i = wait_key()
  3096.            
  3097.  Description: Return the next key pressed by the user. Don't return until
  3098.             a key is pressed.
  3099.             
  3100.  Comments:    You could achieve the same result using get_key() as follows:
  3101.                 
  3102.                 while 1 do
  3103.                     k = get_key()
  3104.                     if k != -1 then
  3105.                         exit
  3106.                     end if
  3107.                 end while    
  3108.  
  3109.            However, on multi-tasking systems like Windows, Windows NT,
  3110.            or OS/2 this "busy waiting" would slow the system down. 
  3111.            wait_key() lets the operating system do other useful work 
  3112.            while your program is waiting for the user to press a key.
  3113.  
  3114.            You could also use getc(0), assuming file number 0 was input 
  3115.            from the keyboard, except that you wouldn't pick up the special
  3116.            codes for function keys, arrow keys etc.
  3117.            
  3118.  See Also:    get_key, getc
  3119.  
  3120. ────────────────────────────────────<where>─────────────────────────────────────
  3121.  
  3122.  Syntax:      include file.e
  3123.            i = where(fn)
  3124.     
  3125.  Description: This function returns the current byte position in the file fn.
  3126.           This position is updated by reads, writes and seeks on the file.
  3127.           It is the place in the file where the next byte will be read 
  3128.           from, or written to.
  3129.  
  3130.  See Also:    seek, open
  3131.  
  3132. ────────────────────────────────<wildcard_file>─────────────────────────────────
  3133.  
  3134.  Syntax:      include wildcard.e
  3135.            i = wildcard_file(s1, s2)
  3136.  
  3137.  Description: Return 1 (TRUE) if the filename s2 matches the wild card pattern
  3138.            s1. Return 0 (FALSE) otherwise. This is similar to DOS wildcard
  3139.            matching, but better in some cases. * matches any 0 or more 
  3140.            characters, ? matches any single character. Character comparisons
  3141.            are not case sensitive. 
  3142.  
  3143.  Comments:    You might use this function to check the output of the dir()
  3144.            routine for file names that match a pattern supplied by the 
  3145.            user of your program.
  3146.  
  3147.            In DOS "*ABC.*" will match ALL files. wildcard_file("*ABC.*", s)
  3148.            will only match when the file name part has "ABC" at the end
  3149.            (as you would expect).
  3150.  
  3151.  Example 1:   i = wildcard_file("AB*CD.?", "aB123cD.e")  
  3152.           -- i is set to 1
  3153.           
  3154.  Example 2:   i = wildcard_file("AB*CD.?", "abcd.ex")
  3155.            -- i is set to 0, because the file type has 2 letters not 1
  3156.            
  3157.  Example Program: see bin\search.ex
  3158.  
  3159.  See Also:    wildcard_match, dir
  3160.  
  3161. ────────────────────────────────<wildcard_match>────────────────────────────────
  3162.  
  3163.  Syntax:      include wildcard.e
  3164.            i = wildcard_match(s1, s2)
  3165.  
  3166.  Description: This function performs general matching of a string against a 
  3167.            pattern containing * and ? wildcards. It returns 1 (TRUE) if 
  3168.            string s2 matches pattern s1. It returns 0 (FALSE) otherwise. 
  3169.            * matches any 0 or more characters. ? matches any
  3170.            single character. Character comparisons are case sensitive.
  3171.  
  3172.  Comments:    If you want case insensitive comparisons, pass both s1 and s2
  3173.            through upper(), or both through lower() before calling
  3174.            wildcard_match().
  3175.  
  3176.            If you want to detect a pattern anywhere within a string,
  3177.            add * to each end of the pattern:
  3178.              
  3179.              i = wildcard_match('*' & pattern & '*', string)
  3180.  
  3181.            There is currently no way to treat * or ? literally in a pattern.
  3182.            
  3183.  Example 1:   i = wildcard_match("A?B*", "AQBXXYY")          
  3184.            -- i is 1 (TRUE)
  3185.            
  3186.  Example 2:   i = wildcard_match("*xyz*", "AAAbbbxyz")
  3187.            -- i is 1 (TRUE)
  3188.  
  3189.  Example 3:   i = wildcard_match("A*B*C", "a111b222c")
  3190.            -- i is 0 (FALSE) because upper/lower case doesn't match
  3191.  
  3192.  Example Program: see bin\search.ex
  3193.  
  3194.  See Also:    wildcard_file, match, upper, lower, compare
  3195.  
  3196. ─────────────────────────────────────<wrap>─────────────────────────────────────
  3197.  
  3198.  Syntax:      include graphics.e
  3199.            wrap(i)
  3200.     
  3201.  Description: Allow text to wrap at the right margin (i = 1) or get truncated
  3202.             (i = 0).
  3203.  
  3204.  Comments:    By default text will wrap.
  3205.  
  3206.               Use wrap() in text modes or pixel-graphics modes when you
  3207.               are displaying long lines of text.
  3208.  
  3209.  Example:     puts(1, repeat('x', 100) & "\n\n") 
  3210.            -- now have a line of 80 'x' followed a line of 20 more 'x'
  3211.            wrap(0)
  3212.            puts(1, repeat('x', 100) & "\n\n")
  3213.            -- creates just one line of 80 'x' 
  3214.            
  3215.  See Also:    puts, position
  3216.  
  3217. ───────────────────────────────────<xor_bits>───────────────────────────────────
  3218.  
  3219.  Syntax:      x3 = xor_bits(x1, x2)
  3220.  
  3221.  Description: Perform the logical XOR (exclusive OR) operation on 
  3222.               corresponding bits in x1 and x2. A bit in x3 will be 1 
  3223.               when one of the two corresponding bits in x1 or x2 is 1, 
  3224.               and the other is 0.
  3225.               
  3226.  Comments:    The arguments to this function may be atoms or sequences. The
  3227.            rules for arithmetic operations on sequences apply.
  3228.  
  3229.           The arguments must be representable as 32-bit numbers,
  3230.           either signed or unsigned.
  3231.           
  3232.           If you intend to manipulate full 32-bit values, you should
  3233.           declare your variables as atom, rather than integer. Euphoria's
  3234.           integer type is limited to 31-bits.
  3235.  
  3236.               Results are treated as signed numbers. They will be
  3237.               negative when the highest-order bit is 1.
  3238.               
  3239.  Example 1:   a = xor_bits(#0110, #1010)
  3240.               -- a is #1100
  3241.  
  3242.  See Also:    and_bits, or_bits, not_bits, int_to_bits
  3243.  
  3244.  
  3245.