Dates for REAL World ‘09
REAL Software just sent out a newsletter and listed the dates of next year’s REAL World conference:
May 4-6, 2009
It’s cool that we know so far ahead of time…
…but it’s MORE than a whole year away! =:(
Well, make plans for it now — I’d like to meet you there!
Jay
My First Yuma Sample
I figure that since Yuma is REALbasic under the hood (kind of ) that it should be fair game for this blog. =:)
This morning, instead of going to bed like I ought, I stayed up and wrote my first Yuma code. It’s very simple, just opens a SQLite database and reads in some data, then prints it to the web page. No classes, functions, etc, just some straight-ahead code.
Here’s the first chunk of Yuma code that goes at the top of the page:
<?yuma
dim srdata as SQLiteDatabase
dim rs as RecordSet
dim cnct as Boolean
dim articles() as String
srdata = New SQLiteDatabase
srdata.DatabaseFile = GetFolderItem("aa.rsd")
cnct = srdata.Connect
rs = srdata.SQLSelect("select title from articles")
while not rs.eof
articles.Append rs.Field("title").StringValue
rs.MoveNext
wend
srdata.Close
?>
One thing I want to mention right off the bat is this is NOT the way to write code — there’s no error- checking. But I wanted to make it as short as possible just to showcase the “good stuff.”
Just like regular RB code, you dimension your variables ahead of time, then create a FolderItem for the aa.rsd file, connect to the database, and finally get a RecordSet as the result of a SQL select statement.
Oh, the other thing I did there was instead of just printing out the data, I used Array.Append to fill the articles() array with the data — we’ll use it in the second chunk of code.
Here’s the second (and last) chunk of code — it’s the main part of the actual HTMP page:
<html>
<head><title>Yuma Database Sample</title></head>
<body>
<p>
<?yuma
dim x, numArticles as Integer
numArticles = UBound(articles)
for x = 0 to numArticles
print str(x+1) + ". " + articles(x) + "<br/>"
next
?>
<p/>
</body>
</html>
Right inside the body of the page we have another Yuma code block that simply finds out how big the articles() array is and then loops over it to print the data to the screen.
That block of code is in just about the simplest HTML page you can create, but there’s nothing stopping it from being inside a big honkin’ prettified web page.
Just for the fun of it, you could even do something like this — break the block up so that it loops over the rows of a table:
<table width="600">
<?yuma
dim x, numArticles as Integer
numArticles = UBound(articles)
for x = 0 to numArticles
?>
<tr>
<td>
<?yuma print str(x+1) + ". " + articles(x) + "<br/>" ?>
</td>
</tr>
<?yuma next ?>
</table>
Notice the “next” part of the for loop is in a different chunk of Yuma code — it doesn’t care, it still knows it belongs with the code above.
Put those two chunks of code on one .yuma page, make sure you have a database file called aa.rsd containing a table called articles and a column called title, and you’re in business!
If you haven’t download the development version of Yuma, get to it — it’s free and cross-platform.
I really wish I’d had Yuma last fall when I was porting a bunch of my REALbasic desktop apps to PHP. That silliness is going to stop now! =;)