OT: Analyzing competitors - In this case Real Software

Ken Ray kray at sonsothunder.com
Tue Mar 22 18:53:56 EST 2005


On 3/22/05 4:06 PM, "Keith Hutchison"
<keith.hutchison at balance-infosystems.com> wrote:

>> Rev:
>> -----
>> put the effective textFont of the selection into tFont
>> if tFont <> the label of me then
>>   select line (lineOffset(cr& tFont &cr,cr&btn "FontMenu"&cr)) of
>>     btn "FontMenu"
>> end if
>> 
>> or, if you like a one-liner:
>> 
>> select line (lineOffset(cr&(the effective textFont of the selection)
>>   &cr,cr&btn "FontMenu"&cr)) of btn "FontMenu"
> 
> You could also subclass, or extend the syntax of realBasic and have code
> which is
> RealBasic - one line
> ------------------------
> fontMenuButton.font = Me.SelTextFont

Well sure, but you can also abtract the Rev code to a one liner as well:

  SetFontButton "FontMenu"

which would call a custom handler to check the current selection and set the
button name passed to it.

> Which code is easier to read/understand?

Mine. ;-)

No, seriously... it all depends on who's doing the reading. Keith, yours is
as easy to read as mine is, but that's because I have a background in VB and
RB. However someone who doesn't have a background in either would find both
equally difficult to understand.
 
> If I want a font menu on a window I just drop a popup menu on the window and
> set it's subclass to kjtlPopupMenuFont.
> 
> That's it.
> 
> Ignorance is a dangerous thing ...

Yes, there are plenty of ways to make it easier to work with in RB. But even
if you subclass, you still have to set up the font menu in the first place
using code similar to what was presented in the RB tutorial. It is only
*later* that you get the benefits of your earlier work. What I was showing
was that "out of the box" the comparison *in this limited case* shows that
Rev takes less code.

HOWEVER, in *the same* tutorial comparison, there are clearly places where
RB is superior. For example, there is a place where you configure a text
field to accept dragged-and-dropped text documents. Here, RB is clearly
superior:

RB:
----
Me.AcceptFileDrop("text")

Rev:
-----
on dragEnter
  if hasTextFiles(the dragData["files"]) then
    set the acceptDrop to true
    focus me
  end if
end dragEnter
 
function hasTextFiles pFileList
  -- assumes all files are from the same folder, looks for
  -- any file that is a text file
  -- If found, sets a custom prop to be used during the drop
  -- looks for both file extension and type of file
  put the directory into tOldDir
  set the itemDel to "/"
  repeat for each line tFile in pFileList
    if tTextFiles = "" then
     set the directory to (item 1 to ­2 of tFile)
     put the detailed files into tFiles
     replace "," with "/" in tFiles
    end if
    put lineOffset(cr& urlEncode(item -1 of tFile)&",",cr&tFiles) into tLine
    put item -1 of line tLine of tFiles into tTypeCreator
    if (char -4 to -1 of tTypeCreator = "TEXT") or (char -4 to -1 of tFile =
".txt") then put tFile & cr after tTextFiles
  end repeat
  set the directory to tOldDir
  delete last char of tTextFiles
  set the uTextFiles of me to tTextFiles
  return (tTextFiles <> "")
end hasTextFiles

And I would *kill* for RB's subclassing and toolbox access in Rev. Anyway,
you get the picture,


Ken Ray
Sons of Thunder Software
Web site: http://www.sonsothunder.com/
Email: kray at sonsothunder.com




More information about the use-livecode mailing list