Currently Being Moderated

Try 5

VERSION 1

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

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

 

 

 

Try 5: <font color="black">Reading Our Score Data</font>

 

 

Please download the Try5.zip file by selecting the following link: {font:courier new}Try5.zip{font}.

 

 

Unzip the contents to the  C:\Curl directory.  This is the working directory for all the examples and exercises contained within this tutorial. Note: If C:\Curl has not already been created, you can create it now.

 

<font color="navy">Basics: Reading Data from a File, Line by Line</font>

 

 

<font color="black">Create the 'Try 5-1' Project</font>

 

 

Close the Try 4 project and then, from the IDE 'File' menu, select 'New Project'. In the 'New Project' dialog box, select “Applet Project” (1), input “Try5-1” (2), specify c:\Curl\lesson\Try5\01_read_file in the “Directory” field (3), set the API Version to 6.0 (4), and then click OK (5).

 

 

<font color="black">Inputting the Program</font>

 

 

Copy the c:\Curl\Try5\01_read_file\data.txt file to c:\Curl\lesson\Try5\01_read_file.  Next, we’ll input the program. You can copy the program code below or use c:\Curl\Try5\01_read_file\start.curl and then paste it into the editor in the IDE.

 

{value
 let loc:Url = {url data.txt}
 let input:#TextInputStream
 let data-array:StringArray = {StringArray}
 let list:DropdownList = {DropdownList width = 5cm}
 
 {try
     set input = {read-open loc}
     {until input.end-of-stream? do
         {if-non-null line = {input.read-line} then
             {data-array.append {line.to-String}}
         }
     }
     
  catch e:IOException do
     {popup-message An error reading the file has occurred.}
     {output e.message}
         
  finally
     {if-non-null input then
         {input.close}
     }
 }
 
 {for s:String in data-array do
     {list.append s}
 }
 
 {list.add-event-handler
     {on ValueChanged at lb:DropdownList do
         {popup-message lb.value &  was selected}
      
     }
 }
 
 {VBox
     Please select a state,
     list
 }
}

 

 

<font color="black">Save the File, and then Execute the Program</font>

 

 

After inputting the code, save the file, and then execute the program. The following result will appear in your browser.

 

 

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

Average User Rating
(0 ratings)




ramana reddy ramana reddy  says:

how we implement on load event so that some value is selected

More Like This

  • Retrieving data ...