doc_Sample_e
Sample Source-Code
A sample of an include file formatted using Creole markup.
See the documentation after running eudoc and creole utilities.
--****
-- == Sample
--
-- <<LEVELTOC level=2 depth=4 >>
--****
-- Signature:
-- <built-in> function command_line()
--
-- Description:
-- returns sequence of strings containing each word entered at the command-line that started your program.
--
-- Returns:
-- # path : to either the Euphoria executable (##eui##, ##eui.exe##, ##euid.exe##, ##euiw.exe##) or to your bound
-- executable file.
-- # next word : is either the name of your Euphoria main file o
-- (again) the path to your bound executable file.
-- # extra words : typed by the user. You can use these words in your program.
--
-- There are as many entries as words, plus the two mentioned above.
--
-- The Euphoria interpreter itself does not use any command-line options. You are free to use
-- any options for your own program. The interpreter does have ##command line switches## though.
--
-- The user can put quotes around a series of words to make them into a single argument.
--
-- If you convert your program into an executable file, either by binding it, or translationg it to C,
-- you will find that all command-line arguments remain the same, except for the first two,
-- even though your user no longer types "eui" on the command-line (see examples below).
--
-- Example 1:
-- <eucode>
-- -- The user types: eui myprog myfile.dat 12345 "the end"
--
-- cmd = command_line()
--
-- -- cmd will be:
-- {"C:\EUPHORIA\BIN\EUI.EXE",
-- "myprog",
-- "myfile.dat",
-- "12345",
-- "the end"}
-- </eucode>
--
-- See Also:
-- [[:build_commandline]], [[:option_switches]], [[:getenv]], [[:cmd_parse]], [[:show_help]]
--**
-- Description:
-- displays a prompt to the user and waits for any keypress.
--
-- Parameters:
-- # prompt : Prompt to display, defaults to ##"Press Any Key to continue..."## .
-- # con : Either ##1## (stdout), or ##2## (stderr). Defaults to ##1## .
--
-- Comments:
-- This wraps ##wait_key## by giving a clue that the user should press a key, and
-- perhaps do some other things as well.
--
-- Example 1:
-- <eucode>
-- include std/console.e
-- any_key()
-- -- outputs the message: Press Any Key to continue...
-- -- and waits for a keypress
-- </eucode>
--
-- See Also:
-- [[:wait_key]], [[:maybe_any_key]]
public procedure any_key(sequence prompt="Press Any Key to continue...", integer con = 1)
if not find(con, {1,2}) then
con = 1
end if
puts(con, prompt)
wait_key()
puts(con, "\n")
end procedure
--**
-- parses a command line string breaking it into a sequence of command line
-- options.
--
-- Parameters:
-- # cmdline : Command line sequence (string)
--
-- Returns:
-- A **sequence**, of command line options
--
-- Example 1:
-- <eucode>
-- sequence opts = parse_commandline("-v -f '%Y-%m-%d %H:%M'")
-- -- opts = { "-v", "-f", "%Y-%m-%d %H:%M" }
-- </eucode>
--
-- See Also:
-- [[:build_commandline]]
--
public function parse_commandline(sequence cmdline)
return keyvalues(cmdline, " ", ":=", "\"'`", " \t\r\n", 0)
end function
public constant
--****
-- This option switch does not have a parameter.
-- See Also:
-- [[:cmd_parse]]
NO_PARAMETER = 'n'
public enum
--****
-- Additional help routine id.
-- See Also:
-- [[:cmd_parse]]
HELP_RID,
--****
-- Validate all parameters (default).
-- See Also:
-- [[:cmd_parse]]
VALIDATE_ALL,
--****
-- Do not cause an error for an invalid parameter.
-- See Also:
-- [[:cmd_parse]]
NO_VALIDATION

