Wednesday, August 23, 2006

J.S, Bach's Brandenburg Concertos: A HTMLViewer Example

Sorry that I haven't updated this blog recently, but my wife had double knee replacement surgery on June 15. I don't drive a car (I haven't done so for twenty years or more), and - until this past week - my wife hasn't been able to drive either, so life has been a bit difficult (and would have been a lot more difficult if it had been for the kind helpfulness of some very good friends).

I've uploaded to http://traver.org/traverrb/ a simple example of a HTMLViewer program. The source code is in Bach.zip. The program is unpolished, but you may enjoy it if you (like me) like the "Baroque croak." Some people consider J.S. Bach to be one of the greatest composers of all time (and I'm among that number).

If you have a firewall installed, the first time you run the program you may need to let the firewall know that you are giving Bach.exe permission to access the Internet. Also, I recommend broadband access (cable or DSL).

Two additional program notes:

(1) If 2/3 sounds familiar, it's because it was used as a theme song for William F. Buckley, Jr.'s "Firing Line."

(2) It's not a mistake: There is a reason for 3/2 being only 13 seconds long (see the main Program Notes for details).

One nice thing about the program is that - once compiled - there is no complicated installation. Put it anyplace you want, and run it from there. Similarly, there is no complicated uninstall process: just delete the file, and that's all that needs to be done.

It has only been tested on a Windows PC, so I would be glad to hear whether the program also works on a Mac or Linux. As always, feedback is much appreciated.

Barry Traver

Saturday, June 17, 2006

More on HTML-RTF for English BIble

There's an improved version available with fewer bugs: HTML-RTF2.zip at http://traver.org/traverrb/.

Changes include better handling of paragraphing and curly quotes (although mdash still needs some work for RTF).

What does the program illustrate? Two things, primarily:

(1) How to retrieve HTML code for a Web page at a certain URL, how to extract data from the Web page, and how to create HTML code for a new Web page making use of that extracted data.

(2) How to create an RTF file.

The latter doesn't really "create" an RTF file from scratch: It simply modifies an existing RTF file, inserting text, superscripts, etc., where appropriate.

Using this approach, you can get by without really understanding the details of RTF (which can be a Good Thing).

Thus the beginning and the end of the RTF file that is created is taken from an already-existing RTF file. (If you'd like, say, a different font, then either modify the code appropriately or use WordPad to create what you want and save that as an RTF file to use as your starting point.)

Right now I'm working on a program which - if you provide an address (street, city, state, and zip) - will give you the latitude and longitude for that location. When finished, I expect (as usual) to make it available to readers of this blog.

You may have little use for such information, but the point is that the program is another sample program illustrating how to use REALbasic to retrieve information from the Web.

It so happens that I do have a practical use for such a program, but even a useless program has its usefulness if it can be used as a sample program from which one can build a more useful program.

I'd be interested in hearing about (or seeing other examples of) how people are putting HTMLViewer and HTTPSocket to use in their programs.

Barry Traver

P.S. Here's a list of what the abbreviations stand for in the Bible translations mentioned last time: KJV - King James Version, NASB - New American Standard Bible, NIV - New International Version, NKJV - New King James Version, and ESV - English Standard Version.

Friday, June 16, 2006

HTML-RTF: Another Web-Related Program

HTML-RTF is a program I wrote for a friend who is the Web manager of a church denominational Web site. It make use of data retrieved at http://www.biblegateway.com/.

OK. Here's what the program does (as I described it to him)....

"You indicate Testament (O.T. or N.T.), Book, Chapter, Verses, and Translation (choice of five for now, KJV, NASB, NIV, NKJV, and ESV). You click on 'Make HTML.'

"The program makes the HTML and displays the result in two panes in the window. The bottom pane displays the HTML code, and the top pane displays what the HTML code will look like in a standard Web browser. In addition, the program will put the HTML code into the Windows clipboard. ready to paste, say, into a field in the admin editing area for "Devotional" or whatever.

"Next you use File --> Save as RTF to save the equivalent in RTF format (so that the RTF file can be later Inserted into a WPWin or WinWord document).

"The program at this point preserves (for both HTML and RTF) the Scripture text, superscripted verse numbers, italics, and "curly quotes" (single and double). It is also specifically set NOT to show notes or cross-references. In addtion, for KJV each verse is put on a separate line, while for other translations the verses are divided into multi-verse paragraphs (with a blank line between paragraphs). Section headings within the passages are automatically removed.

"You have to be on the Internet (preferably broadband) to use this program. Also, the first time you run it, if you're running a firewall give your firewall a few moments to ask you if you want to allow my program to access the Internet. (Say, 'Yes.')"

My coding is a bit sloppy (I hope to post a cleaned-up version sometime in the future), but you should be able to figure out basically what's going on. (As usual, you'll find thte source code, HTML-RTF.zip, at http://traver.org/traverrb/.)

The program has been tested on Windows, but not on the Mac or Linux. (I hope to have some comments on the coding for you in the next blog entry.)

Enjoy!

Barry Traver

P.S. Please send bug reports and other commments to me at rblog@ix.netcom.com. Thanks!

Saturday, May 06, 2006

Accessing the Web Using REALbasic

There are two essential things you need to know about in order to do things on the Web using REALbasic: a function called HTTPSocket and a control called HTLMViewer.

Here's the main difference between them. HTLMViewer allows you to View Web pages that have been written in HTML (or XHTML). You don't see the HTML (or XHTML) code itself: what you see is what you would see if you were to visit that page using a normal Web browser. HTTPSocket, on the other hand, actually Gets the HTML (or XHTML) file for you (or any other file whose URL you know on the remove Web server, such as a GIF or JPG file, an MP3 or MPG file, a PDF file, etc.).

So HTMLViewer lets you View a Web page, while HTTPSocket Gets the actual file ("Socket to Me!") for you (not just HTML or XHMTL, but any type of file you can access using HTTP).

I should start out with some simple examples for you, but I'll probably provide such later. The file for to day is NTGreek3.zip, which can be downloaded from http://traver.org/traverrb/.

Here's how the program works....

It's a NT (New Testament) Greek computer program that I wrote which allows you to look up a particular verse (or groups of verses in a chapter), to get the grammatical analysis for a particular word, and to see a literal word-for-word translation.

You do have to have Windows to run the program. A broadband connection to the Internet (cable or DSL) is also recommended. In addition (nd this won't mean much to you unless you're a student of New Testament Greek, the program has the limitation that the grammatical analysis is based on the Nestle Aland text, 26th edition, while the literal translation is based on the Textus Receptus. Even so, I think it's a useful program. (I'm at present tutoring an Indonesian pastor in Greek, so the program was written for his benefit.)

When you first run the program, your firewall program may ask you if you want to let the program access the Internet. Say, "Yes." (Important: You have to be connected to the Internet for the program to work.)

Select New Testament book, chapter, and verse(s). Then click on "Get Verse(s)." The program should get the appropriate verse(s) from the Greek New Testament for you. Click on a Greek word for a grammatical analysis (i.e., full parsing). Then click on "Get Verse(s)" to return to the Greek passage.

The code is not simple and I do not intend to explain the details at this point (especially since NTGreek3 is an "improved" version of NTGreek2 and NTGreek3 works better when I don't understand why it works at all, since I do not even return a value for the function HTTPSocket).

So the primary purpose of NTGreek3 for this blog is to show that you can do complicated things on the Internet (even if you don't really entirely know what you are doing?). In addition to viewing and getting files, you can extract useful information from Web pages and then create and display your own Web pages based on that extracted information.

As I said, I will try to provide some simpler examples of HTMLViewer and HTTPSocket in the future. But the NTGreek program (which, incidentally, has not been tested on a Mac, although it works fine in Windows) should illustrate that there is tremendous potential in the possibilities offered by HTMLViewer and HTTPSocket, if you want to write your own Web browser to do very particular things.)

Enjoy!

Barry Traver

Saturday, April 22, 2006

YahooMaps1: An RB Off-line Yahoo Maps Utility

First, let me mention that I am planning to coninue TraverToys, but I will be making one change: TraverToys will be given more descriptive names. To call something "TraverToy2" or "TraverToy5" is not, I've found, very helpful. Many of the programs will continue to be fairly simple examples of REALbasic code, but in the future the names will hopefully give at least some hint as to what the program is all about.

Second, an example of that is YahooMaps1, a new RB program which can be run without your being connected to the Internet. The purpose of YahooMaps1 is not to show you the map for a particular address (you'd have to be on-line in order for that to happen), but to create the HTML code for the current format (and Yahoo did apparently change their format) for the URL links to Yahoo maps for the U.S.

Incidentally, Yahoo Maps apparently do not currently like nine-digit zip codes. Check it out: Go to http://maps.yahoo.com/ and enter a valid address, including nine-digit zip code. It will probably show you the map but will probably say something like this: "Your search for ----- could not be found. Here is the closest match in a nearby city." It seems, however, to handle five-digit zip codes fine.

I've uploaded the first version of a program to create the URL for the Yahoo map for a particular address. It worked for addresses that I tried within the U.S. My program works mainly on street address and zip code (you can use the tab key to skip over the entry fields for city and state). If you don't have the zip code, you should be able to enter "city, state" in that field. Whenever you're finished entering the address, the Yahoo HTML code will be in the Windows clipboard. You can then paste it into a browser address field or a Web page or do whatever you want with it.

Note: the program is version 1, which means that desired modifications can be made. (For example, you could remove the fields for city and state, since they are really unnecessary, or make other changes in the interface. Or you could perhaps adapt the program to work with a database. If you make modifications to the program, I would appreciate it if you could send me a copy of the modified version. Thanks!)

Here's where you can find a helpful Yahoo page:

"How do I create links to Yahoo! Maps?"
     http://help.yahoo.com/help/us/maps/maps-26.html

As usual, the source code for my program (YahooMaps1.zip) can be downloaded from this location:

     http://traver.org/traverrb/

Enjoy!

Barry Traver

Thursday, February 16, 2006

Some Favorite, Frequenty-Used Functions

As you know, I usually add something new to this blog every other day on the average. Why the delay this time? The main reason is that I have Verizon high-speed DSL (or, rather that I was without Verizon DSL for five days).

I phoned Verizon on Thursday to let them know that I was unable to connect to the Internet. I was told that I would have service restored "in 48 to 72 hours." How does that become five days? Simple. Verizon does not work on the weekends. (They presumably operate following the non-Biblical injunction, "Five days shalt thou labor...." It's not enough for them to take Sunday off, they apparently need to take Saturday off as well.)

So I was without Verizon DSL for five days. I was given an "open ticket," but whenever I called up to check on it, all I got was a recorded message telling me that they were "still working on my problem" and that "no further information was available." That is, that's what I got when I got a response other than "we're experiencing a greater-than-usual call volume at this time. Please hang up and try your call again later." (That's after you go through the voice-driven automatic menu system, where you're told, "I don't understand. Please answer 'Yes' or 'No.'" either because you don't respond because it's not really a "yes/no" type question or because you do respond but Verizon's voice recognition software doesn't "understand.")

I did finally get through to talk with a genuine human being five days later and got to talk with a technical support person who walked me through the procedure to get myself connected to the Internet again. (No explanation was given as to why this could not have been done five days earlier, and the implication was given that I must have pressed the reset button on my modem, which I know is something that I did NOT do.) Since I get hundreds of emails a day, needless to say, I was not very happy about being off-line for five days, but perhaps my experience with Verizon explains why I have not been able to add a new entry to this blog until now.

I hope to have a new program or two available to you by tomorrow, but for now let's briefly consider the topic of "a few functions I've added to REALbasic, since I use them so often." (If you have such a list, I'd be very interested to see it.)

I think all of us probably have such routines, perhaps gathered together in a module that we include in our Projects. (I'm not quite that organized yet, but there are some things I find myself regularly adding to Projects, so I should probably get around to putting them into a module to make them more readily accessible.)

What are some of my useful add-on subs and functions? Here's one:

Function Mid1 (M As String, Pos1 As Integer, Pos2 As Integer) As String
   Return MidB (M, Pos1, Pos2 - Pos1 + 1)
End Function

I often prefer this to the regular Mid or MidB, because I often have in mind when doing a string extraction the starting position and the end postion, not the starting position and how many characters. For those people who don't have to even think about "Pos2 - Pos1 + 1," such a function is not needed, but I personally find it helpful.

When I want to find the first occurence of StringA or StringB within StringC (and I want whichever comes first, whether it be StringA or StringB), I use this function, assuming that A = InStrB(StringC, StringA) and B = InStrB(StringC, StringB):

Function MinNonZero (A As Integer, B As Integer) As Integer
   If A <> 0 And B = 0 Then
      Return A
   ElseIf A = 0 And B <> 0 Then
      Return B
   ElseIf A <> 0 And B <> 0 Then
      Return Min (A, B)
   ElseIf A = 0 And B = 0 Then
      Return 0
   End If
End Function

I'm sure that the following could be written much more efficiently, but sometimes I want to create a longer string based on repetitions of a shorter string. Then I use this:

Function Rpt (A As String, B As Integer) As String
   Dim I As Integer
   Dim M As String
   M = ""
   For I = 1 To B
   M = M + A
   Next I
   Return M
End Function

Or, if I want to count how many instances there are of a shorter string within a larger string, I use this:

Function HowMany (A As String, WhatToCount As String) As Integer
   Dim Counter As Integer
   Counter = CountFields (A, WhatToCount) - 1
   If Counter = - 1 Then Counter = 0
   Return Counter
End Function

Or, when I want to find the position of not the first occurence of a shorter string within a longer string, but the last occurence, I use this:

Function InStrBRev (Pos1 As Integer, String1 As String, String2 As String) As Integer
   Dim I As Integer
   I = Pos1
   Do
      I = I - 1
   If I = 0 Then Exit
      If MidB (String1, I, Len (String2) ) = String2 Then Exit
   Loop
   Return I
End Function

One function I use surprisingly often (perhaps partly because of working with CodeHelper and related programs is this one:

Function OutsideQuotes (s1 As String, Pos1 As Integer) As Boolean
   Dim A As String
   Dim Counter As Integer
   A = LeftB (s1, Pos1 - 1)
   Counter = HowMany (A, Q)
   If Counter Mod 2 = 0 Then
      Return True
   Else
      Return False
   End If
End Function

The routine determines whether the character at a certain position within a string is "inside quotation marks" or "outside quotation marks."

Many of these routines, you may have noticed, involve string handling, and more efficient versions of some of these can be found in Joe Strout's StringUtils module at http://www.strout.net/info/coding/rb/intro.html
"This is a public-domain module of string functions, including ways to reverse a string, remove or delete certain characters, convert a string into hex, handle fields containing quotes, measure the similarity of two strings, and more.

The archive contains an RB project file which runs the unit tests on the various StringUtils functions. Just drag the StringUtils module out of this project, then drag it into your own projects, and enjoy.

I wrote most of mine before that package was created, so mine do not take advantage of the more efficient procedures to be found there.

Barry Traver



Home Page for This Blog: http://traverrb.blogspot.com/

Programs and Files Discussed in the Blog: http://traver.org/traverrb/

Wednesday, February 08, 2006

Web Page Harvester Program: Some Preliminary Thoughts

Coming in the very near future is a program to "harvest" information (links, email addresses, and other informaiton) from Web pages.

Actually, I already had a program written like that ready to upload, but I decided to rewrite it from scratch, since - although it works perfectly on some sites - it fails to get all the information on some other sites. (And I'm not talking about those sites that have chosen - and quite properly so - to "obfuscate" email addresses to protect the addressees from spam mail.

If you find that Harvester can "harvest" email addresses on your own Web site, you'll be glad to know that the next program will show you how to protect yourself against most "spam robots" or "spambots." I'm not giving away any "secrets" in either program: the information is freely available on the Internet if you know where and how to look for it, but use of the techniques in the latter program can create an additional barrier that most spammers are too lazy to bother about.

I don't know whether it's true or not, but I read somewhere recently (in defense of XHTML) that half the code in most browser programs is devoted to dealing with sloppily written HTML. From my own experience I don't consider that an unlikely figure.

The Harvester program I wrote worked fine with many or most site with which I tried it, but there were some sites where it either missed and messed up the information on the links or (rarely) the email addresses (except, of course, for those pages where the email addresses were "obfuscated" on purpose). In some cases, it was not a matter of improperly written HTML, but simply complex HTML which contained some items my program had not made provision for.

For example, an easy fix was one for the proper handling of a Spanish "tilda n" or a French "c cedilla." But I found other problems that were not as easy to fix, and trying to do so was resulting in hard-to-follow spaghetti code as a result of all of the "band-aids" I was adding. So I decided that - rather than upload that program - it would be better to rewrite it from scratch.

What sort of things might cause a problem for a "harvester" program or at least need to be taken into account? (I'm sort of thinking out loud in today's blog entry.) Immediately, I can think of five.

One is the fact that a link or an email address does not have to appear entirely on one line. It may be split across a couple of lines (or even three, at least one instance of which I found and had to make adjustment for). Perhaps the easiest way to deal with this is to replace any end-of-line markers with a single blank space. That may or may not always work, if the line ends with a hyphen ("-") immediately before the line break. (I'll have to cehck on that.)

Another is the fact that, in general, extra spaces do not matter in HTML (but they DO matter in a "harvester" program). There are, however, cases where extra spaces DO matter in HTML (e.g., between ""<pre>" and ""</pre>" or within quotation marks). So a Web page "harvester" has to take into account such detais. In addition, there may (or may not) be some cases where HTML does't care whether there is a space or no space at all. (That's something else I'll have to check on, either by consulting the reference books or by experimenting myself.)

The obvious basic solution is for Harvester to remove any extra spaces, replacing groups of blank spacs with single blank spaces, BUT it has to be careful where to do this. (It cnnot do it, as I said, with groups of spaces within quotation marks or within a "<pre>" block.)

A third consideration is the matter of capitalization, something that UNIX and LINUSX servers care about (but not Windows NT). Fortunately, REALbasic makes this fairly simple to do (or at least, in general, simpler than in Visual Basic), because in (at least most) REALbasic string comparisions, case is ignored (but that is not always true), and most (but not all) of the time we want to ignore the case (xcept in filenames). Harvester has to do string searches and comparisons to perform its work, so the matter of case can be important.

A fourth thing you need to take into consideration is the matter of nested tags or the matter of attributes or values contained in qauotation marks (or not) within tags. For example, in HTML such nesting is often true of pairs of anchor tags ("<a [whatever]>" and "</a>"). Sometimes you may want to save what is inside the anchor tag (such as the information in the image tag, "<img src=[whaever]>").

Fifthly, you may want to deal with links to certain types of files (e.g., ".htm" and ".html" files) in a different way than you handle links to other types of files (e.g., ".jpg", "mpg", or "mp3" files). For reasons that I will not go into here, the first Harvester only "harvested" (and probably its successor will only "harvest") the information relating to "text links" (and thus not include any links to music files or links based on "thumbnails" among the link information that it harvests).

Have I left out anything important among the preliminary considerations? If so, please feel free to send me a private email or blog comments with your thoughts. Unlike C (I'm told), REALbasic is rich in built-in string functions, so we'll be making use of that fact in Harvester. The program also show how to download the contents of an HTML (or XHTML file) from the Inetnet. (We can't "harvest" information from a Web page on the Internet unless we are able to download that Web page from the Internet!)

Keep tuned....

Barry Traver



Home Page for This Blog: http://traverrb.blogspot.com/

Programs and Files Discussed in the Blog: http://traver.org/traverrb/

Monday, January 30, 2006

RB CodeHelper Lite: New "Better Beta" Available!

A new version of RB CodeHelper Lite is ready for people to beta-test, with some enhancements by Mark Nutter (read on!) and some bug fixes! I very much appreciate Mark's kind comments about the program as well as his his additions to the code.

Below are comments from two recent emails from him (the ">" indicates his quoting of my previous email, and ">>" indicates my quoting of his original email):

-------- Original Message --------
Subject: RB Code Helper Lite on Mac
Date: Thu, 26 Jan 2006
From: Mark Nutter
To: Barry Traver

Hi Barry,

I just downloaded RB Code Helper Lite, and since you asked for some
Mac vetting, I thought I'd send back some comments....

GUI issues: In the Source tab, the SourceTopGoButton does not look
right on my Mac--the font is distorted somehow due to being too big
to fit in the button. I changed the fontsize back to zero in the
IDE, and it looks much nicer on my system. Also the "Whole Word"
checkbox next to it was word-wrapping; I changed the width to 118
and it straightened out again.

I must say, though, it looks very good, and I'm very pleased with it.
I've been writing some articles for the RBLibrary, and I'm very
enthusiastic about having something like this around to help tidy up
and extract the source code listings for my articles. I did a bit of
playing around with the source code since you were kind enough to
include it, and I'm sending back a contribution, if you're
interested. I've shoehorned in an Acrobat-style bookmarks pane
beside the source code view, i.e., a hierarchical listbox that gives
all the objects in the source code, and underneath, if you click on
the disclosure rectangle, each of the methods in the object.
Double-clicking on any item takes you to the source code for that
item in the listing.

It's just a rough cut, but I thought it might interest you. It gave
me a few hours amusement :) I hooked it into your DoIndent method
and your GetCurrentX and GetCurrentS methods, and [it] wasn't too
hard once I figured out your code enough to keep track of where each
method was appearing in the final text buffer. It could use a nice
SplitPane control so it could be resized, but otherwise it seems to
be working fairly nicely now. Take the code and do with it as you
will, I am making it as a contribution in thanks/return for your own.

I also added Cut/Copy/Paste to the Edit menu and disabled the code
for hiding it, but that was just for my own personal utility so I
could cut and paste the code listings; hope you don't mind my messing
with that. I tried to mark all my code changes with "////// mn" so
hopefully you should be able to find everything by searching for that
particular string.

Thanks again for all the work you put into this, it looks like a
cool/clever/useful tool.

Cheers.

Mark

---End of Original Message ---

-------- Original Message --------
Subject: Re: RB Code Helper Lite on Mac
Date: Thu, 26 Jan 2006
From: Mark Nutter
To: Barry Traver

>... Incidentally, when downloading a text file from the Internet, RB
>CodeHelper Lite (RBCHL) can tell you after it is downloaded (and
>unzipped, if necessary) whether it's a Mac file, a Windows file, or
>a Linux file. It's commented out, but it's in the OpenXMLFile
>Method.

Cool, I'll have to check that out.

>>I must say, though, it looks very good, and I'm very pleased with
>>it. I've been writing some articles for the RBLibrary, and I'm very
>>enthusiastic about having something like this around to help tidy
>>up and extract the source code listings for my articles.
>
>Can I quote you on that?

Be my guest. :)

>Anyway, I share the source code ("warts and all") for almost
>everything I write, in the hope that people will share back, either
>source code for programs which they've written or comments on how
>my own source code can be improved. (By the way, what is the
>status of the source code of the program you sent? If (as I expect
>I will) incorporate the suggested changes in future versions of
>RBCHL, do you have any objections to my sharing the source code
>publicly?

It's yours to do with however you see fit. Credit would be
appreciated but is not required. It is intended as a contribution in
kind to thank you for making your code available.

>>I've shoehorned in an Acrobat-style bookmarks pane beside the
>>source code view, i.e a hierarchical listbox that gives all the
>>objects in the source code, and underneath, if you click on the
>>disclosure rectangle, each of the methods in the object.
>>Double-clicking on any item takes you to the source code for that
>>item in the listing.
>
>BRB. I just tried it out. Your description seduced me into
>stopping to take a look at what you did, and I love it! Can I share
>it with others and/or incorporate it as a permanent addition to the
>program?

Sure, whatever you like. I'm glad you like it. :)

[snip comments about internal format of RB XML files -- I definitely
want to keep that around for my records, I've poked around that
format myself and noticed some of the same *ahem* irregularities as
you, but I think you've gone farther than I in sleuthing them out.]

>RB CodeHelper Lite is a subset of a larger CodeHelper program,
>which includes some features that no longer work properly
>(although many do). One feature which may or may not now work
>is one that I found to be very helpful. Let me describe it.
>
>I hate setting initial values of control Properties within the RB IDE.
>Therefore I wrote for CodeHelper a routine so that you could
>_safely_ and _easily_ edit the initial values for control
>Properties. The only thing I hadn't (and haven't) worked out was
>(and is) the ability to handle control arrays, but most Projects
>don't use control arrays, and the routine made it easy for me to set
>the various control attributes in a very friendly fashion. (And if
>you did have control arrays, you could always do normal
>"unprotected" altering of the XML code.)
>
>When you chose to edit initial values for control properties, you
>were taken to the appropriate place in the XML display. You could
>edit what was between the ">" and the "<" but not move left or right
>over those symbols. You were confined to an appropriate field. If
>you pressed the down arrow, you were taken to the next appropriate
>field to edit (usually on the immediate line below, but occasionally
>you'd jump to the next control). (The up arrow worked in a similar
>fashion.)
>
>Does that sound like a useful feature to you? Or do you have some
>suggestions as to some useful features that you might like to see
>added?

Yes, that sounds like a good feature for a number of applications:
XML editor, HTML editor (with templates), as well as CodeHelper....

>>... I tried to mark all my code changes with "////// mn" so
>>hopefully you should be able to find everything by searching for
>>that particular string.
>
>RBCHL has its own particular special combinations for comment
>symbols, here and there. If you inspect the code, for example,
>you'll see that "///" is a marker for what might be called a
>"permanent comment," one that RB CodeHelper Lite is not supposed
>to remove.
>
>>Thanks again for all the work you put into this, it looks like a
>>cool/clever/useful tool.
>
>Again, can I quote you on that? Or would you be willing to write up
>a couple of sentences that you wouldn't mind my quoting? I've asked
>so many "stupid" questions on the RB mail lists that I'm not sure
>what credibility I have as a programmer, so a comment from
>someone like you could be helpful. (No pressure, however.)

You can quote me, and don't worry about credibility. Stupid questions
made me what I am today. :) When you can ask a question, get an
answer, and turn it into useful code, what else is there? I know a
lot of people that can get an answer and still can't write the code,
and I know even more who can't even ask the question!

Cheers.

Mark

---End of Original Message ---

Important: RB CodeHelper Lite is still in beta-test format, so additional feedback would be much appreciated, especially from people with Macs. (For a demo of just one of its seventy-seven or more features, go to http://traver.org/ss/.)

Barry Traver



Home Page for This Blog: http://traverrb.blogspot.com/

Programs and Files Discussed in the Blog: http://traver.org/traverrb/

Sunday, January 29, 2006

diffpatch124: Not much improvement over diffpatch114?

A couple of days ago I indicated that my diffpatch program (diffpatch114) did what it was intended to do, but it was neither user-friendly nor optimized for speed. Well, diffpatch124 is a slight improvement, but not much of one.

Here's how I described the the program and its deficiencies:

"diffpatch has two parts: "The diff [part] compares two versions of a document, generating a set of differences that reflect the changes that need to be applied to the old document to make it identical to the new document.... By running the patch [part], the document contents can be updated to the new version...."

"The major problem with diffpatch114 is two-fold: (1) it takes a l-o-n-g time for the program to process long files, and (2) the user is given no visual clue that the program is still at work. It is possible at this point that the user (at least in Windows) can "break" the program by clicking and reclicking the File menu to try to determine if the program is "alive." Rather than doing that, such a process itself may cause the program to "lock up" and "fail to respond" (again, at least in Windows)."

Well, diffpatch124 now uses a progress bar to show that the program is busy at work creating the differences file, but the process is still very l-o-n-g. The problem is not with the "patch part" of the program (that works almost instantaneously), but with the "diff" part of the program.

If anyone has any suggestions on how the program can be significantly speeded up (the diff part, not the patch part), I'll be glad to hear them. In the meantime, you'll have to take the program "as is." It does what it claims to be able to do, but it doesn't do it in the most efficient fashion.

I haven't yet found the RB program I wrote that is able to apply UNIX-format difference files, but I did find an RB program I wrote that will apparently convert a UNIX-format file into a Traver-format file as well as convert an Edit Pad Pro "compare files" differences fil into a Traver-format file. (I had forgotten that I had written such a program.)

Although our Abyssinaian, Ruby, doesn't like it when I use this metaphor, I'm too old a dog to change now: "There's more than one way to skin a cat." If the diff part of my diffpatch program cannot be greatly improved in speed, is there another (and faster) way that I can create a Traver-format differences file automatically?

Specifically, is it possible to write an RB program to automate a Windows Unix-style diff program (or a Mac UNIX-style diff-program) from RB so that the UNIX-style diff program will create the UNIX-style differences file (which it can do fairly quickly) _and then_ (this part is already done relatively efficiently in the new RB program I discovered) the RB program will covert that UNIX-style differences file to a Traver-format differences file?

Or (to mention a similar theoretical possibility) is it possible to write an RB program to automate my Edit Pad Pro (a Windows program) from RB so that Edit Pad Pro will produce the Edit Pad Pro "compare files" differences output (which it can do fairly quickly) _and then_ (this part is already done relatively efficiently in the new RB program I discovered) the RB program can convert that Edit Pad Pro "compare files" differences output to a Traver-format differences file?

I don't know the answers yet (I'm just thinking out loud, so to speak). The only point at this point is that in programming there is usually more than one way to accomplish a particular task and the "best" solution is not automatically the "most direct" or "obvious" approach (although that may be most often the case).

In programming, there is always room for innovation, ingenuity, creativity, and invention (especially necessary when the required technical expertise may not be there?).

Barry Traver

P.S. Stay tuned. In the next entry, I'll be discussing my RB CodeHelper Lite program as enhanced by Mark Nutter!



Home Page for This Blog: http://traverrb.blogspot.com/

Programs and Files Discussed in the Blog: http://traver.org/traverrb/

Saturday, January 28, 2006

RB Browser/Editor enhanced by Steve Garman

If you've been finding my RB Browser Editor for the Language Reference (RB-BE-LR) useful, you'll be glad to hear that a version enhanced by Steve Garman (RB-BL-LPsg) using code by Mars Saxman as a foundation is now available.

The feedback I got on my program indicated that some people thought it would be nice if it had a Splitter so that the amount of space given to the browser and the editor could be adjusted. At my request, Steve Garman added such a feature.

Here are recent relevant emails I received from Steve:

-------- Original Message --------
Subject: Splitter
Date: Tue, 17 Jan 2006
From: Steve Garman
To: Barry Traver

Barry,

In the end, I decided not to mess around with a general-purpose splitter.

I've taken out most of the resizing code and added a canvas called
horizSplit.

Hope this is the sort of thing you were looking for.

Regards,
Steve
--
Steve Garman
Using REALbasic 2006r1 Professional on Windows XP Pro
-----End of Original Message -----

-------- Original Message --------
Subject: Re: Splitter
Date: Fri, 27 Jan 2006
From: Steve Garman
To: Barry Traver

In a message regarding Re: Splitter dated Fri, 27 Jan 2006,
Barry Traver said that ...

> Thanks. It seems to work fine. Do you have any objection to my
> releasing it publicly (including source code)? And how do I word the
> acknowledgement? Did you write the Splitter, or should I give someone
> else credit for that (and simply give you credit for incorporating it
> into the program)?

Barry, you're very welcome to publish the code.

It's dignifying my addition to call it a splitter, it's just a canvas
dragged onto the window which takes advantage of the new MouseDrag event.

There's really no need to give me credit.

The code in the Paint event that draws the handle was copied from Mars Saxman's splitter control at http://www.redplanetsw.com/realbasic/. It would probably be polite to mention that.

--
Steve Garman
Using REALbasic 2006r1 Professional on Windows XP Pro
-----End of Original Message -----

For the sake of those unfamiliar with the program (download RB-BR-LR for the original version or download RB-BE-LRsg to get Steve's enhanced version), RB Browser/Editor for the Language Reference not only makes it easy to add your own annotations and code snippets to the Language Reference files so that your additions can be accessed from within the RB IDE, but also makes it easy to add links to relevant outside materials in HTML. (See http://snurl.com/lc4o for a general description of the program and see http://snurl.com/lc4p for a decripiton of a related utility.)

Enjoy!

Barry Traver

P.S. Make sure you've downloaded RB-BE-LR2.zip and RB-BE-LR2sg, which are replacements for the RB-BE-LR.zip and RB-BE-LRsg.zip files I uploaded earlier. The new versions include two bug fixes, one of which which prevented internal links from working properly.



Home Page for This Blog: http://traverrb.blogspot.com/

Programs and Files Discussed in the Blog: http://traver.org/traverrb/

Thursday, January 26, 2006

Learning Better Programming from diffpatch114?

I wrote diffpatch114 about two years ago, when I was a complete novice in REALbasic. Although the program in one sense seems to work flawlessly, in another sense it is a good example of bad programming, an illustration of what to avoid (and hence, I hope, a step toward better programming).

diffpatch has two parts: "The diff [part] compares two versions of a document, generating a set of differences that reflect the changes that need to be applied to the old document to make it identical to the new document.... By running the patch [part], the document contents can be updated to the new version...."

The major problem with diffpatch114 is two-fold: (1) it takes a l-o-n-g time for the program to process long files, and (2) the user is given no visual clue that the program is still at work. It is possible at this point that the user (at least in Windows) can "break" the program by clicking and reclicking the File menu to try to determine if the program is "alive." Rather than doing that, such a process itself may cause the program to "lock up" and "fail to respond" (again, at least in Windows).

Let's talk about the second problem first. My CodeHelper solves such a problem by using three techniques to let the user know that the program is "working" on a task: a progress bar is ... well, making visible progress, the mouse cursor is changed to indicate that the computer is busy, and the word "working" is displayed in colorful big bold print. Of these, the progress bar is the most important. So a progress bar should be added to diffpatch114.

The first problem may involve some exploration. In order to speed up the process, I need to find out what part of the process is taking up the most time or an unnecessarily long time. One way I can do that is insert MsgBoxes at appropriate points in the process (MsgBox "1", MsgBox "2", MsgBox "3", etc.) to see what steps seem to take unduly long. For example, if there's a long time between MsgBox "4" and MsgBox "5", I then know what portion of my code needs to be examined (viz., the code between MsgBox "4" and MsgBox "5").

When placing the MsgBoxes, of course, it is ordinarily best not to place them within any loops (Do/Loop, For/Next, etc.). MsgBoxes are how I learned with RB 5.5.x that - although Split worked seemingly instantaneously, Join could take a long time for large arrays (i.e., arrays with tens of thousands of elements in them). (I haven't tested RB 2005 or RB 2006 to see whether Join has been improved, but a while back on one of the RB mail lists Walter Purvis gave me an excellent replacement for "Join" which is called "MyJoin" but works the same way, but only faster.

I just used diffpatch with two file versions, each of which was approximately 20,000 lines long, so I know that the diff part works and I know that the patch part works, because I was able to create a differences file that I was able to apply to the original file to (re-)create the revised version of the file. (I used the "Compare Files" feature of Edit Pad Pro to compare the two files, and Edit Pad Pro told me that they were "identical.")

Anyway, I hope to make an improved version of diffpatch available in the near future. In the meanime, use the bad programming in diffpatch114 as an example of what to avoid and as a step toward better programming. Keep your user informed as to what is taking place (using a progress bar, etc., where appropriate), and don't be content to just get your code working dependably: optimize it!

Barry Traver


Home Page for This Blog: http://traverrb.blogspot.com/

Programs and Files Discussed in the Blog: http://traver.org/traverrb/

Wednesday, January 25, 2006

diffpatch: An Alternative to the Unix Programs

First, some background:

"The standard Unix tools diff and patch are used to find the differences between text files and to apply the differences. These tools operate on a line by line basis using well-studied methods for computing the longest common subsequence (LCS)."
--http://diffxml.sourceforge.net/

My own diffpatch program in REALbasic (written about two years ago) does not use "well-studied methods for computing the longest common subsequence (LCS)," but it can be "used to find the differences between text files and to apply the differences" and it does "operate on a line by line basis."

Here's a description of "How diff and patch Work":

"The diff program compares two versions of a document, generating a set of differences that reflect the changes that need to be applied to the old document to make it identical to the new document.... The set of differences can be transported to someone who has the original copy of the document. By running the patch program, the document contents can be updated to the new version...."
--http://snipurl.com/lwx8

The output of a diff program may have a variety of formats, but the three most common are normal, context, and unified. I wrote a REALbasic program that can handle (not the creating of, but) the applying of at least two of those three UNIX-style formats. That is, I wrote a program that is a patch program in RB: it requires a UNIX-style program to create the file indicating the differences, but once that file has been created, it can apply that file to the original document to update the contents of that document.

I wrote these two programs primarily as an RB novice because (rightly or wrongly) I understood someone to be telling me that I couldn't do it. He was correct in that I knew nothing about the "well-studied methods for computing the longest common subsequence (LCS)," but even though I didn't know enough to be able to write a really efficient diff program, it was simple to write a patch program to update documents using those UNIX-style difference files and fun writing my own diffpatch program with my own format.

How does my format (used in diffpatch) differ from the UNIX files? The significant thing (if there is any) is that my format does not include any lines from the original document. What this means is that if the original document is copyrighted by someone else, then I can publicly post my own updates and modifications without getting into trouble for violation of copyright. (Text files that can be updated, for example, include HTML files - such as are found in the Language Reference - and XML files - such as the format in which RB Projects can be saved.)

I haven't tracked down my patch program yet (the one that handles at least two of the UNIX formats), but I have made available my diffpatch program (look for it in the usual place). It is rather limited in its practical usefulness, but it was an interesting program to write, and you may find it to be of interest also, even if only as a "curiosity piece."

Barry Traver



Home Page for This Blog: http://traverrb.blogspot.com/

Programs and Files Discussed in the Blog: http://traver.org/traverrb/

Tuesday, January 24, 2006

TraverToy4: Extracting Source Code from XML

TraverToy4 is very similar to TraverToy1. The difference is that TraverToy1 removes blank lines from source code, while TraverToy4 extracts the source code from the XML file and allows you to save it as a text file. (Important: No indenting is done. I hope to return to that topic sometime in the future.)

XML is similar to HTML. In fact, an XHTML file is an XML file. The most important thing to realize is that important pieces of data are surrounded, left and right, by angle brackets discribing the data.

For example, take this line of XHTML:

C.S. Lewis's <b>most</b> popular children's book is <i>The Lion, the Witch, and the Wardroble</i>.

The <b> and </b> "bookends" indicate that the word "most" is to be put in bold type. The <i> and </i> "bookends" indicate that "The Lion, the Witch, and the Wardrobe" is to be put in italic print. (Note, by the way, that the right closing tag has a right slash ("/") immediately after the first angle bracket.)

Similarly, in REALbasic's XML format, <SourceLine> and </SourceLine> are the "bookends" used to enclose REALbasic source. Extract from the file what you've got between those two tags, and you have all the source code. It's as simple as that.

To use TraverToy4, Open an XML file, Process the file, and save the result as a TXT file. If you want to take a look at how indenting can be done, you can download RB CodeHelper Lite (RBCHL), but hold off on doing that until tomorrow (Wednesday, January 25, 2006),by which time I hope to have available an improved version, with some features added and some bugs removed.

TraverToy4 should work equally well on a Mac as in Windows, but I don't have a Mac myself (yet), so I can't guarantee that it will work properly "as is" on the Mac. If you as a Mac user have to make any minor modifications, I hope you'll let me know, so that I can pass the information for the benefit of other Mac users of REALbasic. (For example, I'm not quite sure how the Mac handles FileTypes, but I know it works a bit differently from the way it works in Windows.)

Barry Traver



Home Page for This Blog: http://traverrb.blogspot.com/

Programs and Files Discussed in the Blog: http://traver.org/traverrb/

Saturday, January 21, 2006

Looking Back: Index for the Past Month

Sorry about the delay in posting a new entry, but I've kept my promise about trying to put up a new entry for every other day on the average. Here's the evidence:

Saturday, December 17, 2005
REALbasic (RB): A Cross-Platform Language

Sunday, December 18, 2005
TraverToy1 and Removing Blank Lines

Tuesday, December 20, 2005
TraverToy2 and Platform Determination

Tuesday, December 20, 2005
CardTrick for Windows Only

Wednesday, December 21, 2005
RB Browser/Editor for Language Reference

Thursday, December 22, 2005
Language Reference Utility1 for RB Browser/Editor



Saturday, December 24, 2005
XML: All You Need to Know in One Easy Lesson

Sunday, December 25, 2005
What's Planned for the Future for This Blog?

Tuesday, December 27, 2005
Method "Overload" Example: A Debugging Aid

Thursday, December 29, 2005
Method "Overload" Comments: Further Discussion

Friday, December 30, 2005
Intro to RSS and Some RB News Feeds

Wednesday, January 04, 2006
RB CodeHelper and RB CodeHelper Lite

Friday, January 06, 2006
More Info on What CodeHelper Lite Can Do

Saturday, January 07, 2006
Now Available: "Alpha" Index for RB 2005 LR

Sunday, January 08, 2006
More Info on "Alpha" Lists for RB 2005 LR

Monday, January 09, 2006
Still More on What RB CodeHelper Lite Can Do

Wednesday, January 11, 2006
RB CodeHelper Lite: Finishing Up the Features

Thursday, January 12, 2006
TraverToy3: RB Code Indenter

Sunday, January 15, 2006
RB CodeHelper Lite: Now Available But....

Tuesday, January 17, 2006
RB CodeHelper Lite: Just Thinking Out Loud

So that's twenty entries for the past month. As you can figure out from the blog entry titles, I also made available seven programs (RB Browser/Editor for the Language Reference, Utility for the RB Browser Editor, RB CodeHelper Lite, TraverToy1, TraverToy2, TraverToy3, and the Windows CardTrick) and four files (long and short "Alpha" indexes for RB 2005 and RB 2006). I'll see if I can do better than that this month, starting with a new (but simple) TraverToy with the next entry.

Barry Traver



Home Page for This Blog: http://traverrb.blogspot.com/

Programs and Files Discussed in the Blog: http://traver.org/traverrb/

Tuesday, January 17, 2006

RB CodeHelper Lite: Just Thinking Out Loud

I've made available an updated version of RB CodeHelper Lite. It had worked fine on other Projects which I had tried it on, but did not work properly with Thomas Tempelmann's helpful RB Project Tool.

I think I've fixed CodeHelper for now, but - because of RS's lack of full documentation of their XML format - working with XML is like "the scientific method," complete with its disadvantages which result in "temporary truth" at the best. I'm not an Einstein, but it's like progressing in the same way that Newtonian science "progressed" to Einsteinian physics.

That is, rather than being able to use the deductive method, which - given the proper premises - can provide "true truth," you have to be content with the inductive method, which provides at best "probable truth" or "temporary truth," which only works until something better comes along. Specifically, like F = ma my method of obtaining information on RB controls worked fine until Thomas Tempelmann's program came along (just like Newton's laws worked fine until they confronted the situation of particles moving at speeds close to the speed of light, where mass could no longer be considered a constant but was obviously related to speed and/or acceleration, hence e = mc squared).

Although my method worked with all previous cases, when Thomas Tempelmann's program came along I had to work out a different approach which would encompass both the earlier programs and Thomas's as well, which broke the earlier "rules" and showed them to be inadequate (just as the inductive statement "all bears are brown" is "true" until once comes across the first polar bear).

RS's way of phrasing the situation is this: "The XML produced by REALbasic is well-formed, but it cannot be "validated" because it does not include a 'document type declaration.'" What this means is this: "We won't tell you the rules. All we'll do is tell you that there are rules, and it's up to you to infer them as best you can." It makes it fun to work with XML because of the intellectual challenge, but it's also true that you don't know when you're going to meet your first polar bear. That is, the best I can say is that CodeHelper at a certain stage can handle all of the programs it has met thus far, but that is no guarantee that it can handle some program it hasn't met yet.

One other consideration to deal with: RS doesn't tell you the rules, because it changes the rules. Load an old program into RB 5.5.x, and save it as an XML file. Load the same program into RB 2005 or RB 2006 and save it as an XML file. Now compare the two XML files. The differences are considerable (e.g., the RB 2005 or RB 2006 XML file may be a hundred lines _shorter_ than the RB 5.5.x file!). Will my induced rules work with the new format? Maybe yes, but maybe no.

Fortunately, most of them seem to continue to work (including all of those in RB CodeHelper Lite, now that I've fixed the problem with handling Thomas Tempelmann's program), but they cannot be "validated," because RS does not make available a "document type declaration" (even though that is fairly standard procedure with XML formats). Let me give two examples of where what worked before no longer works.

Example #1: When you print out the source code from within the RB IDE, it ordinarily does NOT print out in alphabetical order. With RB 5.5.x, I worked out a way to manipulate the XML file so that it would put the Properties and Methods into alphabetical order when printed out from the RB IDE. That way no longer works.

Example #2: For some reason, RB will from time to time introduce empty event procedures in the XML file. They don't affect the running the program, but they are extraneous and unnecessary. (Essentially you'll have a Function line and an End Function line with nothing between them except perhaps a blank line.) With RB 5.5.x I worked out a way to remove those "empty" event procedures. That way no longer works.

How do I handle such situations? For the time being, I am not trying to put out two different versions of CodeHelper, but one version containing only those routines which work with all versions of RB from 5.5.x. on. If something works only with the 5..5.x version of XML, then that feature is removed (at least for now) from CodeHelper.

Programming can be an interesting endeavor and a real challenge at times....

Barry Traver



Home Page for This Blog: http://traverrb.blogspot.com/

Programs and Files Discussed in the Blog: http://traver.org/traverrb/

Sunday, January 15, 2006

RB CodeHelper Lite: Now Available But....

RB CodeHelper Lite (described previously in this blog) is now available, but...

It has NOT been extensively beta-tested. In particular, it has not been adequately tested on the Mac. If you have a Mac, use it at your own risk. In addition, your downloading it is conditional upon your wilingness to supply some feedback as to whether it works properly.

I do not (yet) own a Mac, so - although RB CodeHelper Lite (RBCHL) seems to work fine in Windows - it may or may not run well (and perhaps may not run properly at all) on a Mac. I hope I made appropriate adjustments for the differences between Windows and the Mac, but I have no way of testing that for myself to make sure.

Here are some of the differences that could affect the running of RBCHL:

(1) EndOfLine is different for the Mac, Linux, and Windows. For the Mac, the EndOfLine marker is Chr(13); for Linux, it is Chr(10); but for Windows, it is Chr(13) + Chr(10). But that's not all. Unlike the Mac and Linux (where the same EndOfLine marker is used consistently), Windows uses a different EndOfLine marker in an EditField than it does elsewhere. Specifically it uses Chr(13) rather than Chr(13) + Chr(10).

(2) Not having a Mac, I'm not able to test whether or not I've set up the FileTypes to work correctly on a Mac. I'm not sure, for example, what to indicate for "MacType" and "MacCreator." Nor do I really know what to put down for the settings for "MinimumMemory" or "SuggestedMemory" on the Mac. It could be that incorrect settings here could prevent the program from running properly on a Mac.

(3) In RB CodeHelper Lite, I load the entire XML file (sometimes 15000+ lines) into an EditField, and I've had no problems. I have been told by a couple of Mac users, however, that it is not a good idea to load that large a string into an EditField on a Mac. It has caused me no trouble at all in Windows, but it may not be as safe on a Mac.

If you do download RB CodeHelper Lite, I would greatly appreciate hearing from you as to the results, particularly if you're using a Mac. You may want to start with smaller Projects and perhaps stay away from the XML tab entirely (although the contents of the EditField on the Source tab can also be fairly large).

Here's the basic eight-step procedure for testing RB CodeHelper Lite:

(1) From the RB IDE, load in a Project and use File --> Save As with "File as type:" set to "XML Project (*.xml)" to save the Project as an XML file.

(2) Exit RB, Run RB CodeHelper Lite, and use File --> Open XML File to load in the file you just saved.

(3) Try some simple things, such as changing the line spacing, displaying a list of controls in the Project, or adding an automatic procedure header or footer to each Method. The Main Menu Tab is where you tell RB CodeHelper Lite what to do. Rather than use the PushButton at the bottom of the page, you can double-click a category to expand it or on an item to perform the task.

(4) If you've done something that modifies the program (rather than just analyzes the data), you can see the result of what you've done on the Source Tab or XML Tab (but, as I said, you may want to avoid doing that if it's a large file and you have a Mac "classic").

(5) If desired, in RB CodeHelper Lite you can use File --> Save XML File to save the result to disk. (As long as you keep a copy of your original .RB or .RBP file, you're safe even if RB CodeHelper Lite should mess up the XML file. I don't expect that to happen, but CodeHelper is still insufficiently tested, particularly on the Mac, so it's possible.)

(6) Then, if you like, you can use File --> Open with "Files of type:" set again to "XML Project (*.xml)" to load the XML file into RB 5.5.x or RB 2005 to look at the code or to run the program to confirm that it still runs as before.

(7) Then, if you're pleased with the result, you can use File --> Save As with "Files of type:" set to "REALbasic Project (*.rbp, *.rb)" to save the Project as a normal (.RB) REALbasic program file.

(8) Finally (and this is a really important step), you need to let me know the results, particularly of any problems you may have encountered.

Incidentally, I've decided to set up a special blog specifically for REALbasic users who are running RB in Windows. You'll find it at this address:

http://traverrbw.blogspot.com

Enjoy!

Barry Traver



Home Page for This Blog: http://traverrb.blogspot.com/

Programs and Files Discussed in the Blog: http://traver.org/traverrb/

Thursday, January 12, 2006

TraverToy3: RB Code Indenter

Something that may be surprising is that the XML file for an RB Project contains no information on the indenting of the code. If you, for example, simply extract the source code information, everything is "flush" with the left margin, i.e., there is no indenting.

So if you want to have properly indented code from the information in the XML files, you'll have to add the formatting yourself, according to the rules that REALbasic itself uses. As far as I know, that information is nowhere documented, but it is not that difficult to figure out.

Here are the rules, discovered from observation. If a line begins with "Case," "Do," "Else," "ElseIf," "Exception," "For," "Select Case," or "While," the following line is indented one level. If a line begins with "Case," "Else," "ElseIf," "End Function," "End Select," "End Sub," "Loop," "Next," or "Wend," that line is outdented one level. If a line begins with "If" and ends with "Then," the following line is indented one level. And if the preceding line end with a "_" (a line continuation character), that linje is indented some extra spaces (but more than one level). That's about all there is to it.

TraverToy3 is able to do three things: (1) Open an XML file and show you the source code with no indents, (2) Open an XML file and show you the appropriate indents, or (3) Open an XML file and (for testing purposes) show you the appropriate indents with the indent level indicated by a number. Thus if you look at all the 1's or all the 2's or all the 3's, etc., you should see related lines (e.g., associated lines beginning with "If," "ElseIf, "Else," and "End If" belonging to the same If/ElseIf/Else/End If statement) having the same number at the beginning of each line.

TraverToy3 is also able to save the results to disk. In Windows, you can also use Copy and Paste to put the EditField text into a plain text editor (such as Notepad for Windows or its equivalent on the Mac) and save the text to disk from there (but I've had mixed reports as to whether that also works on the Mac).

TraverToy3 is a subset extracted from RB CodeHelper Lite, with an additional routine added (the testing routine). It is my hope that the code is "clean," not containing anything extraneous, but it's possible that I may have missed something, so please be tolerant of that.

TraverToy3 contains some useful Methods. For example, MyJoin (which is NOT "My" Join, but Walter Purvis's) is an improvement over the Join contained within REALbasic. You may also want to take a look at routines such as BetweenTags, ConvertHex, CutOffRight, HowMany, IsSource, Mid1, MinNonZero, OutsideQuotes, Rpt, StartsWith, CheckForXMLFile, GetSourceAndComment, GetWholeLine, and ResizeIt, most of which I hope to take a look at in future blog entries.

IMPORTANT: I make no claim that my code is the best way to perform these particular tasks, but simply that it is a way to accomplish certain goals. If you have improvements to sugest, please do so. Just as I hope that you will learn something from this blog, I'm hoping to learn something from this blog as well.

Barry Traver



Home Page for This Blog: http://traverrb.blogspot.com/

Programs and Files Discussed in the Blog: http://traver.org/traverrb/

Wednesday, January 11, 2006

RB CodeHelper Lite: Finishing Up the Features

Previous blog entries have discussed some of the things that RB CodeHelper Lite can do. This entry attempts to consider briefly most of the other features (but be aware that although RB CodeHelper has seventy-seven different tasks it can perform, RB CodeHelper is expected to have even more: about twice that number!).

RBCHL can display (properly indented) source code on the screen for the entire Project or for a particular Method. The code can be saved to disk or printed out if so desired. The size of the indentation can be increased for greater readability (or reduced to the normal amount). And a search feature (including "whole word" search) is also available.

Some programs contain deadwood, such as Properties that are defined but never used or Variables that are DIMensioned but never used. RB CodeHelper Lite can tell you if you have any such in your Project, and can also tell you if you've used the same name for a Property and Variable (not good programming practice!).

You can have some fun "obfuscating" and "unobfuscating" your source code. The fuller CodeHelper program has a number of ways to do this (switching existing names, using randomly created meaningless names, randomizing upper/lower case). RB CodeHelper Lite has simply one example: switching the names of controls around (so that what was called EditField1 may now be perhaps called PushButton2, and so on). This feature has no practical usefulness that I can see, but it can be fun to pass along the "obfuscated" source code of a program and watch someone struggle to try to make some sense out of it.

RB CodeHelper Lite also makes it easy to change the name of a control, method, property, variable, etc., throughout a Project. It can do other miscellaneous tasks, including checking nested For/Next loops for the same counter name used on different levels. You can combine partial source lines (i.e., those which make use of the "_" line continuation character). And you can remove all highlighting, placing the cursor in the top left corner of each Method (thus avoiding the risk of accidentally deleting selected code).

You can remove comments or comment symbols, and differentite between the different types of comments, using different symbols for different purposes. (RB CodeHelper Lite does have one arbitrary convention: it regards comments preceded by "///" to be "permanent" comments and thus will not remove them.)

Finally, you can use RBCHL to work with Dim statements in various ways. You can put individual Dim statements on separate lines, you can alphabetize Dim statements after you have separated them, and you can combine adjacent Dim statements (same kind or different kinds). (If they are not already adjacent, RB CodeHelper can arrange for that as well.)

I'm still looking for some people willing to beta-test RB CodeHelper Lite, which I expect to be releasing shortly (if I can get some beta-testers) as freeware or perhaps "donationware," with source code included. (If you are willing to try it out and provide me with some feedback, no further donation is needed: you've already donated your time!) I'm also looking for people to test the fuller RB CodeHelper, which will probably be released as shareware. (Beta-tester who provide me with helpful feedback will be entitled, of course, to a free copy.)

If you are interested, please send me a private email My address is rb at ix dot netcom dot com (with the appropriate symbols substituted for the "at" and the "dot").

Barry Traver



Blog Home Page: http://traverrb.blogspot.com/

Programs and Files Discussed in the Blog: http://traver.org/traverrb/

Monday, January 09, 2006

Still More on What RB CodeHelper Lite Can Do

Today we look at some other things that RB CodeHelper Lite can do.

In an earlier entry, I explained how "Comment OLut Source and Add MsgBox" could be helpful if you wanted to create a Project that was a subset of an existing Project. "Comment Out Entire Source" can be useful if you need to build a new Project "from scratch," but want the code from an earlier Project to be easily accessible in case some of it can be reused. (You can restore it with "Uncomment Entire Source.") Important: when "Comment Out Entire Source is used, the original indenting is preserved (or, more accurately, is re-created).

"Comment Out MsgBox Statements" can be useful if you make frequent use of MsgBoxes when debugging and then want the Program to run without being interrupted by the MsgBoxes. (You can bring them back with "Uncomment MsgBox Statements.") If you use different types of comment symbols for different purposes, you can "Remove Comment Symbols" of different types separately.

Both "Add Procedure Headers" and "Add Procedure Footers" know the Method in which they are being placed. Thus the procedure header can provide the name and location of the method, and youcan add other information (*e.g., programmer's name, purpose of Method, date of Method, etc.) later, and the procedure footer can include an exception handler that can indicate the Method in which the exception occurred. "Remove Procedure Headers" and "Remove Procedure Footers" remove these haders and footers.

Some people like to have no unnecessary spaces between characters ("Remove Unnecessary Spaces" does this); while others (I'm one of them) like to have spaces for readability, such as spaces around symbols for math operators such as "+," "-," "*." "/,." "^," "=," "<>," "<=," or ">=" ("Put Spaces Around Symbols for Math Operators"), spaces after commas ("Put Spaces After Commas"); spaces around, inside, or outside Parentheses ("Put Spaces Around Parentheses Symbolls," "Put Spaces Only Inside Parentheses Symbols"); "Spaces Only Outside Parentheses"); or all or the preceding ("Add Extra Spaces of All Types").

Those who want to save paper when printing out source code will appreciate "Remove Blank Lines"; those who want more "white space" for readability (or room to write and annotate) will appreciate "Double- (or Triple- or Quadruple-)Space the code or perhaps "Separate Logical Units," which puts a blank line before an "If" line and after an "End If" line, before a "For" line and after a "Next" line, etc.

Since I prefer order to disorder, I like to see standardization of use of upper/lower case. REALbasic doesn't care, but I care. Ir you care, RB CodeHelper Light can ensure that you have standardization in case, using "Reform Constants," "Remove Contorls," Reform "Line Labels," "Reform Methods," "Reform Modules," "Reform Properties,," "Conform REALbasic Keywords," and "Conform Variables." For example, the pattern that RB CodeHelper Lite uses is that which is used in the Dim staatements for that variable.

You can also have RB CodeHelper Lite list all the names used in a Project ("Display All Words Used in Source", "Display Constants Used in Project", "Display Controls Used in Project," "Display Event Handlers Used in Project," "Display Functions Used in Project," "Display Line Labels Used in Project", "Display Menu Items Used In Project," "Display Methods Used in Project," "Display Modules Used in Project," "Display Properties Used in Project," "Display REALbasic Keywords Used in Project," "Display Subs Used in Project," "Display Variable Names Used in Project," "Display Variables by Location," and "Display Variables by Name" provide such lists).

I'll see if I can finish up the list of RB CodeHelper Lite's features in a future blog entry., but at least now you have hopefully a better understanding of some of the things the program can do. (If you are willing to be a beta-tester and supply me with feedback, please let me know. Thanks!)

Barry Traver



Blog Home Page: http://traverrb.blogspot.com/

Programs and Files Discussed in the Blog: http://traver.org/traverrb/

Sunday, January 08, 2006

More Info on "Alpha" Lists for RB 2005 LR

Now two versions of index.html. are available!

One is a short version (with 700+ lines and links); the other is a long version (with 3000+ lines and links). Take your choice. The short version is very similar to the "Alpha" list in REALbasic 5.5.x; the long version is a complete list, with links to all of the 3000+ files in the Topics folder.

I think the addition of the "alphabet bar" to the long version makes it much less "overwhelming." Click on a letter, and jump immediately to the appropriate section. Click on the red letter at the start of any section, and jump immediately back to the top. That cuts down tremendously on the scrolling involved.

Thus you have all the advantages of a complete list, but minimal disadvantages. (Plus you have links to REAL Software, the RB Forums, RBGarage, RBSource, and my RB blog!) And you still have the simplicity of a single Web page (rather than needing twenty-six or twenty-seven, with a separate letter on each).

To install involves two simple steps:

(1) Change name of "index.html" in the "Language Reference" folder to "index2.html."
(2) Put my "index.html" file in that same directory.

That's all there is to it. As long as you do step (1) before step (2), you should be fine!

If you're running Windows, you'll probably find the Language Reference folder here:

C:\Program Files\REAL Software\REALbasic 2005r4\Resources\Language Reference

If you're running a Mac, you may find the following comments from a Mac user helpful:

"It took me quite a time to find out where the Language Reference folder is - Spotlight searches for "Language reference" and"Index.html" did not help - but I found it eventually....
I have a Mac G5 running OSX 10.4.3. The LR is a part of the RB app. package. To get at it, one has to right click (or control-click) the RB app. itself, choose "Show Package Contents " then navigate to the "Resources" folder. There is no other method, as far as I am aware. As already mentioned, none of my search utilities was able to locate the file. Spotlight is the highly acclaimed search tool built into Mac OS X Tiger."

Once the new file is installed, you can still use the original home page for LR, but it will take two clicks to get there (Home button and "Language Reference Original Starting Point" link).

To uninstall, follow these two steps (in that order):

(1) Delete my index.html file from the "Language Reference" folder.
(2) Change the name of "index2.html" in that same folder to "index.html."

Incidentally, I did not assemble this file by hand. I wrote a program (in REALbasic, of course) to read through all the HTML files in the Topics folder, to extract the necessary information, to sort the entries, and to put together the new index.html file.

If I find time, I may improve the file so that it makes use of a Table (or the CSS equivalent of a Table) in order to have multiple columns. For now, however, you'll have to be content with a single-column "Alpha" index (which is essentially how it was done in RB 5.5.x).

Enjoy!

Warm regards,

Barry

P.S. Someone complained that my index.html file is "very complete" to the extent that it is "overwhelming," and he is probably right. It is "very complete," because I let the computer make the list for me. Feel free to "trim it down" or customize it as you desire (I may come out with a shorter version myself). The hard work has been done. It's easier to have too many links and have to decide what ones to cut than it is to have too few links and have to find out what "missing links" to add. So, yes, be forewarned: the file is (needlessly?) long and can be much improved, either by omitting needless links (e.g., subitems under a class) or by putting the links into a multi-column table.

Incidentally, this particular index.html file works only with RB 2005. It will not work correctly, I'm told, with the Language Reference files for RB 2006.

Barry Traver



Blog Home Page: http://traverrb.blogspot.com/

Programs and Files Discussed in the Blog: http://traver.org/traverrb/

Saturday, January 07, 2006

Now Available: "Alpha" Index for RB 2005 LR

Attention: RB 2005 Users!

Do you miss the alphabetical ("Alpha") index that you had available to you in REALbasic 5.5.x for the Language Reference? Do you dislike having to select (guess?) a Category and after that to select (guess again?) a Topic in order to find the information that you want to find? Then I have good news for you!

I've prepared a 3000-line HTML file that will make an extensive alphabetical index available to you once more from within the RB IDE. If interested, act now. This offer is not available in stores.

The file has an A - Z alphabet at the top. Click on a letter, and jump immediately to that section. Click on any red letter at the top of a section, and jump immediately back to the top. That is a real time-saver. (Otherwise you would be doing a lot of scrolling!)

You can still get to the original home page for LR, but it will take two clicks to get there (Home button and "Language Reference Original Starting Point").

Here's all you have to do to install the "Alpha" index:

1. Change the name of the "index.html" file in the "Language Reference" folder to "index2.html."
2. Put my "index.html" file in that same folder.

That's all there is to it.

There is very little danger of your breaking anything (unless you do step 2 before step 1 ). If you don't like the my "Alpha" index, then you can easily restore the earlier setup by doing these two steps (in order):

1. Delete my "index.html" from the "Language Reference" folder.

2. Change the name of the "index2.html" file in that same folder back to "index.html."

What's the cost? Nothing. It's freeware (or, to be more accurate, adware, because the "Alpha" index page contains a link to my RB blog at http://traverrb.blogspot.com, but you can always edit the file to remove that link if it bothers you).

Incidentally, I did not assemble this file by hand. I wrote a program (in REALbasic, of course) to read through all the HTML files in the Topics folder, to extract all the necessary information, to sort the entries, and to put together the new index.html file.

If I find time, I may improve the file so that it makes use of a Table (or the CSS equivalent of a Table) in order to have multiple columns. For now, however, you'll have to be content with a single-column "Alpha" index (which is essentially how it was done in RB 5.5.x).

Warm regards,

Barry Traver

P.S. Someone complained that my index.html file is "very complete" to the extent that it is "overwhelming," and he is probably right. It is "very complete," because I let the computer make the list for me. Feel free to "trim it down" or customize it as you desire (I may come out with a shorter version myself). The hard work has been done. It's easier to have too many links and have to decide what ones to cut than it is to have too few links and have to find out what "missing links" to add. So, yes, be forewarned: the file is (needlessly?) long and can be much improved, either by omitting needless links (e.g., subitems under a class) or by putting the links into a multi-column table.

Note well: this file is for RB 2005 users only. This particular index.html file works only with RB 2005. It will not work correctly, I'm told, with RB 2006.

To get this particular file, send your request as a private email to the following address: rb@ix.netcom.com.

Barry Traver



Blog Home Page: http://traverrb.blogspot.com/

Programs and Files Discussed in the Blog: http://traver.org/traverrb/

Friday, January 06, 2006

More Info on What CodeHelper Lite Can Do

Last time I provided a list of the seventy-seven tasks that CodeHelper Lite can perform. In this entry, I will provide more of an explanation concerning some whose usefulness may perhaps be less obvious.

Sometimes it is difficult to follow the logic or keep track of what's going on in long nested For/Next loops or complicated and lengthy If/End If statements. By the time you get to the "Next" line, you may hve forgotten what the matching "For" line said. Or, if you have nested If/End If statments in your code, when you get to an "Else" line or an "End If" line you may have forgotten what the original "If" statement said and/or whether that condition still applies to the section of code you are working on.

To help you keep track of where you are, CodeHelper can "Add Automatic Comments" to lines that begin with "Next" or "Else" or "End If." Here are an example taken from CodeHelper:
 For XMLLineNumber = 0 To UpperBoundXML
... [more code here] ...
If IsSource(XMLLine) Then
... [more code here] ...
If RightTemp = "_" Then
... [more code here] ...
ElseIf Temp <> "End Sub" _
And Temp <> "End Function" Then
... [more code here] ...
For Counter = 1 To NumberOfBlankLines
... [more code here] ...
Next Counter '/ For Counter = 1 To NumberOfBlankLines
... [more code here] ...
Else '/ (Caution: at least one ElseIf in this statement)
... [more code here] ...
End If '/ (Caution: at least one ElseIf in this statement)
End If '/ If IsSource(XMLLine)
Next XMLLineNumber '/ For XMLLineNumber = 0 To UpperBoundXML
Note the automatic additions to the "Next," "Else," and "End If" lines. Here's another example:
  If Temp1 = "As" Then
... [more code here] ...
If Regexmatch1 = Nil Then Exit
... [more code here] ...
If Temp1 = "New" Then
... [more code here] ...
If Regexmatch1 = Nil Then Exit
... [more code here] ...
Else '/ If NOT (Temp1 = "New")
... [more code here] ...
End If '/ If NOT (Temp1 = "New")
End If '/ If Temp1 = "As"
"Comment Out Source And Add MsgBox" was used in the making of CodeHelper Lite from CodeHelper. Running this routine comments out the entire source code but puts MsgBoxes in Methods so that the MsgBox indicates the Method it is in.

I then chose which features in CodeHelper I wanted to include in CodeHelper Lite, and uncommented those Methods (and removed the related MsgBoxes). Then I ran the program, and the MsgBoxes which appeared showed me which additional Methods needed to be uncommented (and MsgBoxes removed).

Finally, after I was fairly sure that all of the routines I wanted were working, I removed those unnecessary Methods that were still commented out (and thus had not been called). (If I made a mistake and deleted something that was really needed, RB's syntax chedcking would let me know of that fact, so that I could put it back.) As I went along, I removed from the menus those features I had decideed not to include in CodeHelper Lite, so the end result was a program that was a working subset of the fuller CodeHelper program.

We'll come back to CodeHelper and CodeHelper Lite later, but I'll be switching to a different topic temporarily in the next blog entry. And more files will be available soon. Hang in here!

Barry Traver



Blog Home Page: http://traverrb.blogspot.com/

Programs and Files Discussed in the Blog: http://traver.org/traverrb/

Wednesday, January 04, 2006

RB CodeHelper and RB CodeHelper Lite

I'm still looking for volunteers who would be willing to give me some feedback on a program I've been working on called CodeHelper. The program is still in the "development" stage, so you shouldn'texpect to see the final product yet. ("Development"-testing comes before "alpha"-testing, and that comes before "beta"-testing, so there's a way to go yet.) If you're interested, let me hear from you.

What is RB CodeHelper? Well CodeHelper is a REALbasic programming utility to help programmers with their code. Some of the routines are merely cosmetic (e.g., changing the line spacing or character spacing to make the code more readable), but some do serve more directly useful purposes (e.g., checking to see whether your projects include any properties or variables that you have defined but never actually used, or changing the name of a control, method, property, variable, etc. throughout an entire project).

Ready for "development"-testing is CodeHelper Lite, which includes the ability to perform the following seventy-seven tasks (the full CodeHelper will be able to perform perhaps twice as many):

ADD AUTOMATIC COMMENTS
Add Automatic Next Comments
Add Automatic Else Comments
Add Automatic End If Comments
ADD COMMENT SYMBOLS
Comment Out MsgBox Statements
Comment Out Entire Source
Comment Out Source And Add MsgBox
ADD HEADERS OR FOOTERS
Add Procedure Headers
Add Procedure Footers
CHANGE CHARACTER SPACING
Remove Unnecessary Spaces
Add Extra Spaces Of All Types
Put Spaces After Commas
Put Spaces Around Parentheses Symbols
Put Spaces Only Inside Parentheses Symbols
Put Spaces Only Outside Parentheses Symbols
Put Spaces Around Symbols For Math Operators
CHANGE LINE SPACING
Remove Blank Lines
Separate Logical Units
Double-Space Source Code
Triple-Space Source Code
Quadruple-Space Source Code
CONFORM IN CASE
Conform All (may take a while)
Conform Constants
Conform Controls
Conform Line Labels
Conform Methods
Conform Modules
Conform Properties
Conform REALbasic Keywords
Conform Variables
DISPLAY LIST OF NAMES
Display All Words Used in Source
Display Constants Used in Project
Display Controls Used in Project
Display Event Handlers Used in Project
Display Functions Used in Project
Display Line Labels Used in Project
Display Menu Items Used In Project
Display Methods Used in Project
Display Modules Used in Project
Display Properties Used in Project
Display REALbasic Keywords Used in Project
Display Subs Used in Project
Display Variable Names Used in Project
Display Variables by Location
Display Variables by Name
DISPLAY SOURCE CODE
Display Source Code For A Particular Method
Display Source Code For Entire Project
INCREASE OR DECREASE INDENTATION
Increased Indent of 1
Increased Indent of 2
Increased Indent of 3
Remove Increased Indentation
LOCATE UNNECESSARY DEFINITIONS
Check Variables And Properties For Duplicates
Display Unused Properties
Display Unused Variables
OBFUSCATE BY SWITCHING NAMES
Obfuscate Controls by Switching Names
PERFORM MISCELLANEOUS TASKS
Change a Particular Name
Check Nested For/Next Loops For Duplicate Counters
Combine Partial Source Lines
Remove Highlighting
REMOVE AUTOMATIC COMMENTS
Remove Automatic Next Comments
Remove Automatic Else Comments
Remove Automatic End If Comments
REMOVE OTHER COMMENTS
Remove All Comments
Remove // Comments
Remove ' Comments
Remove Rem Comments
REMOVE COMMENT SYMBOLS
Remove // Comment Symbols
Remove ' Comment Symbols
Remove Rem Comment Symbols
Uncomment MsgBox Statements
Uncomment Entire Source
REMOVE HEADERS OR FOOTERS
Remove Procedure Headers
Remove Procedure Footers
UNOBFUSCATE BY SWITCHING NAMES
Unobfuscate Controls by Switching Names
WORK WITH DIM STATEMENTS
Put Individual Dim Statements on Separate Lines
Alphabetize Separated Dim Statements
Combine Adjacent Dim Statements (same kind)
Combine Adjacent Dim Statements (different kinds)

The only feature in the preceding list that I've discussed here so far in this blog is how to "remove blank lines" from the source code. See the discussion of TraverToy1 at the following URL:

http://snurl.com/lajw

In the next entry, I'll explain more about what the program does (some of the features are obvious in purpose, but some are not).

In the meantime, if you're willing to help out by trying things out and supplying some feedback, please send a private email to the following email address:

rb@ix.netcom.com.

Thanks!



Blog Home Page: http://traverrb.blogspot.com

Page for Programs and Files: http://traver.org/traverrb/


Barry Traver



Blog Home Page: http://traverrb.blogspot.com/

Programs and Files Discussed in the Blog: http://traver.org/traverrb/

Friday, December 30, 2005

Intro to RSS and Some RB News Feeds

The purpose of this entry is to introduce RSS news feeds in general and some RB news feeds in particular. If you are aware of other worthwhile RB news feeds not listed here, please let me know, so that I can mention them in a future entry.

Although people agree on what "RSS" news feeds are, there is no such agreement on what "RSS" stands for. There are at least three options: "Rich Site Summary," "Really Simple Syndication," and "RDF Site Summary," where "RDF" stands for "Resource Data Framework," which makes it all sound much more complicated than it really is.

Let's see if I can explain it in simpler terms. If a site has an RSS news feed, using it is similar to your subscribing to a "what's new" newsletter related to that site, with some important advantages to a news feed.

For example, there is no mailing list (thus no hassle for the provider in maintaining and updating one and no hassle for the person reading a news feed (e.g., receiving spam mail as a result of getting on a mailing list he or she doesn't want to be on).

To get full benefit, you do need a "news reader" or "feed reader" program (sometimes also called an "aggregator") which automatically goes out on a regular basis (say, once an hour) to check your favorite sites for anything new in their RSS news feed, but many such programs are available for free (such as Abilon for Windows).

Here's a fairly large list of news reader programs available:

http://snurl.com/2dwz

And here's where you can find some smaller lists:

http://snurl.com/4b14

http://snurl.com/l5s1

A common way to set up such a program is to get the headlines and the first paragraphs of "what's new" on the site. You then can decide whether you're interested enough in a particular item to read the entire article. Many news channels (CNN, New York Times, etc.) make use of news feeds to get out the news in general, but there are also some news feeds that are specifically oriented toward REALbasic.

Before I mention a few, let me just briefly say that there is a competing format to RSS known as Atom, but you don't really have to concern yourself much with that, since many news feed reader programs can handle either format.

Now for the RSS news feeds for RB. Here are some to start with:

This blog (RB's: Where's the Beef?):

http://feeds.feedburner.com/RbsWheresTheBeef

REAL Software:

http://www.realsoftware.com/news/rss/

RB Garage:

http://feeds.feedburner.com/rbgarage

I'm new to this myself, so I make no guarantees regarding the quality of these particular feeds (except for the RSS for this blog, of course, which is guaranteed to be an amateur production <grin>).

Barry Traver

P.S. I was away from home visiting family for the Christmas holidays. That's why for a few days there have been new blogs without new programs to accompany them, but that should change now that I'm back home again.

Barry Traver



Blog Home Page: http://traverrb.blogspot.com/

Programs and Files Discussed in the Blog: http://traver.org/traverrb/

Thursday, December 29, 2005

Method "Overload" Comments: Further Discussion

Note at the end of each blog entry there is an indication of how many comments have been posted to that particular entry. Sad to say, most of them say "0 comments," but after the immediately previous entry there were "4 comments" (well, actually 2 comments plus 2 responses from me).

If you click on the "... comments" you will be taken to an area where you can read comments people have posted or you can post a comment yourself. Before you can post a comment, you do have to register with Blogger.com, but you can register without having to start a blog.

Some helpful comments were posted by "silverpie":
Two improvements I would suggest: CStr() instead of Str(), so that if the user's format isn't US, it will still display as the user expects. Second, have the numeric version take a double as its parameter--it will still accept integers, but can thus show fractional values too.
Actually, even by itself CStr does much of what my "overloaded" S function does, i.e., it Converts to a Str a number of different data types. But I would argue that my S function still has at least two advantages: (1) It is easier to type one character ("S") rather than four ("CStr"), and (2) my S function has other features built in (specifically, EndOfLine and "|"). Here's the improved version of one of my definitions, thanks to silverpie's comments:
Function S (Param1 As Double) As String
Return EndOfLine + CStr(Param1) + EndOfLine
End Function
(The other definitions remain as they were before.)

I'd be interested to hear if people reading this have any of their own suggestions for worthwhile Method "overloads."

Also posted was this comment from Darryl of "glenarbourtech":
Hey Barry,

I just wanted to comment that as a RealBasic newbie, I really appreciate what you are doing here. Keep up the good work!

Darry|
Both posts are important because they both encourage me to keep this blog going. Writing a blog and writing programs takes time and effort (in short, it's a lot of work!), and what keeps me going is getting feedback from readers. So please feel free to post a helpful comment or a relevant question and/or please feel free to write me a private email at rb@ix.netcom.com.

Barry Traver



Blog Home Page: http://traverrb.blogspot.com/

Programs and Files Discussed in the Blog: http://traver.org/traverrb/