Mombu the Programming Forum sponsored links

Go Back   Mombu the Programming Forum > Programming > how to show line number in studio editor and how to EXIT a loop?
User Name
Password
REGISTER NOW! Mark Forums Read

sponsored links


Reply
 
1 16th April 15:15
johnwu
External User
 
Posts: 1
Default how to show line number in studio editor and how to EXIT a loop?



Hello All

I'm new to Eiffel and trying to be familiar to eiffel and its edutio.

the questions now for me are:

1. in Studio Editor, how to show line number as many other editor can do?

2. in a loop or a procedure, how to stop and go out this loop/procedure, like
the pseudo code
....
for i=1,2,3,....1000
if value<100000
then do value++,i++
else exit
.....

--
Thanks lots in advance
John
Toronto
  Reply With Quote


  sponsored links


2 16th April 15:15
jim cochrane
External User
 
Posts: 1
Default how to show line number in studio editor and how to EXIT a loop?



My solution to this problem is to use an external editor, such as vi.
(It's easy to configure it to use an external editor.) I think the
estudio editor doesn't do line #s, but I'll leave it for an estudio
expert to give a definitive answer.


(Is this a homework assignment?)

The first thing to do is to familiarize yourself with the loop format:

from
init_statements
until
exit_condition
loop
body
end

Then figure out from your code example what the exit condition is:
i > 1000 or value >= 100000 -- right?

Make sure you perform the necessary initialization in the from section
(i.e., in your code, what must hold at the beginning of the first iteration
of the loop?). Then figure out what the body should be. You may find that
the result is easier to understand than your code example because the exit
condition is tested in just one place.


--
Jim Cochrane; jtc@dimensional.com
[When responding by email, include the term non-spam in the subject line to
get through my spam filter.]
  Reply With Quote
3 16th April 15:15
johnwu
External User
 
Posts: 1
Default how to show line number in studio editor and how to EXIT a loop?


No, I just start to learn and want to get clear some points about it.

Thanks lots, Jim, making me get to the point of using "from...until"
to control a loop.
Actually I'm a Java developer and like to compare Eiffel with Java at
some aspects.
if the above question changed to, say
in Java, there is a mechanism to handle EXCEPTION which may occur in
running time, i.e.
a file which is supposed to be read but doesn't exist at all, to deal
with this kind of issue, the java code may be like

public void read (File file) Throw Exception
{...read file
...if file exist then...
}

thus the code can go as how it is expected to go

in Eiffel, what is the way to handle the running time problem?

--
Thanks
John
Toronto
  Reply With Quote
4 16th April 15:15
andreas leitner
External User
 
Posts: 1
Default how to show line number in studio editor and how to EXIT a loop?


In Eiffel, there are "exceptions" too. But they have a different semantic.
Exceptions should (almost) never be used to influence the control flow of
a correct program. And a program that tries to open a file that doesn't
exist might very well be correct, it might be wrongly configured,
the user might have mistyped the filename, removed the file, ... Simply,
its a case that we as programmers have to take into account and deal with.
And surely it's no exception that the user inputs invalid data, right (;

Usually in Eiffel the caller is responsible to open the file (and make
sure it opened correctly). The reading party just accepts an open file:

....
FILE f;
....
create f.make_open_write (file_name)
if f.is_open_write then
read (f)
else
print ("error")
end
....
read (f: FILE) is
require
f_not_void: f /= Void
f_is_open_write: f.is_open_write
do
...
end

At least thats the way the GOBO libraries work.

hope this helps,
Andreas
  Reply With Quote
5 16th April 15:15
john
External User
 
Posts: 1
Default how to show line number in studio editor and how to EXIT a loop?


Thanks lots, Andreas, it did make me know the mechanism dealing with this
kind of issue which is far from for Java.
John
  Reply With Quote
6 16th April 15:15
joseph kiniry
External User
 
Posts: 1
Default Exceptions in Eiffel and Java


Hi John,

Andreas Leitner <nozone@sbox.tugraz.at> writes:

You can also learn more about the differences between exceptions in
Java and Eiffel via my paper:

"Exceptions in Java and Eiffel: Two Extremes in Exception Design and
Application". In Proceedings of "Exception Handling in Object
Oriented Systems: Toward Emerging Application Areas and New
Programming Paradigms" (at ECOOP), Darmstadt, Germany, July, 2003.

http://kind.cs.kun.nl/~kiniry/papers_index.html

Best,
Joe
--
Joseph R. Kiniry ID 78860581 ICQ 4344804
SOS Group, University of Nijmegen http://www.cs.kun.nl/~kiniry/
KindSoftware, LLC http://www.kindsoftware.com/
Board Chair: NICE http://www.eiffel-nice.org/
  Reply With Quote
7 22nd April 02:54
jim cochrane
External User
 
Posts: 1
Default how to show line number in studio editor and how to EXIT a loop?


John - Andreas gave you a good answer, but if you're wanting to learn more
about it, you might try one of the online eiffel tutorials. A google
search should locate some sites. I've got a couple bookmarked - let me
know if you want the URLs. Also, if you really get into it, check out
Meyer's OOSC.
--
Jim Cochrane; jtc@dimensional.com
[When responding by email, include the term non-spam in the subject line to
get through my spam filter.]
  Reply With Quote
Reply


Thread Tools
Display Modes




Copyright © 2006 SmartyDevil.com - Dies Mies Jeschet Boenedoesef Douvema Enitemaus -
666