Skip to content
On this page

Numbers

There is no difference in terms of behavior between GreyScript and MiniScript.

Text values in MiniScript are stored as strings of Unicode characters. String literals in the code are enclosed by double quotes ("). Be sure to use ordinary straight quotes, not the fancy curly quotes some word processors insist on making.

Source: MiniScript manual

Operations

gs
// concatenation
a = "hello" + " " + "world" // concatenates all strings into one - results in "hello world"

// subtraction
a = "test" - "est" // if the first string ends in the second string, then the second string gets removed from the first string, otherwise it will just return the first string - results in "t"

// multiplication
a = "test" * 2 // repeats string x amount of times - results in "testtest"

// division
a = "test" / 2 // creates a substring by length - results in "te"

// equality
a = "test" == "foo" // returns true (1) if two strings are equal otherwise false (0) - results in false (0)

// inequality
a = "test" != "foo" // returns true (1) if two strings are inequal otherwise false (0) - results in true (1)

// greater than
a = "foo" > "test" // uses ordinal comparison - results in false (0)

// greater than or equal
a = "foo" >= "test" // uses ordinal comparison - results in false (0)

// less than
a = "foo" < "test" // uses ordinal comparison - results in true (1)

// less than or equal
a = "foo" <= "test" // uses ordinal comparison - results in true (1)

// slice
a = "foo"[1:2] // creates a substring out of the given start and end index - results in "o"

// index
a = "foo"[2] // get character at position - results in "o"

Isa

Beside of using typeof, to determine if a variable is a string, you can also use isa.

gs
myVariable = "test"

print(myVariable isa string) // prints 1

Extend type

It is possible to extend your own methods to the string type.

gs
string.capitalize = function
  return upper(self[:1]) + self[1:]
end function

print("test".capitalize) // prints "Test"