Currently Being Moderated

Try 5: Page 7

VERSION 1

Created on: Mar 5, 2008 11:44 AM by Curl Education - Last Modified:  Jul 3, 2008 3:34 PM by Curl Education

!../../wiki/easy-ide-book/common/images/prev_page.gif! !../../wiki/easy-ide-book/common/images/toc.gif! !../../wiki/easy-ide-book/common/images/next_page.gif!

 

 

 

TRY 5 Summary

 

 

Reading and writing data from/to a file

 

 

Step 1. Specifying the location of a file

 

let location_variable_name:Url = {url “path to file location”}

 

 

Step 2. Opening file as a Stream

  • TextInputStream (read)

  • TextOutputStream (write)

 

 

let stream_variable_name:TextInputStream = {read-open location_variable_name}
let stream_variable_name:TextOutputStream = {write-open location_variable_name}

 

 

Step 3. Using methods to read or write data

  • Methods such as read-line or write-one-string

 

 

 

Step 4. Closing the file

 

{if-non-null stream_variable_name then
    {stream_variable_name.close}
}

 

 

Repeat Expressions

 

 

<font color="purple">until</font> expression (processing repeats until conditional expression is <font color="purple">true</font>)

{until conditional_expression do
    body
}

 

 

<font color="purple">for</font> expression (specifying a range)

{for repeat variable:int = initial_value to final_value step step_size value do
    body
}

As well as to, there are also the below, downto, and above keywords. The step_size can be omitted when the desired step_size is 1.

 

<font color="purple">for</font> expression (repeats only the values among the elements of a collection, such as an array)

{for element_variable:element_type key key_variable[:key type] in (collection) name do
    processing
}

Note that element_variable:Element_type or key key_variable: key_type can be omitted.

 

Exception Processing

{try
    Processing in which an exception may occur.
 catch exception_variable_name: exception
    Exception Processing
 finally
    Processing that must be performed regardless of whether an exception occurs
}

The catch and finally clauses can be omitted. Also, each try can be declared more than once.

 

!../../wiki/easy-ide-book/common/images/next_page.gif!

Average User Rating
(0 ratings)




There are no comments on this document

More Like This

  • Retrieving data ...