User:Dtuser1337/Sandbox

From Esolang
Jump to navigation Jump to search

Commands

All FlinnScrip Variables value starts on 0, and can be changed with the following commands :

Function Commands

For a single line programs, Semicolons is required after the end of the commands.
Adding empty brackets to commands that DOES NOT requires bracket is safe, but will generate warning message warning you to remove the brackets from the commands.

Commands Description
set(x,y); Sets the value of variable x to y, Adding strings to y will set the value of variable x to string.
add(x,y); Adds number y to variable x value, if negative number are applied to y, then it will subtract the value instead. Attempting to add a number into variable containing strings will instead return a error and is skipped instead.
multiply(x,y); Multiply variable x value by y. Attempting to multiply a value on variable containing strings will instead return a error and is skipped instead.
divide(x,y); Divide variable x value by y. Attempting to divide a value on variable containing strings will instead return a error and is skipped instead.
mod(x,y); Performs modulus on the value of variable x and value y. Attempting to perform a modulus on variable containing strings will instead return a error and is skipped instead.
swap(x,y); Swaps the variable value x with variable y.
append(x,y); Appends value y to variable x.
print(x); Prints the variable x. Assigning "" to x prints string instead.
string(x); Converts the variable value x to ASCII strings.
integer(x); Converts the variable ASCII strings x to integer value.
pause; Pauses the whole program with message "Press any key to continue..." until user presses any key.
input(x); Inputs a value to variable x.
if(x[comparative]y[logical]){}; Conditional branch statement.
ifcontain(x,[!]y[logical]){}; If variables x contains y. Adding ! before y indicates if it does not contains y.
while(x[comparative]y[logical]){}; Conditional loops.
define(x){}; Defines a Function.
call(x.y,y,z); Calls a Function. x.y denotes a function id (with y on x.y being library id), y being a parameter id, z being a value for parameter. Both y and z are optional.
push(x,stack); Pushs value x to the stack. stack argument is optional, but default to stack.top if omitted
pop(x,stack); Pops value x times from the stack. x is optional. stack argument is also optional, but default to stack.top if omitted
reverse; Reverse the whole stacks.
clearstack; Clears the whole stacks.
clear; Clears all text in console.
break; Stops while(); loops
returnend; Breaks a functions.
halt; Force halt a program.
// Comment, will ignore anything after this command.
/* */ Multiline Comment, Same as above except it will ignore anything until it reaches */.

File I/O Commands

Commands Description
require(x,y); Loads library from another FlinnScrip file, with x being a filename and y being a library id.
loadfile(x,y,z); Loads file to variable z, with x being a filename and y being amount of line skipped. If loaded to the stack, then it will pushes the file value to the stacks.
loadallfile(x,y); Loads the whole file to variable y on a incremental basis line by line, with x being a filename. If loaded to the stack, then it will pushes the file value to the stacks line by line.
writefile(x,y); Overwrite a file then writes a value y to file, with x being a filename.
appendfile(x,y,z); Appends a value z to file, with x being a filename and y being amount of line skipped.
replacefile(x,y,z); Replace a file line with value z, with x being a filename and y being amount of line skipped.

Replace Commands

These Commands should be Replaced to Function Command's x or y and cannot be used as a Function Commands. Invaild Replacement will return an error message and skips the function commands instead.

Commands Description
var(x) Variable x
random(x,y) Random Numbers with x being minimum number and y being maximum number.
nil Detect if variable has never previously used for the first time. If applied to stack array, then it will detect if there none in the stack. If applied to file(x), then it will detect if files doesn't exist.
param(x) Exclusively used by Functions statement. Attempting to use this outside the function statement will instead return a error, use var(x) instead.
stack[.top|.bottom](x) Stacks Array. x is optional: skip x times (skips stack to the bottom if stack.top, otherwise to the top if stack.bottom.)
int Integer.
str Strings.
file(x) Detect a Files, x being a filename.

Implementation Dependent Commands

Commands listed below are dependent on the Implementation and is safely ignored when ran on Implementation that does not support the following commands.

Commands Description
color(x,y); Change the console color, with x being the foreground color and y being the background color. Uses Windows Batch Color Code. (albeit with hexes replaced with integer)
fgcolor(x,y,z); Change the console foreground color by RGB value, with x being red, y being green, and z being blue.
bgcolor(x,y,z); Change the console background color by RGB value, with x being red, y being green, and z being blue.
debug; Debug Commands. Outputs all variables, stacks, functions, and parameter to the console.

Comparative and Logical Statement

Statement Description
< Comparative Less than
> Comparative More than
<= Comparative Less than or Equal to
>= Comparative More than or Equal to
= Comparative Equal to
!= Comparative Not equal to
& Logical AND
|| Logical OR

Flinnscrip MKII

The MKII Version Is a 2022 Revision of FlinnScrip that makes additional changes to the language:

Function Commands

All of the Commands from original will work in the MKII version, albiet with difference:

Commands Description
pause(x); Pauses the whole program with message "Press any key to continue..." until user presses any key. Optional Timer can be added with x seconds
elif(x[comparative]y[logical]){}; Conditional Else Statement, following after if(){};, ifcontain(){}; or elif{}; statement are required to work, otherwise it wont work. Brackets are optional.

File I/O Commands

Replace Commands

Commands Description
ifelse(a[comparative]b,x,y) Conditional branch statement. Very similar to if(){};, y is optional, but denotes else statement.

Implementation Dependent Commands

Commands Description
mkii; Denotes that this program use the FlinnScrip MKII 2022 Version, must be placed at the start of the line or else it will remain at original 2021 version regardless where this command was placed.

Comparative and Logical Statement

Statement Description
, Used in place of Comparative Statement to indicate if it contains int, str, or value in variable.
,! Same as , except if it doesn't contains int, str, or value in variable.

TEMPORARY

All FlinnScrip Variables value starts on 0, and can be changed with the following commands :

Function Commands

For a single line programs, Semicolons is required after the end of the commands.
Adding brackets to commands that DOES NOT requires bracket is safe, but will generate warning message warning you to remove the brackets from the commands.
Italic text denotes argument that is optional.
FlinnScrip MKII COMMANDS ARE MARKED IN BOLD

Commands Description
set(x,y); Sets the value of variable x to y, Adding strings to y will set the value of variable x to string.
add(x,y); Adds number y to variable x value, if negative number are applied to y, then it will subtract the value instead. Attempting to add a number into variable containing strings will instead return a error and is skipped instead.
multiply(x,y); Multiply variable x value by y. Attempting to multiply a value on variable containing strings will instead return a error and is skipped instead.
divide(x,y); Divide variable x value by y. Attempting to divide a value on variable containing strings will instead return a error and is skipped instead.
mod(x,y); Performs modulus on the value of variable x and value y. Attempting to perform a modulus on variable containing strings will instead return a error and is skipped instead.
swap(x,y); Swaps the variable value x with variable y.
append(x,y); Appends value y to variable x.
print(x); Prints the variable x. Assigning "" to x prints string instead.
string(x); Converts the variable value x to ASCII strings.
integer(x); Converts the variable ASCII strings x to integer value.
pause(x); Pauses the whole program with message "Press any key to continue..." until user presses any key. MKII Version: Optional Timer can be added with x seconds
input(x); Inputs a value to variable x.
if(x[comparative]y[logical]){}; Conditional branch statement.
ifcontain(x,[!]y[logical]){}; If variables x contains Integer or Strings. Adding ! before y indicates if it does not contains y. DEPRECATED IN MKII VERSION
else(x[comparative]y[logical]){}; MKII VERSION: Conditional Else Statement, following after if(){};, ifcontain(){}; or else{}; statement are required to work, otherwise it wont work. Brackets are optional.
while(x[comparative]y[logical]){}; Conditional loops.
define(x){}; Defines a Function.
call(x.y,y,z); Calls a Function. x.y denotes a function id (with y on x.y being library id), y being a parameter id, z being a value for parameter. Both y and z are optional.
push(x,stack); Pushs value x to the stack. stack argument is optional, but default to stack.top if omitted
pop(x,stack); Pops value x times from the stack. x is optional. stack argument is also optional, but default to stack.top if omitted
reverse; Reverse the whole stacks.
clearstack; Clears the whole stacks.
clear; Clears all text in console.
break; Stops while(); loops
returnend; Breaks a functions.
halt; Force halt a program.
// Comment, will ignore anything after this command.
/* */ Multiline Comment, Same as above except it will ignore anything until it reaches */.

File I/O Commands

Commands Description
require(x,y); Loads library from another FlinnScrip file, with x being a filename and y being a library id.
loadfile(x,y,z); Loads file to variable z, with x being a filename and y being amount of line skipped. If loaded to the stack, then it will pushes the file value to the stacks.
loadallfile(x,y); Loads the whole file to variable y on a incremental basis line by line, with x being a filename. If loaded to the stack, then it will pushes the file value to the stacks line by line.
writefile(x,y); Overwrite a file then writes a value y to file, with x being a filename.
appendfile(x,y,z); Appends a value z to file, with x being a filename and y being amount of line skipped.
replacefile(x,y,z); Replace a file line with value z, with x being a filename and y being amount of line skipped.

Replace Commands

These Commands should be Replaced to Function Command's x or y and cannot be used as a Function Commands. Invaild Replacement will return an error message and skips the function commands instead.

Commands Description
var(x) Variable x
random(x,y) Random Numbers with x being minimum number and y being maximum number.
nil Detect if variable has never previously used for the first time. If applied to stack array, then it will detect if there none in the stack
param(x) Exclusively used by Functions statement. Attempting to use this outside the function statement will instead return a error, use var(x) instead.
stack[.top|.bottom](x) Stacks Array. x is optional: skip x times (skips stack to the bottom if stack.top, otherwise to the top if stack.bottom.)
int Integer.
str Strings.
file(x) Detect a Files, x being a filename.

Implementation Dependent Commands

Commands listed below are dependent on the Implementation and is safely ignored when ran on Implementation that does not support the following commands.

Commands Description
color(x,y); Change the console color, with x being the foreground color and y being the background color. Uses Windows Batch Color Code. (albeit with hexes replaced with integer)
fgcolor(x,y,z); Change the console foreground color by RGB value, with x being red, y being green, and z being blue.
bgcolor(x,y,z); Change the console background color by RGB value, with x being red, y being green, and z being blue.
debug; Debug Commands. Outputs all variables, stacks, functions, and parameter to the console.

Comparative and Logical Statement

Statement Description
< Comparative Less than
> Comparative More than
<= Comparative Less than or Equal to
>= Comparative More than or Equal to
= Comparative Equal to
!= Comparative Not equal to
, MKII FEATURE: Used in place of Comparative Statement to indicate if it contains int or str
,! MKII FEATURE: Same as , except if it doesn't contains int or str
& Logical AND
|| Logical OR