<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>REALbasic City &#187; httpsocket</title>
	<atom:link href="http://realbasic.tutspolis.com/tag/httpsocket/feed/" rel="self" type="application/rss+xml" />
	<link>http://realbasic.tutspolis.com</link>
	<description>Tutorials - Tutspolis.com</description>
	<lastBuildDate>Sat, 29 May 2010 23:10:17 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>PM: Create TwittMe v2 a twitter client in REALbasic</title>
		<link>http://realbasic.tutspolis.com/tutorials/pm-create-twittme-v2-a-twitter-client-in-realbasic/</link>
		<comments>http://realbasic.tutspolis.com/tutorials/pm-create-twittme-v2-a-twitter-client-in-realbasic/#comments</comments>
		<pubDate>Fri, 12 Feb 2010 20:08:33 +0000</pubDate>
		<dc:creator>Jakub Pawlak</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[httpsocket]]></category>
		<category><![CDATA[realbasic]]></category>
		<category><![CDATA[twitter api]]></category>
		<category><![CDATA[twitter client]]></category>
		<category><![CDATA[twittme]]></category>

		<guid isPermaLink="false">http://realbasic.tutspolis.com/?p=248</guid>
		<description><![CDATA[<!-- isPostPurchased ,postID 248, userID 0, combination 1 -->
			
				
			
		
In this Premium Member tutorial we will learn how to create a cross-platform twitter client using REALbasic HTTPSocket Class. Our twitter client will also offer a option to insert short URL to twitter updates. Watch it, learn it, enjoy it!


Creating the GUI for twitter client
We will use in this project controls: 2x StaticText, 1x TextArea, [...]]]></description>
			<content:encoded><![CDATA[<!-- isPostPurchased ,postID 248, userID 0, combination 1 --><div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Frealbasic.tutspolis.com%2Ftutorials%2Fpm-create-twittme-v2-a-twitter-client-in-realbasic%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Frealbasic.tutspolis.com%2Ftutorials%2Fpm-create-twittme-v2-a-twitter-client-in-realbasic%2F&amp;source=REALbasicCity&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p>In this Premium Member tutorial we will learn how to create a cross-platform twitter client using REALbasic HTTPSocket Class. Our twitter client will also offer a option to insert short URL to twitter updates. Watch it, learn it, enjoy it!</p>
<p><span id="more-248"></span></p>
<div style="margin-left:19px;float:left">
<h2>Creating the GUI for twitter client</h2>
<p>We will use in this project controls: 2x StaticText, 1x TextArea,  1x TextField and 2x PushButton. Try to get results close to the screenshot below. Change in StaticText1 -&gt; Appearance -&gt; Text Value to What are you doing? and in StaticText2 change text to 140 and the Font to bold style. In TextArea1 change the property LimitText value to 140 (this way we will add a limit for character in this control).  On bottom insert PushButton1 control and change it Caption to &#8220;Update on twitter&#8221;. Add also one TextField for our URL and one PushButton2 control with Caption &#8220;Insert Short URL&#8221;. You should get something like that:</p>
<p><img src="http://realbasic.tutspolis.com/files/tutorials/twittmev2.png" alt="realbasic TwittMe v2" /></p>
<h2>Count remaining characters&#8230;</h2>
<p>Twitter allows using only 140 characters per update so we will create a character counter in our application. Go to TextArea1 Sub TextChange() and insert there the code.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="vb" style="font-family:monospace;">StaticText2.Text = <span style="color: #000080;">CStr</span>(140 - Len(TextArea1.Text))</pre></td></tr></table></div>

<p>CStr function converts the number to string and in () we count how many characters are left in our TextArea1 control. Len function give us how many character are in TextArea1 control. </p>
<p>	<div class='ArePayPalContent'>
	<p class='ArePayPalTextToShowIfNotLogedIn'>If you see this message you probably want access special material for Premium Members (Source Files, Bonus Tutorials, free Classes and More). You can do this by subscribing REALbasic City site for 10 USD (access for 3 months). There is also a option to buy access only to this material. Login or register to get option to buy and support REALbasic City.</p>
	<a class='ArePayPalLoginButton' href='http://tutspolis.com/wp-login.php'>Log in</a>
	</div></p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://realbasic.tutspolis.com/tutorials/pm-create-twittme-v2-a-twitter-client-in-realbasic/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Download Manager in REALbasic</title>
		<link>http://realbasic.tutspolis.com/tutorials/download-manager-in-realbasic/</link>
		<comments>http://realbasic.tutspolis.com/tutorials/download-manager-in-realbasic/#comments</comments>
		<pubDate>Sat, 14 Nov 2009 13:10:16 +0000</pubDate>
		<dc:creator>Jakub Pawlak</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[download]]></category>
		<category><![CDATA[get]]></category>
		<category><![CDATA[httpsocket]]></category>
		<category><![CDATA[manager]]></category>
		<category><![CDATA[progress]]></category>
		<category><![CDATA[realbasic]]></category>

		<guid isPermaLink="false">http://realbasic.tutspolis.com/?p=162</guid>
		<description><![CDATA[<!-- isPostPurchased ,postID 162, userID 0, combination 1 -->
			
				
			
		
In this great tutorial we will learn in few easy steps how to create a Download Manager using REALbasic. We will discover a method to download a file with live progressbar and a option to get the file name and extension from URL. Watch it, learn it, enjoy it!


Creating Download Manager GUI
We will create a [...]]]></description>
			<content:encoded><![CDATA[<!-- isPostPurchased ,postID 162, userID 0, combination 1 --><div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Frealbasic.tutspolis.com%2Ftutorials%2Fdownload-manager-in-realbasic%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Frealbasic.tutspolis.com%2Ftutorials%2Fdownload-manager-in-realbasic%2F&amp;source=REALbasicCity&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p>In this great tutorial we will learn in few easy steps how to create a Download Manager using REALbasic. We will discover a method to download a file with live progressbar and a option to get the file name and extension from URL. Watch it, learn it, enjoy it!</p>
<p><span id="more-162"></span></p>
<div style="margin-left:19px;float:left">
<h2>Creating Download Manager GUI</h2>
<p>We will create a very basic GUI for our app so add to Window1 2x StaticText Control (File URL, Status), one TextField Control (for file url location), one Listbox Control (for displaying download status) and one PushButton Control (Download button). When you finish you should get something like this:</p>
<p><img src="http://realbasic.tutspolis.com/files/tutorials/downloadmanager.png" alt="Download Manager in REALbasic" /></p>
<h2>HTTPSocket Class in REALbasic</h2>
<p>At this moment we will create a class named hget with Super Value HTTPSocket. We will use it to download a file and show the progress of download. If you don&#8217;t know how to do this simply go to my article <a href="http://realbasic.tutspolis.com/tutorials/creating-a-class-in-realbasic/">Creating a Class in REALbasic</a> and you will find there all answers you need to go next. </p>
<p>Now inside hget Class go to Event Handlers Sub Connected () we can display info that our download has started. We can do this with one line of code and our Listbox Control.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="vb" style="font-family:monospace;">Window1.Listbox1.AddRow <span style="color: #800000;">&quot;Download Started&quot;</span></pre></td></tr></table></div>

<p>Remaining in hget Class code editor go to Event Handlers Sub DownloadComplete () and enter there:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code"><pre class="vb" style="font-family:monospace;">me.<span style="color: #000080;">Close</span> //closing the connection when download finish
&nbsp;
Window1.Listbox1.AddRow <span style="color: #800000;">&quot;Download Complete&quot;</span> //add info <span style="color: #000080;">to</span> Listbox</pre></td></tr></table></div>

<p>The last thing we will do in hget Class is making visual progress of file download. We do this in Event Handlers Sub ReceiveProgress.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code"><pre class="vb" style="font-family:monospace;">Window1.ProgressBar1.Maximum = totalbytes
&nbsp;
Window1.ProgressBar1.Value = bytesReceived
&nbsp;
Window1.ProgressBar1.Refresh</pre></td></tr></table></div>

<h2>Get file name and extension from URL</h2>
<p>Well how can we do this? The best way to do this is knowing that URL is constructed in such a way that mark / separates the file locations, folders. If we know that we can find the last mark / and then we will copy everything before it (this will be the file name and extension). The easiest method to do it is finding the first mark / from the right of URL. </p>
<p>For example when we use this link:</p>
<p>http://realbasic.tutspolis.com/files/tutorials/downloadmanager.png</p>
<p>we will find this:</p>
<p>/downloadmanager.png</p>
<p>We can find the file name and extension from URL using this method:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
</pre></td><td class="code"><pre class="vb" style="font-family:monospace;"><span style="color: #000080;">Dim</span> i, n <span style="color: #000080;">As</span> <span style="color: #000080;">Integer</span>
<span style="color: #000080;">Dim</span> s, a, filename <span style="color: #000080;">As</span> <span style="color: #000080;">String</span>
<span style="color: #000080;">Dim</span> b <span style="color: #000080;">As</span> <span style="color: #000080;">Boolean</span>
&nbsp;
b = <span style="color: #000080;">true</span>
&nbsp;
<span style="color: #000080;">for</span> i = 0 <span style="color: #000080;">to</span> Len(TextField1.Text) //check all mark <span style="color: #000080;">in</span> URL - Len returns the number of characters <span style="color: #000080;">in</span> the specified <span style="color: #000080;">string</span>
&nbsp;
  s = Right(TextField1.Text, i) //<span style="color: #000080;">get</span> mark from right i + 1
&nbsp;
  a = Mid(s, 1 ,1) //check the firs mark from s Right count
&nbsp;
  <span style="color: #000080;">if</span> a = <span style="color: #800000;">&quot;/&quot;</span> <span style="color: #000080;">and</span> b = <span style="color: #000080;">true</span> <span style="color: #000080;">then</span> //when we find the first mark / we will save the position <span style="color: #000080;">to</span> n <span style="color: #000080;">and</span> <span style="color: #000080;">stop</span> replacing it because <span style="color: #000080;">in</span> URL are more / marks
&nbsp;
    b= <span style="color: #000080;">false</span>
    n = i 
  <span style="color: #000080;">end</span>
&nbsp;
<span style="color: #000080;">next</span>
&nbsp;
filename = Right(TextField1.Text, n - 1) //returns the file name</pre></td></tr></table></div>

<h2>Download a file using HTTPSocket</h2>
<p>To download a file with displaying the progress in ProgressBar control using HTTPSocket.Get you must remember to have it like in example below. If you try to use only something like HTTPSocket.get(string,f,10) the class will not react for displaying the download progress or other Event Handlers.</p>
<p>One tip more &#8211; When you are using synchronous HTTP, your application may need to wait a noticeable amount of time to get or post a page. Setting Yield to True allows for events and other code to execute while waiting for a page.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
</pre></td><td class="code"><pre class="vb" style="font-family:monospace;"><span style="color: #000080;">Dim</span> d <span style="color: #000080;">As</span> <span style="color: #000080;">New</span> hget
<span style="color: #000080;">Dim</span> f <span style="color: #000080;">As</span> FolderItem
<span style="color: #000080;">Dim</span> filename <span style="color: #000080;">As</span> <span style="color: #000080;">String</span>
&nbsp;
f = SpecialFolder.Desktop.Child(filename) // saves the file <span style="color: #000080;">on</span> Desktop
&nbsp;
d.Yield = <span style="color: #000080;">True</span>
&nbsp;
<span style="color: #000080;">if</span> f.Exists = <span style="color: #000080;">false</span> <span style="color: #000080;">then</span> //<span style="color: #000080;">if</span> file doesn<span style="color: #008000;">'t exists then 
</span>    
  Window1.Listbox1.AddRow <span style="color: #800000;">&quot;Creating file: &quot;</span> + Str(f.DisplayName)
&nbsp;
  d.<span style="color: #000080;">get</span> (TextField1.Text,f) //downloading file  <span style="color: #000080;">to</span> desktop
&nbsp;
<span style="color: #000080;">elseif</span> f.Exists = <span style="color: #000080;">true</span> <span style="color: #000080;">then</span>
  Return
<span style="color: #000080;">end</span></pre></td></tr></table></div>

<p>So to get everything work combine our two last methods into one and insert them to PushButton1 Sub Action () like here:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
</pre></td><td class="code"><pre class="vb" style="font-family:monospace;"><span style="color: #000080;">Dim</span> d <span style="color: #000080;">As</span> <span style="color: #000080;">New</span> hget
<span style="color: #000080;">Dim</span> f <span style="color: #000080;">As</span> FolderItem
<span style="color: #000080;">Dim</span> i, n <span style="color: #000080;">As</span> <span style="color: #000080;">Integer</span>
<span style="color: #000080;">Dim</span> s, a, filename <span style="color: #000080;">As</span> <span style="color: #000080;">String</span>
<span style="color: #000080;">Dim</span> b <span style="color: #000080;">As</span> <span style="color: #000080;">Boolean</span>
&nbsp;
b = <span style="color: #000080;">true</span>
&nbsp;
  <span style="color: #000080;">for</span> i = 0 <span style="color: #000080;">to</span> Len(TextField1.Text)
&nbsp;
    s = Right(TextField1.Text, i)
&nbsp;
    a = Mid(s, 1 ,1)
&nbsp;
    <span style="color: #000080;">if</span> a = <span style="color: #800000;">&quot;/&quot;</span> <span style="color: #000080;">and</span> b = <span style="color: #000080;">true</span> <span style="color: #000080;">then</span>
&nbsp;
      b= <span style="color: #000080;">false</span>
      n = i
&nbsp;
    <span style="color: #000080;">end</span>
&nbsp;
  <span style="color: #000080;">next</span>
&nbsp;
  filename = Right(TextField1.Text, n - 1)
&nbsp;
  f = SpecialFolder.Desktop.Child(filename)
&nbsp;
  d.Yield = <span style="color: #000080;">True</span>
&nbsp;
  <span style="color: #000080;">if</span> f.Exists = <span style="color: #000080;">false</span> <span style="color: #000080;">then</span>
&nbsp;
    Window1.Listbox1.AddRow <span style="color: #800000;">&quot;Creating file: &quot;</span> + Str(f.DisplayName)
&nbsp;
    d.<span style="color: #000080;">get</span> (TextField1.Text,f)
&nbsp;
  <span style="color: #000080;">elseif</span> f.Exists = <span style="color: #000080;">true</span> <span style="color: #000080;">then</span>
    Return
<span style="color: #000080;">end</span></pre></td></tr></table></div>

<h3>Download</h3>
<p>	<div class='ArePayPalContent'>
	<p class='ArePayPalTextToShowIfNotLogedIn'>If you see this message you probably want access special material for Premium Members (Source Files, Bonus Tutorials, free Classes and More). You can do this by subscribing REALbasic City site for 10 USD (access for 3 months). There is also a option to buy access only to this material. Login or register to get option to buy and support REALbasic City.</p>
	<a class='ArePayPalLoginButton' href='http://tutspolis.com/wp-login.php'>Log in</a>
	</div></p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://realbasic.tutspolis.com/tutorials/download-manager-in-realbasic/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>Weather software in REALbasic</title>
		<link>http://realbasic.tutspolis.com/tutorials/weather-software-in-realbasic/</link>
		<comments>http://realbasic.tutspolis.com/tutorials/weather-software-in-realbasic/#comments</comments>
		<pubDate>Sun, 25 Oct 2009 19:24:09 +0000</pubDate>
		<dc:creator>Jakub Pawlak</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[download]]></category>
		<category><![CDATA[httpsocket]]></category>
		<category><![CDATA[image]]></category>
		<category><![CDATA[realbasic]]></category>
		<category><![CDATA[weather]]></category>
		<category><![CDATA[yahoo]]></category>

		<guid isPermaLink="false">http://realbasic.tutspolis.com/?p=133</guid>
		<description><![CDATA[<!-- isPostPurchased ,postID 133, userID 0, combination 1 -->
			
				
			
		
In this tutorial we will create a Weather software using our favorite cross-platform software development environment REALbasic. Learn how to download a file using HTTPSocket, how to format text and how to find text between two strings. Watch it, learn it, enjoy it!


Creating the GUI
Add to your Window Class 8 x StaticText Control and 1 [...]]]></description>
			<content:encoded><![CDATA[<!-- isPostPurchased ,postID 133, userID 0, combination 1 --><div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Frealbasic.tutspolis.com%2Ftutorials%2Fweather-software-in-realbasic%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Frealbasic.tutspolis.com%2Ftutorials%2Fweather-software-in-realbasic%2F&amp;source=REALbasicCity&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p>In this tutorial we will create a Weather software using our favorite cross-platform software development environment REALbasic. Learn how to download a file using HTTPSocket, how to format text and how to find text between two strings. Watch it, learn it, enjoy it!</p>
<p><span id="more-133"></span></p>
<div style="margin-left:19px;float:left">
<h2>Creating the GUI</h2>
<p>Add to your Window Class 8 x StaticText Control and 1 x Canvas Control. Try to put this controls like on the screenshot below. In our example we will download and format weather data for Polish city Wroclaw. Of course there are no problems to change it for your city. Add in code editor a New Property s As String. We will hold there the downloaded web page.</p>
<p><img src="http://realbasic.tutspolis.com/files/tutorials/weather.png" alt="Weather software in REALbasic" /></p>
<p>Before we start please notice that the data (conditions, forecasts, news, images, logos) contained in weather.yahoo.com are copyrighted by Yahoo! Inc. and the Weather Channel Enterprises, Inc. You are prohibited from using or repurposing this data in any way without express written consent from Yahoo! Inc. and the Weather Channel Enterprises, Inc. If you are looking for a source of weather data, please see the National Weather Service Website at http://www.nws.noaa.gov/. Their data is public information, to be used with appropriate byline/photo/image credits. This tutorial shows only some techniques allowing you download a file and render some data. </p>
<h2>Find text between two strings</h2>
<p>Add a New Method and enter for Method Name: getData for Parameters: KeyQuery As String, KeyQuery2 As String, data As String and for Result: String. Insert then the code below. If you don&#8217;t understand what is going here please visit <a href="http://realbasic.tutspolis.com/tutorials/mid-and-instr-functions-in-realbasic/">Mid and InStr Functions in REALbasic</a> tutorial for better orientation.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code"><pre class="vb" style="font-family:monospace;"><span style="color: #000080;">Dim</span> KeyStart <span style="color: #000080;">As</span> <span style="color: #000080;">String</span> = KeyQuery
<span style="color: #000080;">Dim</span> KeyEnd <span style="color: #000080;">As</span> <span style="color: #000080;">String</span> = KeyQuery2
&nbsp;
Return Mid( Data, InStr( Data, KeyStart ) + Len(KeyStart), InStr( Data, KeyEnd ) - (InStr( Data, KeyStart) + Len(KeyStart) ) )</pre></td></tr></table></div>

<h2>Download image using HTTPSocket</h2>
<p>Create a New Method and name it getImage. In this method we will find the graphics on the web page, download it to our hard drive and load it to our application.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
</pre></td><td class="code"><pre class="vb" style="font-family:monospace;"><span style="color: #000080;">Dim</span> f <span style="color: #000080;">As</span> FolderItem
<span style="color: #000080;">Dim</span> p <span style="color: #000080;">As</span> Picture
<span style="color: #000080;">Dim</span> http <span style="color: #000080;">as</span> <span style="color: #000080;">New</span> HTTPSocket
<span style="color: #000080;">Dim</span> pictureurl <span style="color: #000080;">As</span> <span style="color: #000080;">String</span>
&nbsp;
f = getTemporaryFolderItem() //temporary folder location <span style="color: #000080;">to</span> save image
&nbsp;
pictureurl = getData(<span style="color: #800000;">&quot;http://l.yimg.com/a/i/us/nws/weather/gr/&quot;</span>, <span style="color: #800000;">&quot;.png&quot;</span>, s) //find the picture name from source code
&nbsp;
<span style="color: #000080;">dim</span> result <span style="color: #000080;">as</span> <span style="color: #000080;">boolean</span> = http.<span style="color: #000080;">get</span>(<span style="color: #800000;">&quot;http://l.yimg.com/a/i/us/nws/weather/gr/&quot;</span> + pictureurl + <span style="color: #800000;">&quot;.png&quot;</span>, f, 10) //download <span style="color: #000080;">and</span> save the picture
&nbsp;
<span style="color: #000080;">if</span> result <span style="color: #000080;">then</span>
    f.MacCreator = <span style="color: #800000;">&quot;prvw&quot;</span>
    f.MacType = <span style="color: #800000;">&quot;PNG&quot;</span>
    p = f.openAsPicture() //load the picture from hard drive <span style="color: #000080;">to</span> memory
    Canvas1.Backdrop = p //load the picture <span style="color: #000080;">to</span> Canvas1 <span style="color: #000080;">Control</span>
<span style="color: #000080;">end</span> <span style="color: #000080;">if</span>
&nbsp;
http.<span style="color: #000080;">Close</span></pre></td></tr></table></div>

<h2>Download and format Yahoo! Weather data</h2>
<p>Ok, when we view http://weather.yahoo.com/Wroclaw-Poland/PLXX0029/forecast.html page source we will find a HTML dl Tag with all data we like to use in our REALbasic Weather application.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
</pre></td><td class="code"><pre class="html" style="font-family:monospace;">&lt;dl&gt;
&lt;dt&gt;Feels Like:&lt;/dt&gt;&lt;dd&gt;57°&lt;/dd&gt;
&lt;dt&gt;Barometer:&lt;/dt&gt;&lt;dd&gt;30 in and steady&lt;/dd&gt;
&lt;dt&gt;Humidity:&lt;/dt&gt;&lt;dd&gt;72%&lt;/dd&gt;
&lt;dt&gt;Visibility:&lt;/dt&gt;&lt;dd&gt;6.21 mi&lt;/dd&gt;
&lt;dt&gt;Dewpoint:&lt;/dt&gt;&lt;dd&gt;48°&lt;/dd&gt;
&lt;dt&gt;Wind:&lt;/dt&gt;&lt;dd&gt;ESE 8 mph&lt;/dd&gt;
&lt;dt&gt;Sunrise:&lt;/dt&gt;&lt;dd&gt;6:32 am&lt;/dd&gt;
&lt;dt&gt;Sunset:&lt;/dt&gt;&lt;dd&gt;4:40 pm&lt;/dd&gt;
&lt;/dl&gt;</pre></td></tr></table></div>

<p>Now we try to find and format this data and display it in our StaticText Controls. Let&#8217;s do it!</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
</pre></td><td class="code"><pre class="vb" style="font-family:monospace;"><span style="color: #000080;">Dim</span> http <span style="color: #000080;">as</span> <span style="color: #000080;">New</span> HTTPSocket
<span style="color: #000080;">Dim</span> part <span style="color: #000080;">As</span> <span style="color: #000080;">String</span>
&nbsp;
s = http.<span style="color: #000080;">Get</span>(<span style="color: #800000;">&quot;http://weather.yahoo.com/Wroclaw-Poland/PLXX0029/forecast.html&quot;</span>,30)
&nbsp;
part = getData(<span style="color: #800000;">&quot;&lt;dl&gt;&quot;</span>,<span style="color: #800000;">&quot;&lt;/dl&gt;&quot;</span>, s) //grab only the data we will need 
&nbsp;
StaticText1.Text = <span style="color: #800000;">&quot;Feels Like: &quot;</span> + getData(<span style="color: #800000;">&quot;Feels Like:&lt;/dt&gt;&lt;dd&gt;&quot;</span>,<span style="color: #800000;">&quot;&lt;/dd&gt;&quot;</span>, part)
&nbsp;
part = Replace(part, <span style="color: #800000;">&quot;&lt;/dd&gt;&quot;</span>, <span style="color: #800000;">&quot;&quot;</span>) //this will give us a <span style="color: #000080;">option</span> <span style="color: #000080;">to</span> find <span style="color: #000080;">next</span> <span style="color: #000080;">end</span> of &lt;/dd&gt;
&nbsp;
StaticText2.Text = <span style="color: #800000;">&quot;Barometer: &quot;</span> + getData( <span style="color: #800000;">&quot;Barometer:&lt;/dt&gt;&lt;dd&gt;&quot;</span> ,<span style="color: #800000;">&quot;&lt;/dd&gt;&quot;</span> , part)
&nbsp;
part = Replace(part, <span style="color: #800000;">&quot;&lt;/dd&gt;&quot;</span>, <span style="color: #800000;">&quot;&quot;</span>)
&nbsp;
StaticText3.Text = <span style="color: #800000;">&quot;Humidity: &quot;</span> + getData(<span style="color: #800000;">&quot;Humidity:&lt;/dt&gt;&lt;dd&gt;&quot;</span>,<span style="color: #800000;">&quot;&lt;/dd&gt;&quot;</span>, part)
&nbsp;
part = Replace(part, <span style="color: #800000;">&quot;&lt;/dd&gt;&quot;</span>, <span style="color: #800000;">&quot;&quot;</span>)
&nbsp;
StaticText4.Text = <span style="color: #800000;">&quot;Visibility: &quot;</span> + getData(<span style="color: #800000;">&quot;Visibility:&lt;/dt&gt;&lt;dd&gt;&quot;</span>,<span style="color: #800000;">&quot;&lt;/dd&gt;&quot;</span>, part)
&nbsp;
part = Replace(part, <span style="color: #800000;">&quot;&lt;/dd&gt;&quot;</span>, <span style="color: #800000;">&quot;&quot;</span>)
&nbsp;
StaticText5.Text = <span style="color: #800000;">&quot;Dewpoint: &quot;</span> + getData(<span style="color: #800000;">&quot;Dewpoint:&lt;/dt&gt;&lt;dd&gt;&quot;</span>,<span style="color: #800000;">&quot;&lt;/dd&gt;&quot;</span>, part)
&nbsp;
part = Replace(part, <span style="color: #800000;">&quot;&lt;/dd&gt;&quot;</span>, <span style="color: #800000;">&quot;&quot;</span>)
&nbsp;
StaticText6.Text = <span style="color: #800000;">&quot;Wind: &quot;</span> + getData(<span style="color: #800000;">&quot;Wind:&lt;/dt&gt;&lt;dd&gt;&quot;</span>,<span style="color: #800000;">&quot;&lt;/dd&gt;&quot;</span>, part)
&nbsp;
part = Replace(part, <span style="color: #800000;">&quot;&lt;/dd&gt;&quot;</span>, <span style="color: #800000;">&quot;&quot;</span>)
&nbsp;
StaticText7.Text = <span style="color: #800000;">&quot;Sunrise: &quot;</span> + getData(<span style="color: #800000;">&quot;Sunrise:&lt;/dt&gt;&lt;dd&gt;&quot;</span>,<span style="color: #800000;">&quot;&lt;/dd&gt;&quot;</span>, part)
&nbsp;
part = Replace(part, <span style="color: #800000;">&quot;&lt;/dd&gt;&quot;</span>, <span style="color: #800000;">&quot;&quot;</span>)
&nbsp;
StaticText8.Text = <span style="color: #800000;">&quot;Sunset: &quot;</span> + getData(<span style="color: #800000;">&quot;Sunset:&lt;/dt&gt;&lt;dd&gt;&quot;</span>,<span style="color: #800000;">&quot;&lt;/dd&gt;&quot;</span>, part)
&nbsp;
getImage //download <span style="color: #000080;">and</span> load the image into Canvas1 <span style="color: #000080;">Control</span></pre></td></tr></table></div>

<h3>Download</h3>
<p>	<div class='ArePayPalContent'>
	<p class='ArePayPalTextToShowIfNotLogedIn'>If you see this message you probably want access special material for Premium Members (Source Files, Bonus Tutorials, free Classes and More). You can do this by subscribing REALbasic City site for 10 USD (access for 3 months). There is also a option to buy access only to this material. Login or register to get option to buy and support REALbasic City.</p>
	<a class='ArePayPalLoginButton' href='http://tutspolis.com/wp-login.php'>Log in</a>
	</div></p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://realbasic.tutspolis.com/tutorials/weather-software-in-realbasic/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Creating a Class in REALbasic</title>
		<link>http://realbasic.tutspolis.com/tutorials/creating-a-class-in-realbasic/</link>
		<comments>http://realbasic.tutspolis.com/tutorials/creating-a-class-in-realbasic/#comments</comments>
		<pubDate>Wed, 23 Sep 2009 11:03:51 +0000</pubDate>
		<dc:creator>Jakub Pawlak</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[class]]></category>
		<category><![CDATA[creating]]></category>
		<category><![CDATA[httpsocket]]></category>
		<category><![CDATA[realbasic]]></category>
		<category><![CDATA[using]]></category>

		<guid isPermaLink="false">http://realbasic.tutspolis.com/?p=69</guid>
		<description><![CDATA[<!-- isPostPurchased ,postID 69, userID 0, combination 1 -->
			
				
			
		
Class is a great way to make some things faster by saving the time of producing the code. Wrote it once, use it always. Learn how to create and how to use own Class in REALbasic. Watch it, learn it, enjoy it!


Definition of Class by Wikipedia
In object-oriented programming, a class is a programming language construct [...]]]></description>
			<content:encoded><![CDATA[<!-- isPostPurchased ,postID 69, userID 0, combination 1 --><div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Frealbasic.tutspolis.com%2Ftutorials%2Fcreating-a-class-in-realbasic%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Frealbasic.tutspolis.com%2Ftutorials%2Fcreating-a-class-in-realbasic%2F&amp;source=REALbasicCity&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p>Class is a great way to make some things faster by saving the time of producing the code. Wrote it once, use it always. Learn how to create and how to use own Class in REALbasic. Watch it, learn it, enjoy it!</p>
<p><span id="more-69"></span></p>
<div style="margin-left:19px;float:left">
<h2>Definition of Class by Wikipedia</h2>
<p>In object-oriented programming, a class is a programming language construct that is used as a blueprint to create objects of that class. This blueprint describes the state and behavior that the objects of the class all share. An object of a given class is called an instance of the class. The class that contains that instance can be considered as the type of that object, e.g. a type of an object of the &#8220;Fruit&#8221; class would be &#8220;Fruit&#8221;.</p>
<h2>Creating a Class in REALbasic</h2>
<p>Run REALbasic IDE and go to Project TAB. Click there on Add Class button and select created Class1.</p>
<p><img src="http://realbasic.tutspolis.com/files/tutorials/creatingclass/chtmlclass-1-realbasic.png" alt="realbasic add class" /></p>
<p>Now go to  Property and Value and change the Name from Class1 to cHTTP and add to Super value HTTPSocket. Double click on cHTML Class in Project TAB.</p>
<p><img src="http://realbasic.tutspolis.com/files/tutorials/creatingclass/chtmlclass-2-realbasic.png" alt="realbasic class property and value" /></p>
<h2>Add Method and Add Property</h2>
<p>In code editor for this class we will create a new Property, so click Add Property and in Declaration type Data in As type String.  </p>
<p><img src="http://realbasic.tutspolis.com/files/tutorials/creatingclass/chtmlclass-3-realbasic.png" alt="realbasic class code editor" /></p>
<p>Our next step will be creating a new Method. Click on Add Method button next to Add Property and enter for Method Name downloadHTML. Now insert this code below.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code"><pre class="vb" style="font-family:monospace;">Data = Me.<span style="color: #000080;">Get</span> (<span style="color: #800000;">&quot;http://tutspolis.com&quot;</span>, 3 )
&nbsp;
Me.<span style="color: #000080;">Close</span></pre></td></tr></table></div>

<p>The HTTPSocket has got a option called Get with will simply in this case get the html code of indicated URL. Our class will download for us the HTML from tutspolis.com.</p>
<h2>Using a Class in REALbasic project</h2>
<p>Now in GUI builder we will have a new control called cHTML. We can simply drag and drop it to our Window. To try out our new class add to the  Window controls TextArea and PushButton. Double click on PushButton and enter the code:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code"><pre class="vb" style="font-family:monospace;"><span style="color: #000080;">Dim</span> tuts <span style="color: #000080;">As</span> <span style="color: #000080;">new</span> cHTML
&nbsp;
tuts.downloadHTML // <span style="color: #000080;">get</span> the html code
TextArea1.Text =  tuts.Data // display it <span style="color: #000080;">in</span> TextArea <span style="color: #000080;">control</span></pre></td></tr></table></div>

<h2>The effect</h2>
<p>When we will press PushButton, TextArea will fill up with HTML code of tutspolis.com home page. You can now for example render the code, modify it or get only some important for you information. It can be also done in class cHTML on other Method.</p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://realbasic.tutspolis.com/tutorials/creating-a-class-in-realbasic/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
