Jump To...

RETURN HOME
0. Header
0.1. Explanation
1. Syntax
2. Commands
2.1. Variable Declaration (var)
2.2. Print
2.2.1. Functional Print (printf)
2.3. Delete Variable (del)
2.4. List all Variables (variables)
2.5. String/Lit/Str
2.6. Assign Numbers (int/float)
2.7. Assign Booleans (true/false)
2.8. With
2.9. Concat
2.10. Scope
3. Functions
3.1. Defining Functions
3.2. Calling Functions (call)
3.3. Returning Values
4. Modules
4.1. GitHub
4.1.1. Repository (rep)
4.1.2. Page
4.2. WEB
4.2.1. Open
5. Escaping Characters
5.1. Regular Escaping
5.2. Exact Escaping

Simple Query Official Documentation


This is the official documentation of Simple Query (SQ). You may use the Navigation on the right side of the screen to quickly find the section you would like to read about.

Explanation

In this documentation you can find styled text. Here is a quick overview of what is what:
I'm a block of code!
I'm a multiline
block of code!
I'm an explaining block of code!
I'm an output of a block of code!

Example in python: print("Hello World!")
We will print hello world to the screen.
Hello World!
Command Syntax: command parameter label another_parameter



Syntax


The syntax of the language is very simple, you simply write a command name, followed by parameters separated by spaces.
Example from python:
Python Script:
a = "Hello, World!"  Create variable a and assign the value "Hello, World!" to it.
print(a)  Print variable a to console.
Hello, World!

SQ Script:
var a := Hello, World!  Create variable a and assign the value "Hello, World!" to it.
print {a}  Print variable a to console.
Hello, World!

When creating .sq files that you can run using the interpreter keep in mind some extra syntax operands:
var hello = string Hello, World!; print {hello}   You can separate commands using semicolons!
Hello, World!

var hi = \   You can continue the command in the next line when you use a backslash as the final character!
string Hello!
print {hi}
Hello!



Commands


Commands in simple query can contain parameters or follow a specific syntax. If you fail to follow it or a different error occurs, you'll get a message printed. No error can cause the console to crash.
In SQ, spaces are essential, so omiting them will cause the command to not work.



Variable Declaration (var)

Syntax 1: var variable_name = Command with return value
Syntax 2: var variable_name := Literal Value
Function: Declares a variable and saves it to the temporary memory. You can even save an entire command to it.
Using variables: To use a variable, simply surround the variable name with curly brackets.
Example: var i = string Hello,   Regular value assignment
var j := World!   Literal value assignment
print i
i
print {i} {j}
Hello, World!



Print

Syntax: print value
Function: Prints a literal value to the console. Replaces escaped characters with their real values in the output.


Functional Print (printf)

Syntax: printf Command with return value
Function: Prints a return value to the console. Replaces escaped characters with their real values in the output.
Example: print scope
scope   The literal value "scope" is printed.
printf scope
GLOBAL__   The return of the scope command is printed.



Delete Variable (del)

Syntax: del variable
Function: Deletes a previously declared variable.



List all Variables (variables)

Syntax: variables
Function: Returns the list of all variables with their raw (unescaped) values.



String/Lit/Str

Syntax 1: string String/Literal to return
Syntax 2: lit String/Literal to return
Syntax 3: str String/Literal to return
Function: Returns a String or Literal.
This is an alternative to using := in variable declaration.



Assign Numbers (int/float)

Syntax 1: int Integer to return
Syntax 2: float Floating Point to return
Function: Returns a Number - an Integer or Floating Point depending on which command was used.



Assign Booleans (true/false)

Syntax 1: true
Syntax 2: false
Function: Returns a Boolean value (true or false).



With

Syntax: with paramter command
Function: Passes an optional parameter (literal string) to command.
Example: var i = with , concat str Hello & str \sWorld!
print {i}
Hello, World!



Concat

Syntax: concat command1 & command2
Function: Concatenates results of two commands.
Return: Concatenated result separated by optional separator parameter.
Optional Parameter: Separator parameter can be passed using the with command.



Scope

Syntax 1: scope
Syntax 2: scope local/global
Syntax 3: scope fn/custom function_name/custom_scope_key
Function 1: Returns the current scope.
Function 2: Sets the scope to either global or local.
Function 3: Sets the scope to either a previously defined function's scope or to a custom scope key.
Note: Calling a function resets the scope. This means that calling any function resets the scope back to global.

Scopes in SQ:
- Global = All variables declared outside of functions and custom scopes.
- Local = Variables declared in the current function.
- Function Specific = Variables declared in a previously defined and called function.
- Custom Key = Variables declared in custom key scopes can only be accessed when you explicitly set the current scope to said key.

Examples: scope global   Use this is functions to access global variables. Keep in mind, that any variable declared after setting the scope to global will also be global.
scope local   Using this in function returns the scope back to default (this function's scope). Using this outside of a function does nothing.
scope fn task   After doing this, assuming the function exists and has been previously called, we are able to access its variables.
scope custom hello   We've entered a custom key scope. Variables from any other scope are now inaccessible, if we declare any variables in this scope, they can only be accessed in this scope and not from outside. Do not use this if you are unsure what this might cause.



Functions


In interpeted code, you are able to define your own function that you can later call. This also gives you the possibility to return any value for variables to save or call a complicated function many times without having to rewrite the code every time.



Defining Functions

To define a function, use the fn statement. Keep in mind, that by doing this you are also opening a code block.
To close a code block, simply add a dot on an empty line / after a semicolon.
Example of a function definition: fn sayHello
   var a = str Hello,
   var b = str World!
   return str lol   Returns do not cause the function to stop executing.
   print {a} {b}
.
Keep in mind, indentation is completely optional and it's up to you if you want to use it or not.
The last two lines (the print command and the dot) can be rewritten like this and still properly close the function code block: print {a} {b}; .

Variables declared in functions are local, however you can access them outside of the function after it has been called at least once like this: fn hi
   var bl = str text
.

call hi   Make sure to call the function first.
scope fn hi   Setting the scope to function hi.
print {bl}   In our current scope, this variable exists.
text



Calling Functions (call)

You can call functions using the call command.
Syntax: call function_name
Return: None or function's return.
Example: We have defined the sayHello function.

call sayHello
Hello, World!

var x = call sayHello
Hello, World!   Function still executes.
print {x}
lol   We returned a literal string.



Returning Values

You can return values from a function using the return statement.
Syntax: return Command with return value
Examples: var a := Hello!
return lit {a}   We return the literal value of variable a.

return call b   We return function b's return.

return true   We return a boolean value.



Modules


You use modules are regular commands, with doubled depth: syntax in doubled depth is module command parameters
You can write the module's name alone as a command to see some quick help and description of said module, including its commands and their syntax.



GitHub

This is a simple module to help you access GitHub from SQ.

Commands:

Repository (rep)
Syntax: github rep USER REPOSITORY
Function: Opens USER's REPOSITORY in the default browser.
Return: Link to USER's REPOSITORY.


Page
Syntax: github page USER
Function: Opens USER's GitHub Pages page in the default browser.
Return: Link to USER's GitHub Pages page.



WEB

This is a simple module to open URLs straight from SQ.

Commands:

Open
Syntax: web open URL
Function: Opens URL in the default browser.



Escaping Characters


Escaping characters is very important in programming, and so is in SQ. There are characters that you cannot type, or characters that might have a special meaning. For this reason, there are many escaped characters that you can use.



Regular Escaping

Regular escaping is a type of escaping consisting of a backslash and a single escaped characters (\n)
Here is a list of all regular escaped charcters: \n New Line
\s Space (This exists because space is used to separate parameters in commands - typing multiple spaces in a string results to only one being saved, however, you can add \s to add as many spaces as you want.)
\t Tab
\0 Null Character
\l Left Curly Bracket ({)
\r Right Curly Bracket (})
\b Backslash (\)



Exact Escaping

Exact escaping is a type of escaping consisting of a backslash and a character pointer (\$sc.)
Syntax: \$CHARACTERCODE.
Here is a list of all charcter codes: sc Semicolon ;
et Ampersand &

Example: var a := Hello,\sWorld!
print Variable \la\r stores this value:\n{a}\n--endprogram\$sc.

Variable {a} stores this value:
Hello, World!
--endprogram;