INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Can anyone explain what this statement does in Eiffel.

Can anyone explain what this statement does in Eiffel.

Can anyone explain what this statement does in Eiffel.

(OP)
local
      i, newhostscount : INTEGER
      found : BOOLEAN
   do
      from
         found := false
         i := 1
         newhostscount := noofhosts
      until
         i > noofhosts or found
      loop
         if distincthosts.item(i).same_as(hostname) then
            found := true
         end -- if
         i := i + 1
      end -- loop
      
      if not found then
         newhostscount := newhostscount + 1
         if not(newhostscount > distincthosts.count) then
            distincthosts.put(hostname, newhostscount)
         end -- if
      end -- if
      
      result := newhostscount
   end -- addhost
   

RE: Can anyone explain what this statement does in Eiffel.

All the entities used in the body of this eiffel routine are not known, as far as I can understand it.

- I assume noofhosts is an INTEGER, meaning something like ``number of hosts''. It should be better named hosts_count.
- distincthosts must be a table container(a DICTIONARY, or TABLE, etc.) owning some distincts hosts(no doublons maybe). It should be better named distinct_hosts.
- hostname must be a STRING, and a parameter of this routine, maybe the host to seek for.

Back to the body of this routine : the from, until, loop, end statement iterates on the distincthosts container in order to find a host named hostname(the loop ends when it was found ).

The following if, end statement add hostname, and update newhostscount if hostname was not found in the previous search.

Finally, the updates newhostscount is returned.

--
Globos

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close