Author Topic: C# "Hello World" example  (Read 8940 times)

Flying Peanut

  • Newbie
  • *
  • Posts: 3
C# "Hello World" example
« on: November 03, 2023, 09:20:12 AM »
Hello,

Welcome to my first post  :)

I am learning the features of voiceattack and try to simplify the features to understand how they work. I also see the "inline function" option and I am interested. I would like to start with the simplest of simple examples to write "Hello World" to the voiceattack console to have a starting point.

My "non-working" start is

Code: [Select]
using System;
 
 static void Main(string[] args)
 {
              Console.WriteLine("Hello World");
 }


Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4782
  • RTFM
Re: C# "Hello World" example
« Reply #1 on: November 03, 2023, 09:36:02 AM »
You'll want to have a look at the "VoiceAttack Plugins (for the truly mad)" section of the documentation; press F1 while VoiceAttack has focus to open VoiceAttackHelp.pdf in your default PDF viewer.

That section contains information on the proxy methods that are available (in an inline function this would be through the "VA" object, rather than "vaProxy").


However, note that learning .NET/C# is outside the scope of VoiceAttack itself.

Flying Peanut

  • Newbie
  • *
  • Posts: 3
Re: C# "Hello World" example
« Reply #2 on: November 03, 2023, 10:49:54 AM »
You'll want to have a look at the "VoiceAttack Plugins (for the truly mad)" section of the documentation; press F1 while VoiceAttack has focus to open VoiceAttackHelp.pdf in your default PDF viewer.

That section contains information on the proxy methods that are available (in an inline function this would be through the "VA" object, rather than "vaProxy").


However, note that learning .NET/C# is outside the scope of VoiceAttack itself.


I am definitely not looking for a course in C# here.  ;D
I was hoping for a simple example I could paste in just to see it work and learn further from that.

I have looked at the manual several times in trying to understand it, but that seems to be going more into plugins instead of a simple "inline" function. I will study the manual some more and # my knowledge on C#.

Thanks

Flying Peanut

  • Newbie
  • *
  • Posts: 3
Re: C# "Hello World" example
« Reply #3 on: November 03, 2023, 11:09:25 AM »
After searching more I was able to create a simple example that will write to the VoiceAttack console. Pasting this into the "inline function" field will write into the VA console.
The journey starts here  :)

Code: [Select]
using System;

public class VAInline
{
    public void main()
    {

        VA.WriteToLog("Hello World", "orange");
     
    }
}

SemlerPDX

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 291
  • Upstanding Lunatic
    • My AVCS Homepage
Re: C# "Hello World" example
« Reply #4 on: November 03, 2023, 12:21:11 PM »
Well done and congrats on taking your first steps with inline functions!

If you'd like to learn the basic concepts of C#, I would highly recommend an interactive (free) online tutorial - I very much enjoy the introductions to various languages at W3 Schools because they are a great way to get a leg up in something new before moving onto more in-depth and involved tutorial projects or more advanced learning in that language.

Check out the C# tutorials at W3 Schools here:  w3schools.com/cs/index.php

You are right that a majority of the focus in the VA Help Manual is on plugins, but programmatically, they are mostly identical but for the use of "vaProxy" in plugins, whereas in an inline function, you'd substitute simply "VA" instead.  This is how we access objects exposed to us through our inline functions (or plugins), as you have done above to write to the event log.

You can technically still use the "vaProxy" object in an inline, however, by using "VA" you can access intellisense completions as well as each of the available functions/classes/operations through the dot operator as shown below using the arrow up/down keys to scroll the list: