New topic: My first project
<http://forums.realsoftware.com/viewtopic.php?t=46131> Page 1 of 1 [ 3 posts ] Previous topic | Next topic Author Message mrxyz Post subject: My first projectPosted: Tue Dec 04, 2012 4:28 am Joined: Tue Dec 04, 2012 3:34 am Posts: 1 Hi, I am completely new to RS. My programming project is to make a temperature monitor doing the following steps. 1. Read data from a web server with temperature readings 2. Parse the text data and extract the temperature data 3. Analyse the temperatures, if the temperature drops below or rises above a certain threshold, make an alarm by sending an email Sound easy, but I already met the wall. I have investigated the sample files and the documentation but are not able to figure out how to get the data from the webpage into a variable. Can someone help me? Karl Top alexvs Post subject: Re: My first projectPosted: Tue Dec 04, 2012 5:45 am Joined: Fri Feb 12, 2010 1:32 pm Posts: 208 Location: Switzerland mrxyz wrote:Sound easy, but I already met the wall. I have investigated the sample files and the documentation but are not able to figure out how to get the data from the webpage into a variable. Welcome to Realstudio Look at the language reference: http://docs.realsoftware.com/index.php/HTTPSocket There's an example down the page: Dim socket1 As New HTTPSocket Dim data As String = socket1.Get("http://www.realsoftware.com/", 30) Top p0wn3d Post subject: Re: My first projectPosted: Tue Dec 04, 2012 8:39 am Joined: Sun Oct 28, 2012 4:54 am Posts: 40 I am a complete beginner too but learning slowly Try this quick example I am sure that there is a much better way but maybe is enough to get you started hopefully. Just drag a TextArea + Label + Pushbutton onto a new form and add the following code behind the pushbutton Action event. Dim myTextFileContents As String Dim http As New HTTPSocket http.Yield = True myTextFileContents = http.Get("http://justgoodit.web44.net/TempSensor.html", 10) TextArea1.text = myTextFileContents Dim rg as New RegEx Dim myMatch as RegExMatch rg.SearchPattern="sensor2..." myMatch=rg.search(TextArea1.text) if myMatch <> Nil then Label1.text=myMatch.SubExpressionString(0) Dim s as string = Label1.text s = right(s, Len(s)-8) If s <= "50" then MsgBox("temp below 50 send email alert") //Send email code //http://docs.realsoftware.com/index.php/SMTPSocket else Msgbox("temp normal do nothing") end end if Top Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending Page 1 of 1 [ 3 posts ] -- Over 1500 classes with 29000 functions in one REALbasic plug-in collection. The Monkeybread Software Realbasic Plugin v9.3. http://www.monkeybreadsoftware.de/realbasic/plugins.shtml [email protected]
