Why does this crash rb? (Real Studio network user group Mailinglist archive)

Back to the thread list
Previous thread: command key symbol on bottons
Next thread: Will REALbasic Ever allow ...?


[OT] How to compile Carbon Shared Library w/ProjectBuilder?   -   Hadley, Joshua
  Why does this crash rb?   -   The Carbon 6 Dev. Team.
   Re: Why does this crash rb?   -   CV
   Re: Why does this crash rb?   -   Charles Yeomans
   Re: Why does this crash rb?   -   Michael MacAskill
    Re: Why does this crash rb?   -   Dean Davis
     Re: Why does this crash rb?   -   Aaron Ballman
     Re: Why does this crash rb?   -   Noah Desch
     Re: Why does this crash rb?   -   Mal Paine
      Re: Why does this crash rb?   -   Will Leshner
     Re: Why does this crash rb?   -   Charles Yeomans
    Re: Why does this crash rb?   -   Dean Davis
    Re: Why does this crash rb?   -   Dean Davis
    Re: Why does this crash rb?   -   Dean Davis
     Re: Why does this crash rb?   -   Will Leshner
    Re: Why does this crash rb?   -   Dean Davis

Why does this crash rb?
Date: 12.12.02 01:07 (Wed, 11 Dec 2002 16:07:41 -0800)
From: The Carbon 6 Dev. Team.
ok so i have a subclass of menuitem called presetApps and this is in my
main window but rb crashes every time whats up?

dim i as integer
dim folder as FolderItem
dim newmenu as MenuItem

folder = GetFolderItem( "Resources" ).Child( "presetApps" )

if folder <> nil and folder.Exists then
for i = folder.Count DownTo 1
If folder.Item(i).Visible = True and left(folder.item(i).name,1)
<> "." Then
if i - 1 <> 0 then
newmenu = new presetApps
newmenu.Text = folder.Item(i).DisplayName
else
'newmenu = presetApps(0).Index
end

'newmenu.ParentFile = folder.item(i)
End
Next
End

---
A searchable archive of this list is available at:
<http://dbserver.realsoftware.com/KBDB/search.php>

Unsubscribe:
<mailto:<email address removed>>

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

Re: Why does this crash rb?
Date: 12.12.02 03:21 (Wed, 11 Dec 2002 20:21:40 -0600)
From: CV
Did you get a message that indicated the nature and location of the "crash"?
If so, put a breakpoint at the line before, then in the debugger check your
variables and objects with respect to the info in the message.

Jack

----- Original Message -----
From: "The Carbon 6 Dev. Team." <<email address removed>>
To: "REALbasic Group" <<email address removed>>
Sent: Wednesday, December 11, 2002 6:07 PM
Subject: Why does this crash rb?

> ok so i have a subclass of menuitem called presetApps and this is in my
> main window but rb crashes every time whats up?
>
> dim i as integer
> dim folder as FolderItem
> dim newmenu as MenuItem
>
> folder = GetFolderItem( "Resources" ).Child( "presetApps" )
>
> if folder <> nil and folder.Exists then
> for i = folder.Count DownTo 1
> If folder.Item(i).Visible = True and left(folder.item(i).name,1)
> <> "." Then
> if i - 1 <> 0 then
> newmenu = new presetApps
> newmenu.Text = folder.Item(i).DisplayName
> else
> 'newmenu = presetApps(0).Index
> end
>
> 'newmenu.ParentFile = folder.item(i)
> End
> Next
> End
> Subscribe to the digest:
> <mailto:<email address removed>>

---
A searchable archive of this list is available at:
<http://dbserver.realsoftware.com/KBDB/search.php>

Unsubscribe:
<mailto:<email address removed>>

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

Re: Why does this crash rb?
Date: 12.12.02 16:44 (Thu, 12 Dec 2002 10:44:18 -0500)
From: Charles Yeomans
It's hard to tell because "rb crashes every time" isn't very specific.

Charles Yeomans

On Wednesday, December 11, 2002, at 07:07 PM, The Carbon 6 Dev. Team.
wrote:

> ok so i have a subclass of menuitem called presetApps and this is in
> my main window but rb crashes every time whats up?
>
> dim i as integer
> dim folder as FolderItem
> dim newmenu as MenuItem
>
> folder = GetFolderItem( "Resources" ).Child( "presetApps" )
>
> if folder <> nil and folder.Exists then
> for i = folder.Count DownTo 1
> If folder.Item(i).Visible = True and left(folder.item(i).name,1)
> <> "." Then
> if i - 1 <> 0 then
> newmenu = new presetApps
> newmenu.Text = folder.Item(i).DisplayName
> else
> 'newmenu = presetApps(0).Index
> end
>
> 'newmenu.ParentFile = folder.item(i)
> End
> Next
> End
>


---
A searchable archive of this list is available at:
<http://dbserver.realsoftware.com/KBDB/search.php>

Unsubscribe:
<mailto:<email address removed>>

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

Re: Why does this crash rb?
Date: 12.12.02 05:30 (Thu, 12 Dec 2002 17:30:14 +1300)
From: Michael MacAskill
Jack,

Your message uses the term "debugger". You seem to be unaware that the
Carbon 6 Dev. Team are using a rare version of REALbasic in which the
debugger is actually disabled in favour of generating an automatic e-mail
query to this list. All responses to those e-mails should therefore include
the complete solution rather than mere suggestions of how to reach the
solution.

Cheers,

Mike

> Subject: Re: Why does this crash rb?
> From: "CV" <<email address removed>>
> Date: Wed, 11 Dec 2002 20:21:40 -0600
>
> Did you get a message that indicated the nature and location of the "crash"?
> If so, put a breakpoint at the line before, then in the debugger check your
> variables and objects with respect to the info in the message.
>
> Jack
>
> ----- Original Message -----
> From: "The Carbon 6 Dev. Team." <<email address removed>>


---
A searchable archive of this list is available at:
<http://dbserver.realsoftware.com/KBDB/search.php>

Unsubscribe:
<mailto:<email address removed>>

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

Re: Why does this crash rb?
Date: 12.12.02 17:06 (Thu, 12 Dec 2002 11:06:33 -0500)
From: Dean Davis
One possibility is the line...
"if folder <> nil and folder.Exists then"

You should never check the nilness of a folderitem (or any object for that
matter) and a property of that object in the same "if" statement. Why? What
if the folderitem/object is nil? Then folder.exists will give you a
nilobjectexception (not the same as a crash I understand, but still...).

Dean Davis

>From: Charles Yeomans <<email address removed>>
>Reply-To: "REALbasic Network Users Group"
><<email address removed>>
>To: "REALbasic Network Users Group" <<email address removed>>
>Subject: Re: Why does this crash rb?
>Date: Thu, 12 Dec 2002 10:44:18 -0500
>
>It's hard to tell because "rb crashes every time" isn't very specific.
>
>Charles Yeomans
>
>On Wednesday, December 11, 2002, at 07:07 PM, The Carbon 6 Dev. Team.
>wrote:
>
>>ok so i have a subclass of menuitem called presetApps and this is in my
>>main window but rb crashes every time whats up?
>>
>> dim i as integer
>> dim folder as FolderItem
>> dim newmenu as MenuItem
>>
>> folder = GetFolderItem( "Resources" ).Child( "presetApps" )
>>
>> if folder <> nil and folder.Exists then
>> for i = folder.Count DownTo 1
>> If folder.Item(i).Visible = True and left(folder.item(i).name,1) <>
>>"." Then
>> if i - 1 <> 0 then
>> newmenu = new presetApps
>> newmenu.Text = folder.Item(i).DisplayName
>> else
>> 'newmenu = presetApps(0).Index
>> end
>>
>> 'newmenu.ParentFile = folder.item(i)
>> End
>> Next
>> End
>>

_________________________________________________________________
The new MSN 8: smart spam protection and 2 months FREE*
http://join.msn.com/?pageþatures/junkmail

---
A searchable archive of this list is available at:
<http://dbserver.realsoftware.com/KBDB/search.php>

Unsubscribe:
<mailto:<email address removed>>

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

Re: Why does this crash rb?
Date: 12.12.02 17:10 (Thu, 12 Dec 2002 10:10:18 -0600)
From: Aaron Ballman
>One possibility is the line...
>"if folder <> nil and folder.Exists then"
>
>You should never check the nilness of a folderitem (or any object
>for that matter) and a property of that object in the same "if"
>statement. Why? What if the folderitem/object is nil? Then
>folder.exists will give you a nilobjectexception (not the same as a
>crash I understand, but still...).

It is perfectly legitimate to do this. What the above statement
evaluates out to (in terms of logic) is:

if folder <> nil then
if folder.Exists then
blah blah blah
end
end

Because of the 'and', if the first expression evaluates to false, the
entire if statement is false, and thus it doesn't need to check any
subsequent expressions in the 'if'.

~Aaron

Re: Why does this crash rb?
Date: 12.12.02 17:12 (Thu, 12 Dec 2002 11:12:05 -0500)
From: Noah Desch
>One possibility is the line...
>"if folder <> nil and folder.Exists then"
>
>You should never check the nilness of a folderitem (or any object
>for that matter) and a property of that object in the same "if"
>statement. Why? What if the folderitem/object is nil? Then
>folder.exists will give you a nilobjectexception (not the same as a
>crash I understand, but still...).

No that is simply not true. RB, like many other languages, uses short
circuit logic to evaluate if statements. If folder is nil, it won't
bother to check the rest of the statement. The above code is
perfectly safe.

-Noah Desch

---
A searchable archive of this list is available at:
<http://dbserver.realsoftware.com/KBDB/search.php>

Unsubscribe:
<mailto:<email address removed>>

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

Re: Why does this crash rb?
Date: 12.12.02 17:16 (Thu, 12 Dec 2002 11:16:22 -0500)
From: Mal Paine
> You should never check the nilness of a folderitem (or any object for that
> matter) and a property of that object in the same "if" statement. Why? What
> if the folderitem/object is nil? Then folder.exists will give you a
> nilobjectexception (not the same as a crash I understand, but still...).

If RB is any kind of real programming language, then it implements
short-circuit evaluation. What this means is that in a statement like
"If a and b and c then", if a is false, b and c aren't even checked since
it's an 'and' statement, and one false value causes the whole statement to
be false. Similarly, in a statement like "If a or b or c then", if a is
true, then b and c aren't checked.

Now, most programming languages do this. I don't know if RB does, but if it
doesn't, it should.

-----------------------
mal paine
<email address removed>

ilesa software
http://www.ilesa.com
<email address removed>

---
A searchable archive of this list is available at:
<http://dbserver.realsoftware.com/KBDB/search.php>

Unsubscribe:
<mailto:<email address removed>>

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

Re: Why does this crash rb?
Date: 12.12.02 17:23 (Thu, 12 Dec 2002 08:23:02 -0800)
From: Will Leshner
It does.

On Thursday, December 12, 2002, at 08:16 AM, Mal Paine wrote:

> Now, most programming languages do this. I don't know if RB does, but
> if it
> doesn't, it should.


---
A searchable archive of this list is available at:
<http://dbserver.realsoftware.com/KBDB/search.php>

Unsubscribe:
<mailto:<email address removed>>

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

Re: Why does this crash rb?
Date: 12.12.02 17:25 (Thu, 12 Dec 2002 11:25:01 -0500)
From: Charles Yeomans

On Thursday, December 12, 2002, at 11:06 AM, Dean Davis wrote:

> One possibility is the line...
> "if folder <> nil and folder.Exists then"
>
> You should never check the nilness of a folderitem (or any object for
> that matter) and a property of that object in the same "if" statement.
> Why? What if the folderitem/object is nil? Then folder.exists will
> give you a nilobjectexception (not the same as a crash I understand,
> but still...).
>

AND is a non-strict operator; in this case, it means that the
expression (folder <> nil) is evaluated; if it false, then RB knows
that (folder <> nil) AND b will always evaluate to false, so it returns
without evaluating the rest of the expression.

Charles Yeomans


---
A searchable archive of this list is available at:
<http://dbserver.realsoftware.com/KBDB/search.php>

Unsubscribe:
<mailto:<email address removed>>

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

Re: Why does this crash rb?
Date: 12.12.02 17:14 (Thu, 12 Dec 2002 11:14:30 -0500)
From: Dean Davis
Interesting, I could of swore I got caught on this before. I stand
corrected.

Thinking back I may have gotten caught on newbie illogic and wrote a
statement like...
"if object = nil or object.booleanproperty = false then"

Thanks.
Dean Davis

>From: Aaron Ballman <<email address removed>>
>Reply-To: "REALbasic Network Users Group"
><<email address removed>>
>To: "REALbasic Network Users Group" <<email address removed>>
>Subject: Re: Why does this crash rb?
>Date: Thu, 12 Dec 2002 10:10:18 -0600
>
>>One possibility is the line...
>>"if folder <> nil and folder.Exists then"
>>
>>You should never check the nilness of a folderitem (or any object for that
>>matter) and a property of that object in the same "if" statement. Why?
>>What if the folderitem/object is nil? Then folder.exists will give you a
>>nilobjectexception (not the same as a crash I understand, but still...).
>
>It is perfectly legitimate to do this. What the above statement evaluates
>out to (in terms of logic) is:
>
>if folder <> nil then
> if folder.Exists then
> blah blah blah
> end
>end
>
>Because of the 'and', if the first expression evaluates to false, the
>entire if statement is false, and thus it doesn't need to check any
>subsequent expressions in the 'if'.
>
>~Aaron
>--

_________________________________________________________________
Add photos to your messages with MSN 8. Get 2 months FREE*.
http://join.msn.com/?pageþatures/featuredemail

---
A searchable archive of this list is available at:
<http://dbserver.realsoftware.com/KBDB/search.php>

Unsubscribe:
<mailto:<email address removed>>

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

Re: Why does this crash rb?
Date: 12.12.02 17:19 (Thu, 12 Dec 2002 11:19:48 -0500)
From: Dean Davis
Stirke that, reverse it.
"if object.booleanproperty = false or object = nil then"

Dean "Stop the Madness" Davis



>From: "Dean Davis" <<email address removed>>
>Reply-To: "REALbasic Network Users Group"
><<email address removed>>
>To: <email address removed>
>Subject: Re: Why does this crash rb?
>Date: Thu, 12 Dec 2002 11:14:30 -0500
>
>Interesting, I could of swore I got caught on this before. I stand
>corrected.
>
>Thinking back I may have gotten caught on newbie illogic and wrote a
>statement like...
>"if object = nil or object.booleanproperty = false then"
>
>Thanks.
>Dean Davis
>
>>From: Aaron Ballman <<email address removed>>
>>Reply-To: "REALbasic Network Users Group"
>><<email address removed>>
>>To: "REALbasic Network Users Group"
>><<email address removed>>
>>Subject: Re: Why does this crash rb?
>>Date: Thu, 12 Dec 2002 10:10:18 -0600
>>
>>>One possibility is the line...
>>>"if folder <> nil and folder.Exists then"
>>>
>>>You should never check the nilness of a folderitem (or any object for
>>>that matter) and a property of that object in the same "if" statement.
>>>Why? What if the folderitem/object is nil? Then folder.exists will give
>>>you a nilobjectexception (not the same as a crash I understand, but
>>>still...).
>>
>>It is perfectly legitimate to do this. What the above statement evaluates
>>out to (in terms of logic) is:
>>
>>if folder <> nil then
>> if folder.Exists then
>> blah blah blah
>> end
>>end
>>
>>Because of the 'and', if the first expression evaluates to false, the
>>entire if statement is false, and thus it doesn't need to check any
>>subsequent expressions in the 'if'.
>>
>>~Aaron
>>--
>
>_________________________________________________________________
>Add photos to your messages with MSN 8. Get 2 months FREE*.
>http://join.msn.com/?pageþatures/featuredemail
>
>---
>A searchable archive of this list is available at:
><http://dbserver.realsoftware.com/KBDB/search.php>
>Unsubscribe:
><mailto:<email address removed>>
>Subscribe to the digest:
><mailto:<email address removed>>

_________________________________________________________________
Tired of spam? Get advanced junk mail protection with MSN 8.
http://join.msn.com/?pageþatures/junkmail

---
A searchable archive of this list is available at:
<http://dbserver.realsoftware.com/KBDB/search.php>

Unsubscribe:
<mailto:<email address removed>>

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

Re: Why does this crash rb?
Date: 12.12.02 17:30 (Thu, 12 Dec 2002 11:30:49 -0500)
From: Dean Davis
I really love the RB mailing lists but this thread is the example of my
love-hate relationship with it.

I obviously don't mind being corrected but being corrected 5 times is a
little much. But such is the nature of a mailing list as opposed to an
online forum/discussion board.

Thanks to all the respondents to my mistake. Chalk it up to "Learn something
new everyday."

Dean Davis

>From: Charles Yeomans <<email address removed>>
>Reply-To: "REALbasic Network Users Group"
><<email address removed>>
>To: "REALbasic Network Users Group" <<email address removed>>
>Subject: Re: Why does this crash rb?
>Date: Thu, 12 Dec 2002 11:25:01 -0500
>
>On Thursday, December 12, 2002, at 11:06 AM, Dean Davis wrote:
>
>>One possibility is the line...
>>"if folder <> nil and folder.Exists then"
>>
>>You should never check the nilness of a folderitem (or any object for that
>>matter) and a property of that object in the same "if" statement. Why?
>>What if the folderitem/object is nil? Then folder.exists will give you a
>>nilobjectexception (not the same as a crash I understand, but still...).
>>
>AND is a non-strict operator; in this case, it means that the expression
>(folder <> nil) is evaluated; if it false, then RB knows that (folder <>
>nil) AND b will always evaluate to false, so it returns without evaluating
>the rest of the expression.
>
>Charles Yeomans
>
>---
>A searchable archive of this list is available at:
><http://dbserver.realsoftware.com/KBDB/search.php>
>Unsubscribe:
><mailto:<email address removed>>
>Subscribe to the digest:
><mailto:<email address removed>>

_________________________________________________________________
Tired of spam? Get advanced junk mail protection with MSN 8.
http://join.msn.com/?pageþatures/junkmail

---
A searchable archive of this list is available at:
<http://dbserver.realsoftware.com/KBDB/search.php>

Unsubscribe:
<mailto:<email address removed>>

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

Re: Why does this crash rb?
Date: 12.12.02 17:53 (Thu, 12 Dec 2002 08:53:00 -0800)
From: Will Leshner
Sorry about that. I don't think it's because we are trying to be
obnoxious. I think it's just that we fire off a response without
realizing that 5 other people are doing the same thing. Some things get
no responses. Some things get too many.

On Thursday, December 12, 2002, at 08:30 AM, Dean Davis wrote:

> I obviously don't mind being corrected but being corrected 5 times is
> a little much. But such is the nature of a mailing list as opposed to
> an online forum/discussion board.


---
A searchable archive of this list is available at:
<http://dbserver.realsoftware.com/KBDB/search.php>

Unsubscribe:
<mailto:<email address removed>>

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

Re: Why does this crash rb?
Date: 13.12.02 02:54 (Thu, 12 Dec 2002 20:54:08 -0500)
From: Dean Davis
Oh no, I don't think anyone was even close to being obnoxious, in fact this
group has always been more than pleasent. I'm just a big fan of on-line Q&A
forums and have always secretly wished this list was a threaded forum.

Dean Davis

>From: Will Leshner <<email address removed>>
>Reply-To: "REALbasic Network Users Group"
><<email address removed>>
>To: "REALbasic Network Users Group" <<email address removed>>
>Subject: Re: Why does this crash rb?
>Date: Thu, 12 Dec 2002 08:53:00 -0800
>
>Sorry about that. I don't think it's because we are trying to be obnoxious.
>I think it's just that we fire off a response without realizing that 5
>other people are doing the same thing. Some things get no responses. Some
>things get too many.
>
>On Thursday, December 12, 2002, at 08:30 AM, Dean Davis wrote:
>
>>I obviously don't mind being corrected but being corrected 5 times is a
>>little much. But such is the nature of a mailing list as opposed to an
>>online forum/discussion board.

_________________________________________________________________
The new MSN 8: advanced junk mail protection and 2 months FREE*
http://join.msn.com/?pageþatures/junkmail

---
A searchable archive of this list is available at:
<http://dbserver.realsoftware.com/KBDB/search.php>

Unsubscribe:
<mailto:<email address removed>>

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