Xojo Conferences
MBSOct2019CologneDE

RB NUG FAQ 010 (Real Studio network user group Mailinglist archive)

Back to the thread list
Previous thread: RB NUG FAQ 011
Next thread: REALinsects 2.1.1


Serializable ... kind of   -   Jan Erik Moström <
  RB NUG FAQ 010   -   Chris Cummer
   Re: RB NUG FAQ 010   -   Kevin Ballard
    Re: RB NUG FAQ 010   -   Will Leshner
     Re: RB NUG FAQ 010   -   Chris Cummer
      Transaction concept   -   Maximilian Tyrtania

RB NUG FAQ 010
Date: 05.05.02 20:34 (Sun, 05 May 2002 15:34:23 -0400)
From: Chris Cummer
The Unofficial RB-NUG FAQ

maintained by Chris Cummer
<email address removed>
http://www.postal-code.com/public/rbnugfaq.txt

Last updated: 05/05/2002
Issue: 010

Please send any relevant code examples, spelling corrections, FAQ
suggestions and question/answer rewording to the address above rather than
polluting the list. Cheers!

For more information about REALbasic: http://www.realbasic.com

New in this version: 4.5, 4.6

0.0 QUESTION INDEX

Miscellany
1.1 Is there a searchable archive of this newsgroup?
1.2 Is there an etiquette for posting to the RB NUG?
1.3 Who is this guy Matt Neuburg and why does he answer in page numbers?
1.4 I just launched REALbasic and received a warning that another copy
of REALbasic is already running with my serial number. Then it quits and I
must re-enter my serial numer. What's going on?

General Programming
2.1 How do I get the cube root?
2.2 Is MouseUp is broken in <insert control name herecontrol?
2.3 I get a stack overflow error when I try to call up to the parent's
EnableMenuItems event in my control subclass. What's going wrong?
2.4 My menubars appear disabled until I click on them. Then they appear
enabled, as they should. How can I make the menus refresh themselves?
2.5 Why won't ImageWells and Bevel buttons accept the image I'm trying
to put into them?

Classic
3.1 When I run my application in Classic I have two Apple menus showing,
one with an About box, one without. Huh?

OS X
4.1 How do I enable the Preferences menu under the Application menu?
4.2 How do I use the Preferences menu under the Application menu?
4.3 How do I use sheets in my application?
4.4 How do I add an OS X application icon to my app?
4.5 How do I execute a command via the command line from REALbasic as
root?
4.6 How can I use sheets in my application?

1.0 MISCELLANY

1.1 Q: Is there a searchable archive of this newsgroup?
A: Yes. Chris Little writes:
"The most comprehensive archives are at:

http://dbserver.realsoftware.com/KBDB/search.php
http://realbasic.zapkerpow.com/

1.2 Q: Is there an etiquette for posting to the RB NUG?
A: No, however as Frank Bitterlich points out there are some general
rules you might follow to make life easier for everyone else on the list:

1. "Send messages to the NUG in plain-text emails only. HTML posts are
frowned upon for three reasons: HTML messages are completely unreadable on
the digest; some email clients cannot process HTML emails; and they increase
the list volume unnecessary."
2. "If you invoke an email auto-reply system on you mail account before
going on vacation, UNSUBSCRIBE from the list. It's no fun to watch the list
getting flooded with "I'm on vacation..." emails from your account as you
receive list email."
3. And I would add: keep in mind that the programming skills and
experience of the members on this list vary greatly, from those with decades
of of experience to those with literally none. Questions are bound to
reflect the skill level of the poster; be nice and try to couch your
responses accordingly.

The "Unofficial REALbasic NUG List Netiquette FAQ", maintained by Peter
Job, is an excellent resource on exactly what the title says.Check it out
at:

http://www.ziggy.speedhost.com/rbnugfaq.html

1.3 Q: Who is this guy Matt Neuburg and why does he answer in page numbers?
A: Matt is the author of the seminal O'Reilly book "REALbasic: The
Definitive Guide" (currently in 2nd edition). When he answers in page
numbers he's referencing the contents of his book. Unpaid plug: you owe it
to yourself to check this book out.

1.4 Q: I just launched REALbasic and received a warning that another copy of
REALbasic is already running with my serial number. Then it quits and I must
re-enter my serial numer. What's going on?
A: Sometimes when REALbasic crashes and you restart it it will launch
with the message given above because of the copy protection scheme it
implements (assuming you actually aren't really using a duplicate serial
number on the same network). Restarting your computer should fix the
problem.


2.0 GENERAL PROGRAMMING

2.1 Q: How do I get the cube root?
A: pow(x, 1/3)

2.2 Q: Is MouseUp is broken in <insert control name herecontrol? I have code
in the MouseUp event of my control but nothing happenswhen I click on it.
A: No, you just need to first handle the MouseDown event. As
Charles Yeomans writes:
"You need to return TRUE from the MouseDown event, otherwise the MouseUp
event does not occur."

2.3 Q: I have a subclass of a control. I've created a new event called
EnableMenuItems so that I can execute the parent class's EnableMenuItems
event as well as the subclass's. When I try to call it I get a stack
overflow error. What's wrong?
A: In the EnableMenuItems event handler of your subclass you need to
call the parent class's EnableMenuItems event handler using:

EnableMenuItems()

Note the parenthesis on the end. Otherwise the subclass's
EnableMenuItems is calling itself recursively. (Thanks to Charles Yeomans).

2.4 Q: My menubars appear disabled until I click on them. Then they appear
enabled, as they should. How can I make the menus refresh themselves?
A: Use the EnableMenuItems global method to force a menu refresh.

2.5 Q: Why won't ImageWells and Bevel buttons accept the image I'm trying to
put into them?
A: Mike Benonis writes:
"ImageWells only like PICT images and not other formats. I wrote this
method to work around this issue:

Sub DisplayImageInImageWell( Image As Picture, IW As ImageWell )
Dim F As FolderItem
F=TemporaryFolder.Child("ImageWellConversion.temp")
F.SaveAsPicture Image

IW.Image=TemporaryFolder.Child("ImageWellConversion.temp").OpenAsPicture
F.Delete
End Sub

Pass the image you want displayed (it can be any image, even one
createdwith NewPicture) and the ImageWell you want to display it in, and
thismethod displays the image.

Here is a modified version to display images that a BevelButton doesn't
like (especially images created with NewPicture):

Sub DisplayImageInBevelButton(Image As Picture, B As BevelButton)
Dim F As FolderItem
F=TemporaryFolder.Child("BevelButtonConvert.temp")
F.SaveAsPicture Image

B.Icon=TemporaryFolder.Child("BevelButtonConvert.temp").OpenAsPicture
F.Delete
End Sub


3.0 CLASSIC

3.1 Q: When I run my application in Classic I have two Apple menus showing,
one with an About box, one without. Huh?
A: Noah Desch writes:"You have somewhere declared a call to CarbonLib.
In a classic app, this forces CarbonLib to load in addition to InterfaceLib,
causing a second apple menu to appear. Change the carbon declare to its
classic counterpart and you will be fine."

Which is to say: if you use Carbon declares, don't compile your
application for PPC.


4.0 OS X

4.1 Q: How do I enable the Preferences menu under the Application menu?
A: Via the following method:

Sub SetCarbonPrefsMenu( pBool as Boolean )
#If TargetCarbon then
Declare Sub EnableMenuCommand Lib "CarbonLib" (inMenu as Integer,
inCommandID as OSType)
Declare Sub DisableMenuCommand Lib "CarbonLib" (inMenu As Integer,
inCommandID As OSType)

If pBool Then
EnableMenuCommand 0,"pref"
Else
DisableMenuCommand 0, "pref"
End If

#Endif
End Sub

4.2 Q: How do I use the Preferences menu under the Application menu?
A: The Preferences menu sends an Apple event to your application when it
has been selected. To handle this appleevent, place the following code in
the HandleAppleEvent event of your Application class (you do have a class
extending Application, don't you?)

#If TargetCarbon then
// Handle the call from the Carbon preferences menu
If eventClass = "aevt" and eventID = "pref" then
// Do you prefs handling code here, such as...
PrefsWindow.show

return true
End if
#Endif

4.3 Q: How do I use sheets in my application?
A: Matthew Williams writes:
"Set your sheet (dialog) to MacProcID 1088 and window type to Document.
Then call the following code, which you can store in a global module:

Sub ShowSheet(sheet as window, parent as window)
Dim i as integer

#If TargetCarbon then
Declare Function ShowSheetWindow Lib "CarbonLib" (sheet As
WindowPtr, Parent as WindowPtr) As Short

i = ShowSheetWindow(sheet,parent)
#endif

sheet.showmodal
End Sub

Mike Benonis writes:
"One more thing. In your sheet's open event, call this function:

Declare Function SetThemeWindowBackground Lib "CarbonLib" ( inWindow As
WindowPtr, inBrush As Integer, inUpdate As Boolean) As Integer

Dim Err As Integer
Err=SetThemeWindowBackground(Self, 53, True)
If Err<>0 Then
MsgBox "SetThemeWindowBackground failed; err="+Str(Err)
End If

This will make your sheet transparent."

4.4 Q: How do I add an OS X application icon to my app?
A: Noah Desch writes:
"IconPaste and the RB build dialog don't support OSX icons. You'll need
to put the OSX icon resources into a resource file (with ID 128) which you
then drag into your project window. This will cause the icon resources to be
compiled into your application.

The only resource needed for OSX icons is the 'icns' resource, but
you'll probably want to include all the others as well in case someone tries
to use your program under OS 9."

Erick Tejkowski (author of "REALbasic for Dummies") has a tutorial for
adding OS X icons at:

http://www.ResExcellence.com/realbasic/12-13-01.shtml

4.5 Q: How do I execute a command via the command line from REALbasic as
root?
A: Joe Strout wrote:
The correct solution to this problem (which seems to come up here every
few days!) is:

s.execute "echo " + password + " | sudo -S someCommandGoesHere"

[Where s is an instance of shell - ed.]

Note that I'm using sudo here instead of su; this is both because su is
dangerous and not recommended by Apple, and because sudo has a "-S" option
which tells it to get the password from stdin, which su does not have (as
far as I can tell).

To get the password into stdin, we feed it to echo, which echoes it
right back, and pipe the output of that to the input of sudo.

4.6 Q: How can I use Sheets in my application?
A: Currently you cannot. REALbasic compile Carbon-based applications and
sheets are a Cocoa-only feature.

Cheers,
Chris

________________________________________________________________
PostalCode, Inc. (416) 737-2633

http://www.postal-code.com
________________________________________________________________

---
Subscribe to the digest:
<mailto:<email address removed>>
Unsubscribe:
<mailto:<email address removed>>

Re: RB NUG FAQ 010
Date: 05.05.02 20:43 (Sun, 05 May 2002 15:43:42 -0400)
From: Kevin Ballard
On 5/5/02 3:34 PM, "Chris Cummer" <<email address removed>> wrote:

> 4.6 Q: How can I use Sheets in my application?
> A: Currently you cannot. REALbasic compile Carbon-based applications and
> sheets are a Cocoa-only feature.

4.5 alphas include sheet support. You could refer to that instead.

Re: RB NUG FAQ 010
Date: 06.05.02 01:03 (Sun, 5 May 2002 17:03:19 -0700)
From: Will Leshner
I thought of that, but would vote against it (is this a democracy :) .
When 4.5 comes out, then you could include the stuff about sheets. But
think the FAQ is getting pretty good and we should start directing some
newbies to it more than we do. And for now, the current sheets answer is
probably the right one for what most people just starting out are doing.

On Sunday, May 5, 2002, at 12:43 PM, Kevin Ballard wrote:

> On 5/5/02 3:34 PM, "Chris Cummer" <<email address removed>> wrote:
>
>> 4.6 Q: How can I use Sheets in my application?
>> A: Currently you cannot. REALbasic compile Carbon-based applications
>> and
>> sheets are a Cocoa-only feature.
>
> 4.5 alphas include sheet support. You could refer to that instead.
>
> --
> Kevin Ballard
> kevin@sb.org
> Email from Korea or China must go to <kevin.nb@sb.org>
> http://kevin.sb.org/
>
> ---
> Subscribe to the digest:
> <mailto:<email address removed>>
> Unsubscribe:
> <mailto:<email address removed>>

---
Subscribe to the digest:
<mailto:<email address removed>>
Unsubscribe:
<mailto:<email address removed>>

Re: RB NUG FAQ 010
Date: 06.05.02 05:26 (Mon, 06 May 2002 00:26:52 -0400)
From: Chris Cummer
Will Leshner wrote:

> But
> think the FAQ is getting pretty good and we should start directing some
> newbies to it more than we do. And for now, the current sheets answer is
> probably the right one for what most people just starting out are doing.

Thanks Will. The intention with the FAQ is to reflect the status of the
current commercial, shipping version of REALbasic. As such references to dev
versions, which are subject to the whims of REAL Software's development
cycle, likely won't be reflected in it.

Regarding the sheet issue: I'd originally meant to write "drawer" but had
sheets on my mind and miswrote that instead. Given the wealth of excellent
plugins and declare code available to add sheet support one can pretty much
consider sheets a feature of Rb right now (in fact, FAQ question 4.3
describes exactly how to implement sheets with the current version of Rb).

Cheers,
Chris

________________________________________________________________
PostalCode, Inc. (416) 737-2633

http://www.postal-code.com
________________________________________________________________

---
Subscribe to the digest:
<mailto:<email address removed>>
Unsubscribe:
<mailto:<email address removed>>