Last night I decided I was finally motivated enough to jump into ASH scripting. The language itself is pretty simply, but the size of the API is a bit intimidating.
Looking through the syntax, most of the constructs are very similar to C/C++/Java/C#. I realized that if I could write code in the subset of ASH and C# that overlap, I could have Intellisense autocomplete and documentation in Microsoft Visual Studio (I spend 8 hours a day working in Visual Studio, so it's my native environment).
I went through the Wiki, copy/pasted all the functions, transformed them into static methods (and class methods, if the method takes a first parameter of the right type), and formatted the descriptions into XML comments. It uses features added in the latest version of C# (specifically "using static" to bring static methods into global scope in a file), so it won't work with Visual Studio older than 2015.
If I'm writing code from scratch, it lets me get auto-completion, auto-documentation, auto-formatting, syntax highlighting, and name checking. I tried importing an existing script into a C# file, but there are enough things that you can do in ASH that are completely invalid C# that it's not at all useful for most existing scripts. But maybe someone else who wants to start learning will find this useful in the future. If not, at least it's useful to me.
Here's the issues I ran into:
* Record type "class" (as in character class) is a reserved keyword in C#. It has to be escaped in C# as @class, which is incompatible. But it doesn't appear to be used much.
* The maps correlate to dictionaries in C#, but the syntax is very different. Simple integer indexed arrays are ALMOST identical. [EDIT: I figured out how to represent map syntax using generics of each class. However, anything where the value is int or string has to be escaped @int or @string]
* for loop is completely different. [Edit - I was reading other posts, and it looks like C style for loops are now supported in ASH, but I guess the Wiki hasn't been updated.]
* foreach loop is almost identical, but ASH doesn't put parentheses around the looping construct.
* Comments start with # vs. //
* ASH seems to allow a bunch of functionality that doesn't translate into C# at all, like unquoted strings.
A few places I didn't know what a parameter meant, I just called it xx,yy,zz, etc.
Instructions: unzip the project, open it in Visual Studio, copy the file "StandardHeaders.cs" as a template, and start writing your code inside "class ScriptTemplate". When you're done, you'll need to translate any C#isms to valid ASH syntax. Maybe I'll get around to writing a small utility to do so later.
Looking through the syntax, most of the constructs are very similar to C/C++/Java/C#. I realized that if I could write code in the subset of ASH and C# that overlap, I could have Intellisense autocomplete and documentation in Microsoft Visual Studio (I spend 8 hours a day working in Visual Studio, so it's my native environment).
I went through the Wiki, copy/pasted all the functions, transformed them into static methods (and class methods, if the method takes a first parameter of the right type), and formatted the descriptions into XML comments. It uses features added in the latest version of C# (specifically "using static" to bring static methods into global scope in a file), so it won't work with Visual Studio older than 2015.
If I'm writing code from scratch, it lets me get auto-completion, auto-documentation, auto-formatting, syntax highlighting, and name checking. I tried importing an existing script into a C# file, but there are enough things that you can do in ASH that are completely invalid C# that it's not at all useful for most existing scripts. But maybe someone else who wants to start learning will find this useful in the future. If not, at least it's useful to me.
Here's the issues I ran into:
* Record type "class" (as in character class) is a reserved keyword in C#. It has to be escaped in C# as @class, which is incompatible. But it doesn't appear to be used much.
* The maps correlate to dictionaries in C#, but the syntax is very different. Simple integer indexed arrays are ALMOST identical. [EDIT: I figured out how to represent map syntax using generics of each class. However, anything where the value is int or string has to be escaped @int or @string]
* for loop is completely different. [Edit - I was reading other posts, and it looks like C style for loops are now supported in ASH, but I guess the Wiki hasn't been updated.]
* foreach loop is almost identical, but ASH doesn't put parentheses around the looping construct.
* Comments start with # vs. //
* ASH seems to allow a bunch of functionality that doesn't translate into C# at all, like unquoted strings.
A few places I didn't know what a parameter meant, I just called it xx,yy,zz, etc.
Instructions: unzip the project, open it in Visual Studio, copy the file "StandardHeaders.cs" as a template, and start writing your code inside "class ScriptTemplate". When you're done, you'll need to translate any C#isms to valid ASH syntax. Maybe I'll get around to writing a small utility to do so later.
Attachments
Last edited: