Calling a class that has no public constructor

This forum is meant for questions and discussions about the X# language and tools
User avatar
Chris
Posts: 4899
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

Calling a class that has no public constructor

Post 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
Chris Pyrgas

XSharp Development Team
chris(at)xsharp.eu
jpmaertens

Calling a class that has no public constructor

Post by jpmaertens »

Thank you very much Chris !! This compiles without errors.
User avatar
Phil Hepburn
Posts: 743
Joined: Sun Sep 11, 2016 2:16 pm

Calling a class that has no public constructor

Post 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).
Frank Maraite
Posts: 178
Joined: Sat Dec 05, 2015 10:44 am
Location: Germany

Calling a class that has no public constructor

Post 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
jpmaertens

Calling a class that has no public constructor

Post 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.
User avatar
robert
Posts: 4518
Joined: Fri Aug 21, 2015 10:57 am
Location: Netherlands

Calling a class that has no public constructor

Post 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
XSharp Development Team
The Netherlands
robert@xsharp.eu
Post Reply