Comon! Enough with "This item does not exist"

Another piece of documentation code that supposedly doesn’t exist according to the debugger.

b=d.ShowModalWithin(Window1)                //display the dialog in Window1
Select Case b                               //determine which button was pressed.
Case d.ActionButton
  //user pressed Save
Case d.AlternateActionButton
  //user pressed Don't Save
Case d.CancelButton
  //user pressed Cancel
End select

Guess what? “ActionButton” doesn’t exist! It isn’t in the autocomplete either. I’m thinking about switching to another IDE because this whole “doesn’t exist” crap is getting annoying. If it’s in the autocomple, which “ActionButton” is when creating a MessageDialog, then it SHOULD EXIST in the autocomple when coding the results. I’m also getting tired of the seemingly blank errors like “NilObjectException”, if I’m missing an “Then”, then TELL ME I’M MISSING THE DAMN “Then”. Don’t just set me off on a wild error chase. At least in other IDEs (like Xamarin), if I don’t have something the IDE actually tells me WHAT I’M missing.

using System;

namespace synerrorcheck
	class MainClass
		public static void Main (string[] args)
			String myString = "Hello";
			if (myString.Contains "ello"

For example, I did not type the “)” and “;” and oh my, instead of “NilObjectException”, the IDE tells me that it’s expecting an “)” and “;”. I love Xojo to death, but until some of it’s language practices mature, I’ll be using Xamarin. At least with Xamarin, I’m able to view C# docs and tutorials.


ROTFL “C.R.A.P” and is sensored but “damn” isn’t? Real embarrassing!

Cant say I have ever seen a message of ‘NilObjectException’ due to a missing ‘then’

dim x as integer if x = 0 msgbox "hello" end if

What I get is 'The keyword ‘Then’ is expected after this if statement’s condition
Thats a compile time check.

A NilObjectException happens at run time, because you didn’t initialise an object.

Like this:

dim d as date dim x as integer if x = 0 then msgbox str(

…It wont be much to do with a missing THEN.

dim d as new date 'properly initialised dim x as integer if x = 0 then msgbox str(

All that said, if you really DO get NilObjectExceptions while working in the IDE and before running your app , thats a bug.
Is that what’s happening?

SInce you didn’t post all the code… I am going to “guess” here…

and say that “D” is not initialized, ie it is NIL, and autocomplete cannot do its job if it doesn’t know what it is SUPPOSED to do.

are you perhaps missing

Dim d As New MessageDialog

You certainly could get an error like this with a missing THEN statement because properties are scoped.

The example code works if you copy & paste it - I just did

Create a new desktop project
Add a button
Add the Action EVent to that button
In the Action event CUT & PASTE the code from MessageDialog (see the example at the bottom of )

Now alter the ShowModal line to say

b=d.ShowModalWithin(self)                              //display the dialog

The reason I’d use SELF instead of a window by name is that self means “the window this code is executing in” so even if you cut & paste the button OR the code to another window it will show on that window - which is probably what you want.

[quote=38531:@Dave S]I am going to “guess” here…
and say that “D” is not initialized, ie it is NIL, and autocomplete cannot do its job if it doesn’t know what it is SUPPOSED to do.[/quote]
Nope, that’s certainly not it. Neither the compiler nor autocomplete cares (or even knows) whether the instance is created with new or not, as long as the variable “d” is defined to be of type MessageDialog. If the compiler would know, it would be able to tell us upfront (during compiling) that we’d be getting a nil ptr exception if we ran the code.

Also, in fact, autocomplete FAILS if you use the “new” in it, at least that’s how it was still in RB 2012r2. Its parser doesn’t understand this new syntax of inlining “new” in a variable declaration and thus doesn’t know the type of “d”. Actually, that might be the reason why autocomplete isn’t working for Shane. If Shane changes the code from:

Dim d As New MessageDialog


Dim d As MessageDialog d = New MessageDialog

then autocomplete should work better for “d”.