mirror of
https://github.com/EiffelSoftware/eiffel-org.git
synced 2026-04-05 17:49:26 +02:00
Merged 18.01 changes into trunk.
git-svn-id: https://svn.eiffel.com/eiffel-org/trunk@2030 abb3cda0-5349-4a8f-a601-0c33ac3a8c38
This commit is contained in:
@@ -0,0 +1,15 @@
|
|||||||
|
[[Property:uuid|B74D374E-895C-4F22-B95F-656BD78ECD03]]
|
||||||
|
[[Property:weight|1000]]
|
||||||
|
[[Property:title|Getting a STRING from a NUMERIC object]]
|
||||||
|
[[Property:link_title|NUMERIC to STRING]]
|
||||||
|
Every class has the <code>out</code> method that can be used to get a text version of the object. For a lot of class, this method return internal informations that are not really useful for the end user. But for every <code>NUMERIC</code> class, the <code>out</code> method return a text representation of the number that the <code>NUMERIC</code> object represents.
|
||||||
|
|
||||||
|
<code>
|
||||||
|
print_integer(a_integer:INTEGER)
|
||||||
|
-- Print the value of `a_integer'
|
||||||
|
do
|
||||||
|
print(a_integer.out + "%N")
|
||||||
|
end
|
||||||
|
</code>
|
||||||
|
|
||||||
|
Note that for more advance convertion, you can also used convertion class like <code>FORMAT_DOUBLE</code>.
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
[[Property:uuid|78393BBA-9B1E-4523-9881-3D83CEB6A952]]
|
||||||
|
[[Property:weight|3000]]
|
||||||
|
[[Property:title|Removing object while iterating on a LIST]]
|
||||||
|
If you already have the object that you want to remove from the <code>LIST</code> you can easily use <code>prune</code> and <code>prune_all</code>. But if you want to remove objects while iterating on that <code>LIST</code>, depending on criteria on the objects contained in the <code>LIST</code>, here what you can do.
|
||||||
|
|
||||||
|
First of all, if you think about removing object while iterating, I do not recommend using an <code>across</code> loop. If you iterate on the list using a <code>from until loop end</code>, just remember to use the <code>LIST.forth</code> only when you do not use <code>LIST.remove</code>.
|
||||||
|
|
||||||
|
For example, let's say we have class <code>MY_CLASS</code> with an attribute <code>has_stopped</code> and that I want to remove every object of a <code>LIST</code> that has this attribute set to <code>True</code>. Here what the code will look like.
|
||||||
|
|
||||||
|
<code>
|
||||||
|
removing_stopped(a_list:LIST[MY_CLASS])
|
||||||
|
-- Removing every closed element of `a_list'
|
||||||
|
do
|
||||||
|
from
|
||||||
|
a_list.start
|
||||||
|
until
|
||||||
|
a_list.exhausted
|
||||||
|
loop
|
||||||
|
if a_list.item.has_stoped then
|
||||||
|
a_list.remove
|
||||||
|
else
|
||||||
|
a_list.forth
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
</code>
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
[[Property:uuid|96077603-DD2D-4D8C-A486-AF4BD066613A]]
|
||||||
|
[[Property:weight|2000]]
|
||||||
|
[[Property:title|Iterating on a LIST]]
|
||||||
|
There are two Eiffel mechanisms to iterate on every element of a <code>LIST</code>.
|
||||||
|
|
||||||
|
The first it the <code>across</code> loop. The <code>across</code> can be used on every <code>ITERABLE</code> object (including <code>LIST</code> objects).
|
||||||
|
|
||||||
|
<code>
|
||||||
|
print_elements(a_list:LIST[INTEGER])
|
||||||
|
-- Print every elements on `a_list'
|
||||||
|
do
|
||||||
|
across a_list as la_list loop
|
||||||
|
print(la_list.item.out + "%N")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
</code>
|
||||||
|
|
||||||
|
Note that the temporary variable (<code>la_list</code> in the example) represent an iterator of the <code>ITERABLE</code> object, and not directly an element like in many other languages (like the <code>for</code> structure in Python for example).
|
||||||
|
|
||||||
|
The other mechanism uses the <code>from until</code> loop syntax. This syntax offer more possibilities than the <code>across</code> loop, but is riskier.
|
||||||
|
|
||||||
|
<code>
|
||||||
|
print_elements(a_list:LIST[INTEGER])
|
||||||
|
-- Print every elements on `a_list'
|
||||||
|
do
|
||||||
|
from
|
||||||
|
a_list.start
|
||||||
|
until
|
||||||
|
a_list.exhausted
|
||||||
|
loop
|
||||||
|
print(a_list.item.out + "%N")
|
||||||
|
a_list.forth
|
||||||
|
end
|
||||||
|
end
|
||||||
|
</code>
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
[[Property:uuid|5CA34C5D-30F1-4D6F-9FE4-B555E541EA8C]]
|
||||||
|
[[Property:weight|4000]]
|
||||||
|
[[Property:title|Managing CTRL+C in console application]]
|
||||||
|
Normally, if the user use the CTRL+C keys, the Eiffel application detect it as an error and throw an exception of type <code>OPERATING_SYSTEM_SIGNAL_FAILURE</code>.
|
||||||
|
|
||||||
|
To manage the CTRL+C keys, you can use a <code>rescue</code> clause to detect the exception and a <code>retry</code> mecanism to cancel the exception handeling done by the Eiffel runtime.
|
||||||
|
|
||||||
|
To detect the exception, you can <code>inherit</code> from the <code>EXCEPTIONS</code> class and use an attachment test on <code>Exception_manager.last_exception</code>.
|
||||||
|
|
||||||
|
<code>
|
||||||
|
note
|
||||||
|
description: "Show how to quit an application using CTRL+C (without trace)."
|
||||||
|
author: "Louis Marchand"
|
||||||
|
date: "Wed, 25 Apr 2018 23:12:33 +0000"
|
||||||
|
revision: "0.1"
|
||||||
|
|
||||||
|
class
|
||||||
|
APPLICATION
|
||||||
|
|
||||||
|
inherit
|
||||||
|
EXCEPTIONS
|
||||||
|
|
||||||
|
create
|
||||||
|
make
|
||||||
|
|
||||||
|
feature {NONE} -- Initialization
|
||||||
|
|
||||||
|
make
|
||||||
|
-- Launch `Current'.
|
||||||
|
local
|
||||||
|
l_ctrl_c:BOOLEAN
|
||||||
|
do
|
||||||
|
if not l_ctrl_c then
|
||||||
|
from until False loop
|
||||||
|
io.standard_default.put_string ("Press CTRL+C%N")
|
||||||
|
io.input.read_line
|
||||||
|
end
|
||||||
|
else
|
||||||
|
io.standard_default.put_string ("%NClosing...%N")
|
||||||
|
end
|
||||||
|
rescue
|
||||||
|
if attached {OPERATING_SYSTEM_SIGNAL_FAILURE}
|
||||||
|
Exception_manager.last_exception then
|
||||||
|
l_ctrl_c := True
|
||||||
|
retry
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
</code>
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
[[Property:link_title|Mini How-tos]]
|
||||||
|
[[Property:uuid|B2E4622A-2495-47DD-9C02-B9940A026EC1]]
|
||||||
|
[[Property:weight|0]]
|
||||||
|
[[Property:title|Mini How-tos]]
|
||||||
|
In this section, you will find little how-tos that can be used to know how to used some very specific mechanics in Eiffel. Those how-tos are small by design and can be used to show very fundamental mechanisms for beginners or more advance mechanisms.
|
||||||
|
|
||||||
|
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
[[Property:title|Set slice size command]]
|
[[Property:title|Set slice size command]]
|
||||||
[[Property:weight|3]]
|
[[Property:weight|3]]
|
||||||
[[Property:uuid|ce2469a3-cf00-554e-47bd-5e8b2fdbc783]]
|
[[Property:uuid|ce2469a3-cf00-554e-47bd-5e8b2fdbc783]]
|
||||||
Located in the object tool toolbar, this command [[Image:debugger-set-sizes-icon]] changes the display size of special objects (i.e. objects whose class is [[ref:libraries/base/reference/special_chart|SPECIAL]] ). Because special objects may contain thousands of attributes, only the first fifty are displayed by default. If left-clicked, a dialog is popped up that sets the exploration indices of special objects that will be loaded in the future.
|
Located in the object tool toolbar, this command [[Image:debugger-set-sizes-icon]] changes the display size of special objects (i.e. objects whose class is [[ref:libraries/base/reference/special_chart|SPECIAL]], most importantly in the representation of arrays and strings). Because special objects may contain thousands of attributes, only the first fifty are displayed by default. If left-clicked, a dialog is popped up that sets the exploration indices of special objects that will be loaded in the future.
|
||||||
|
|
||||||
This pop-up also shows the "Maximum displayed string size" in the grid ([[Object tool|object tool]], or the [[Expression evaluation|watch tools]]).
|
This pop-up also shows the "Maximum displayed string size" in the grid ([[Object tool|object tool]], or the [[Expression evaluation|watch tools]]).
|
||||||
|
|
||||||
|
|||||||
@@ -56,28 +56,47 @@ cp -r /mnt/cdrom/EiffelXX .</code>
|
|||||||
|
|
||||||
This will install the EiffelStudio files into /usr/local/EiffelXX. To complete the installation of EiffelStudio, jump to the next section, [[#Setting up EiffelStudio|Setting up EiffelStudio]].
|
This will install the EiffelStudio files into /usr/local/EiffelXX. To complete the installation of EiffelStudio, jump to the next section, [[#Setting up EiffelStudio|Setting up EiffelStudio]].
|
||||||
<span id="setting_up"></span>
|
<span id="setting_up"></span>
|
||||||
|
|
||||||
==Setting up EiffelStudio==
|
==Setting up EiffelStudio==
|
||||||
|
|
||||||
Once the files have been installed, you should define the following environment variables in order to run EiffelStudio:
|
Once the files have been installed, you should define the following environment variables in order to run EiffelStudio:
|
||||||
* '''ISE_EIFFEL''' to /usr/local/EiffelXX
|
* '''ISE_EIFFEL''' to /usr/local/EiffelXX
|
||||||
* '''ISE_PLATFORM''' to linux-x86 for the 32 bits version or linux-x86-64 for the 64 bits version. We will be using '''linux-x86''' in the examples below.
|
* '''ISE_PLATFORM''' to linux-x86 for the 32 bits version or linux-x86-64 for the 64 bits version. We will be using '''linux-x86-64''' in the examples below.
|
||||||
and add $'''ISE_EIFFEL'''/studio/spec/$'''ISE_PLATFORM'''/bin to your '''PATH''' environment variable.
|
and add $'''ISE_EIFFEL'''/studio/spec/$'''ISE_PLATFORM'''/bin to your '''PATH''' environment variable.
|
||||||
|
|
||||||
Using sh or bash as a shell, it suffices to type the following commands:
|
Using sh or bash as a shell, it suffices to type the following commands:
|
||||||
<code>
|
<code>
|
||||||
export ISE_EIFFEL=/usr/local/EiffelXX
|
export ISE_EIFFEL=/usr/local/EiffelXX
|
||||||
export ISE_PLATFORM=linux-x86
|
export ISE_PLATFORM=linux-x86-64
|
||||||
export PATH=$PATH:$ISE_EIFFEL/studio/spec/$ISE_PLATFORM/bin</code>
|
export PATH=$PATH:$ISE_EIFFEL/studio/spec/$ISE_PLATFORM/bin</code>
|
||||||
|
|
||||||
|
|
||||||
Using csh or tcsh as a shell, it suffices to type the following commands:
|
Using csh or tcsh as a shell, it suffices to type the following commands:
|
||||||
<code>
|
<code>
|
||||||
setenv ISE_EIFFEL /usr/local/EiffelXX
|
setenv ISE_EIFFEL /usr/local/EiffelXX
|
||||||
setenv ISE_PLATFORM linux-x86
|
setenv ISE_PLATFORM linux-x86-64
|
||||||
set path = ($path $ISE_EIFFEL/studio/spec/$ISE_PLATFORM/bin)</code>
|
set path = ($path $ISE_EIFFEL/studio/spec/$ISE_PLATFORM/bin)</code>
|
||||||
|
|
||||||
|
|
||||||
If you are using the Enterprise edition, please follow the instructions of the next section, [[#Registering the Enterprise Edition|Registering the Enterprise Edition]], otherwise jump to the [[#Using EiffelStudio|Using EiffelStudio]] section at the end of this document.
|
If you are using the Enterprise edition, please follow the instructions of the next section, [[#Registering the Enterprise Edition|Registering the Enterprise Edition]], otherwise jump to the [[#Using EiffelStudio|Using EiffelStudio]] section at the end of this document.
|
||||||
|
|
||||||
|
== Installing EiffelStudio on Ubuntu ==
|
||||||
|
An alternative to previous solution for Ubuntu, is to use the ppa repository.
|
||||||
|
```shell
|
||||||
|
sudo add-apt-repository ppa:eiffelstudio-team/ppa
|
||||||
|
sudo apt-get update
|
||||||
|
sudo apt-get install eiffelstudio
|
||||||
|
```
|
||||||
|
It installs EiffelStudio using the linux layout, so no specific environment variables are needed (note: ISE_EIFFEL and ISE_PLATFORM should not be set to use this linux layout).
|
||||||
|
The executable are located under `/usr/bin`, libraries under `/usr/lib/eiffelstudio`, ...
|
||||||
|
|
||||||
|
To reinstall, or update:
|
||||||
|
```shell
|
||||||
|
sudo apt-get purge eiffelstudio
|
||||||
|
sudo apt-get update
|
||||||
|
sudo apt-get install eiffelstudio
|
||||||
|
```
|
||||||
|
|
||||||
<span id="registering"></span>
|
<span id="registering"></span>
|
||||||
==Registering the Enterprise Edition==
|
==Registering the Enterprise Edition==
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user