xsharp.eu • Calling a class that has no public constructor - Page 2
Page 2 of 2

Calling a class that has no public constructor

Posted: Wed Feb 22, 2017 5:35 pm
by Chris
Hi Jean-Pierre,

Ahh, I love seeing c# code, it is so clear to read...

Well, this method declaration in the c# code:

public void FromVegas(Vegas vegas)

defines the FromVegas() method with one parameter, named vegas and its type is Vegas (I know...). The equivalent VO/x# definition would be:

METHOD FromVegas(vegas AS Vegas) AS VOID

So the c# code MessageBox.Show(vegas.Version) operates on the "vegas" local (parameter), not on the "Vegas" (with capital V) type itself. In VO/x# syntax again, this would be:

MessageBox.Show(vegas:Version)

so this should compile fine in x:

METHOD FromVegas(vegas AS Vegas) AS VOID
MessageBox.Show(vegas:Version)

or I would suggest to change the parameter name to something else, so it is more clear what the code does, something like (for example):

METHOD FromVegas(oVegas AS Vegas) AS VOID
MessageBox.Show(oVegas:Version)

the reason why you get a compiler error in this code:

FUNCTION start() AS VOID
MessageBox.Show(vegas:version)

is that there is no variable named "vegas" defined in this function, so the compiler thinks that you are attempting to call a static method on the same named "Vegas" class itself. If you had defined a "LOCAL vegas AS Vegas", then it would again compile fine, but would obviously fail at runtime, because "vegas" (the var...) would be NULL.

Chris

Calling a class that has no public constructor

Posted: Wed Feb 22, 2017 5:53 pm
by jpmaertens
Thank you very much Chris !! This compiles without errors.

Calling a class that has no public constructor

Posted: Wed Feb 22, 2017 6:05 pm
by Phil Hepburn
Hi you guys,

Now you may understand why I can't count properly any more!

Or why I code like NASA folks programmer their Lunar/Mars probes ;-0)

Recently I spent a few consecutive days translating code directly from C# into X#. It does get easier - BUT - at least my C# code did not have the irritating "vegas / Vegas" sorts of confusion.

Personally I find this (too often) common style of coding 'name choice' VERY unclear, even when it is syntactically correct - or should that be semantically correct ?

Either way, onward and upward, and X# syntax for Leonardo and his mates !!!

Regards,
Phil.

P.S. I really use the single dot a lot in my CORE apps - so much easier (and possibly sloppier too).

Calling a class that has no public constructor

Posted: Thu Feb 23, 2017 7:46 am
by Frank Maraite
Hi Jean-Pierre,

from Vegas pro Scripting API

from here
http://www.vegascreativesoftware.com/de ... ds/#c24726
download link
http://www.vegascreativesoftware.com/fi ... ng_api.zip

Vegas Class
Represents the Vegas application. You can get access to this singleton object via DomainManager.VegasDomainManager.GetVegas()

HTH

Frank

Calling a class that has no public constructor

Posted: Thu Feb 23, 2017 8:47 am
by jpmaertens
Thank you Frank ! I already made a dll that can be called by Sony Vegas, and thanks to the help I got on this forum, it works (does nothing great for the moment ;-) )
Wish I had the professional version of Visual Studio, because the Community version doesn't have the option to start an external program through the debugger, and neither has Xide I think. As I am a retired programmer I can no longer deduct the costs of buying such software (650 €) from my tax bill.

Calling a class that has no public constructor

Posted: Thu Feb 23, 2017 11:12 am
by robert
Jean-Pierre,

In XIDE you can connect to an external process to start debugging your code inside another app:
- Set a breakpoint in your code
- Choose 'Attach to Process' in the Debug menu
Then the debugger should stop as soon as your breakpoint is reached.


Robert