It would be nice if we could make a USD to EUR converter in REALbasic? Studding Mid and InStr Functions in REALbasic and Creating a Class in REALbasic you can do it! Let me show you how. Watch it, learn it, enjoy it!
Use two TextFields Controls and one PushButton. Try to get result something like on this image. Please note that you can make this application on Windows or Linux too. I prefer Mac OS, you can use what you like – REALbasic is cross-platform.

Go to Project TAB and create Class called cHTTP. Then add to Super value HTTPSocket. In code editor for cHTTP Class create a new Property and in Declaration type code and in As type String. Great! Now Add Method and enter for Method Name: convertHTML for Parameters: KeyQuery As String, KeyQuery2 As String, data As String and for Result: String. Insert then the code below:
1 2 3 4 | Dim KeyStart As String = KeyQuery Dim KeyEnd As String = KeyQuery2 Return Mid( Data, InStr( Data, KeyStart ) + Len(KeyStart), InStr( Data, KeyEnd ) - (InStr( Data, KeyStart) + Len(KeyStart) ) ) |
Create new Method called downloadHTML and use this code. When we type in Google search ex. 20 USD to EUR we will get the result between h2 class=”r” style=”font-size:138%” and /h2. If we know this than we are done with work.
1 2 3 4 5 6 7 8 9 | Dim Data As String Data = Me.Get ("http://www.google.com/search?hl=en&q=" + (Window1.TextField2.text) + "+USD+in+EUR&aq=f&oq=&aqi=g1", 3 ) code = convertHTML( "h2 class=r style=" + chr(34) + "font-size:138%" + chr(34) + "><b>" , "</b></h2>", Data ) Window1.TextField1.Text = code Me.Close |
PushButton1 Sub Action ()
1 2 3 | Dim tuts As new cHTML tuts.downloadHTML |
Thanks for the example, but I believe that I’ve done something wrong. My code get hung up on the Data = Me.Get …
Any ideas?
Frank
Simply use this link. Google has changed something…
http://www.google.com/search?hl=en&source=hp&q=20+usd+in+euro&aq=1&aqi=g10&oq=20+USD+in+
Thanks for that, but what I mean is that realbasic is throwing an error on the command ‘me.get’ part.
http://realbasic.tutspolis.com/articles/realbasic-tip-me-in-realbasic/