NScript

From Esolang
Jump to navigation Jump to search

NScript is a basic esoteric language designed to be at least somewhat unique. NScript has a couple nicknames by the creator: NS, NoahScript NS has plenty of flexibility and has a somewhat-main focus, which is to allow other people to easily create their own esoteric languages. It has bits and pieces stolen from python and lua such as print(). It has been worked on for a year at most now, off an on throughout that time.

How to use it

Quick note: as of now, there is NO "if" statements, no "while" loops, no "for" loops, etc

Comments

Comments are a helpful thing in languages. They are done one way in most (if not all) languages. In NS, there are 2 ways to create comments

The first (and main) one is:

##comment here

The other one is:

(comment here

A "(" works because the interpreter checks for a ")" when looking for function call, so it thinks a function is being called and therefor doesn't cause an error, so it can be used as a comment when wanted.

Due to interpreter limitations, you cant just put a comment after code. Instead, you need to do something like:

print("this is where the code goes");##comment over here, without a space after the ";"
##or, as mentioned before, a "(" can be used instead of "##".

Variables

Remember those nasty old variable name limitations? Those don't exist in NS! Variable names can be ANYTHING you want, the only limitation being no quotation marks!

##when creating a variable, the arguments are name,value.
##creating a string variable:
new string("test","test")
##or
new string(test,"test")
##creating a new number variable:
new num("test",123456)
##or
new num(test,123456)

In NS, variables are referenced very differently than in a lot of languages.

To read a variable's value, you would use "/(varname)" To write to a varible's value, you would use "\(varname)"

Currently there are no +=, +, etc. keywords for strings. There is no way to concencate strings together.

Functions/Methods

Creating functions takes a tad bit longer in NS, by a few characters.

To create a new function:

##when creating a function, the only argument is name.
new function("test")
##code here
end
##or
new function(test)
##code here
end

Arguments

As of now, you can only provide a single argument. To reference the argument variable you use /argument. To set the argument variable, you provide the argument upon calling the function like this:

functionname("argument")

Returning data

To return something, you use return to return some data like this:

new function("testDisplay")

return("test")

end

To access the data returned, you use /returned or /ret. You can run code after the "return" if wanted.

Builtin Functions/Methods

print(string data)

print() prints a string, just like in Python or Lua. Providing no argument to print() prints an empty line and produces an error.

math(variable, equation) DEPRECIATED

math() was the first way to set an int variable to an equation result. the equation can only have one symbol (-,+,>>,etc.). The equation can have bitshift operators. The variable must have a "\" before it, marking it as writing to a variable.

getin(text)

Takes user input. The only argument is text, which is the question to be printed. To access the user's input, you have to use /in.

sfunc()

Added but no code was given to sfunc().

Extra & cool code

My NS compiler/interpreter has a couple compiler functions.

io.compile(string file)

Compiles the bit of code without opening the file in the editor.

io.editfile(string file)

Switches the compiler to editing that file. During file editing, file can be compiled if wanted.

sys.bcolor(string color)

Changes the compiler window's background color to the color given.

sys.tcolor(string color)

Changes the compiler window's text color (forecolor) to the color given.