diff --git a/documentation/current/examples/example-environment-variables.wiki b/documentation/current/examples/example-environment-variables.wiki new file mode 100644 index 00000000..426d8dc8 --- /dev/null +++ b/documentation/current/examples/example-environment-variables.wiki @@ -0,0 +1,42 @@ +[[Property:title|Environment variables]] +[[Property:link_title|Example: Environment variables]] +[[Property:weight|0]] +[[Property:uuid|60c39a34-0794-4c1f-a150-7431afa3e693]] +==Description== + +Using features from the class EXECUTION_ENVIRONMENT to create and retrieve an environment variable. + +==Notes== + +The make procedure of the class APPLICATION below uses the features put and get, inherited from the class EXECUTION_ENVIRONMENT, to create the environment variable MY_VARIABLE with value "Hello World!", and then to retrieve the value by key and print it. + +==Solution== + + +class + APPLICATION + +inherit + EXECUTION_ENVIRONMENT + +create + make + +feature {NONE} -- Initialization + make + -- Create and retrieve an environment variable. + do + put ("Hello World!", "MY_VARIABLE") + print (get ("MY_VARIABLE")) + end +end + + + +==Output== + + +Hello World! + + + diff --git a/documentation/current/examples/example-sleep.wiki b/documentation/current/examples/example-sleep.wiki new file mode 100644 index 00000000..b1463dbe --- /dev/null +++ b/documentation/current/examples/example-sleep.wiki @@ -0,0 +1,54 @@ +[[Property:title|Sleep]] +[[Property:link_title|Example: Sleep]] +[[Property:weight|0]] +==Description== + +Write a program that does the following in this order: +# Input an amount of time to sleep in whatever units are most natural for your language (milliseconds, seconds, ticks, etc.). This unit should be noted in comments or in a description. +# Print "Sleeping..." +# Sleep the main thread for the given amount of time. +# Print "Awake!" +# End. + +==Notes== + +The feature sleep is defined in the library class EXECUTION_ENVIRONMENT. So the demonstration class APPLICATION inherits from EXECUTION_ENVIRONMENT in order to make sleep available. + +sleep takes an argument which declares the number of nanoseconds to suspend the thread's execution. + +==Source== + +Problem description from [http://rosettacode.org/wiki/Sleep Rosetta Code] + +==Solution== + + +class + APPLICATION +inherit + EXECUTION_ENVIRONMENT +create + make +feature -- Initialization + make + -- Sleep for a given number of nanoseconds. + do + print ("Enter a number of nanoseconds: ") + io.read_integer_64 + print ("Sleeping...%N") + sleep (io.last_integer_64) + print ("Awake!%N") + end +end + + + +==Output (sleeping 10 seconds)== + + +Enter a number of nanoseconds: 10000000000 +Sleeping... +Awake! + + +