This is the package with the main functionality of EZCode
This EZCode file defines several classes (bool, float, int, str, char, var, expressions, file) and global methods. Each class is designed to handle specific data types and their associated operations, while global methods provide utility functions for the EZCode language.
Handles boolean values and operations.
-
Properties:
Value: Holds the boolean value.
-
Methods:
set : val: AssignsvaltoValue.= @bool:val: Parses and assigns a boolean value.!: Negates the current boolean value.oposite : @bool:__bol: Returns the opposite of the boolean value.is-type : val: Checks ifvalcan be parsed as a boolean.parse : val: Parsesvalas a boolean.
Handles floating-point values and operations.
-
Properties:
Value: Holds the float value.
-
Methods:
set : @float:num: AssignsnumtoValue.= @float:val: Parses and assigns a float value.+ @float:val: AddsvaltoValue.- @float:val: SubtractsvalfromValue.* @float:val: MultipliesValuebyval./ @float:val: DividesValuebyval.^ @float:val: RaisesValueto the power ofval.is-type : val: Checks ifvalcan be parsed as a float.parse : val: Parsesvalas a float.- Comparison methods (
<,>,<=,>=,!=,==): CompareValuewithvaland return a boolean.
Handles integer values and operations.
-
Properties:
Value: Holds the integer value.
-
Methods:
set : @int:num: AssignsnumtoValue.= @int:val: Parses and assigns an integer value.+ @int:val: AddsvaltoValue.- @int:val: SubtractsvalfromValue.* @int:val: MultipliesValuebyval./ @int:val: DividesValuebyval.^ @float:val: RaisesValueto the power ofval.is-type : val: Checks ifvalcan be parsed as an integer.parse : val: Parsesvalas an integer.- Comparison methods (
<,>,<=,>=,!=,==): CompareValuewithvaland return a boolean.
Handles string values and operations.
-
Properties:
Value: Holds the string value.
-
Methods:
set : text: AssignstexttoValue.= @str:text: Parses and assigns a string value.+ @str:text: ConcatenatestexttoValue.- @str:text: RemovestextfromValue.* @str:text: RepeatsValuebytext./ text: SplitsValuebytext.format : @str:text: Formatstext.parse : val: Parsesvalas a string.length: Returns the length ofValue.string-length : val: Returns the length ofval.- Comparison methods (
<,>,<=,>=,!=,==): CompareValuewithvaland return a boolean. lower : @str:text: Convertstextto lowercase.upper : @str:text: Convertstextto uppercase.replace : @str:text, @str:older, @str:newwer: Replacesolderwithnewwerintext.trim : @str:text: Trims whitespace fromtext.substring : @str:text, @int:index, @int:length: Extracts a substring fromtext.starts-with : @str:text, @str:val: Checks iftextstarts withval.ends-with : @str:text, @str:val: Checks iftextends withval.
Handles character values and operations.
-
Properties:
Value: Holds the character value.
-
Methods:
set : ch: AssignschtoValue.= @char:ch: Parses and assigns a character value.parse : val: Parsesvalas a character.!= val: ComparesValuewithvaland returns a boolean.== val: ComparesValuewithvaland returns a boolean.lower : @char:val: Convertsvalto lowercase.upper : @char:val: Convertsvalto uppercase.
Handles generic variable values and operations.
-
Properties:
Value: Holds the variable value.
-
Methods:
set : val: AssignsvaltoValue.= val: Parses and assigns a value.+ val: AddsvaltoValue.- val: SubtractsvalfromValue.* val: MultipliesValuebyval./ val: DividesValuebyval.get => @str: ReturnsValueas a string.get => @char: ReturnsValueas a char if its length is 1, otherwise throws an error.get => @bool: ReturnsValueas a boolean.get => @int: ReturnsValueas an integer.get => @float: ReturnsValueas a float.get => @var: ReturnsValueas a variable.- Comparison methods (
<,>,<=,>=,!=,==): CompareValuewithvaland return a boolean.
Handles expressions.
-
Properties:
Value: Holds the expression value.
-
Methods:
expression : vals: Parses and assigns an expression.get => @bool: Evaluates the expression and returns a boolean.get => @float: Evaluates the expression and returns a float.get => @int: Evaluates the expression and returns an integer.get => @str: Evaluates the expression and returns a string.get => @var: Evaluates the expression and returns a variable.
Handles file operations.
- Methods:
read : @str:path: Reads the file atpathand returns its content as a string.write : @str:path, @str:text: Writestextto the file atpath.create : @str:path: Creates a file atpath.delete : @str:path: Deletes the file atpath.
This class represents an array data structure and provides methods for manipulating arrays.
-
Properties:
Value: Holds the array value.
-
Methods:
get-value : @int:index: Retrieves the value at the specified index.set-value : @int:index, value: Sets the value at the specified index.append : value: Appends a value to the end of the array.prepend : value: Prepends a value to the beginning of the array.length => @int: Returns the length of the array.hashcode => @int: Calculates the hash code of the array.first: Returns the first element of the array.last: Returns the last element of the array.to-list : => @list: Converts the array to a list.get-array : _array => @array: Gets the array value.generate-array : ?@int:length => @array: Generates an array of the specified length.split : @str:_text, @str:_splitter => @array: Splits a string into an array using a specified splitter.
Basic methods
print ! @str:__text: Prints__text.run-code : @str:__code: Runs the EZCode specified by__code.clear: Clears the console or environment.input => @str: Returns console input.is-type : __val, __type => @bool: Checks if__valis of type__type.regex-match : @str:__val, @str:__match => @bool: Checks if__valmatches the regex__match.return : __val: Returns__valto the caller.
Math Methods
add obj1, obj2 => @float: Addsobj1andobj2together.subtract obj1, obj2 => @float: Subtractsobj2fromobj1.multiply obj1, obj2 => @float: Multipliesobj1andobj2.divide obj1, obj2 => @float: Dividesobj1byobj2.avg ! @float:nums => @float: Calculates the average of the numbers innums.clamp @float:val, @float:min, @float:max => @float: Clampsvalbetweenminandmax.random @float:min, @float:max => @int: Generates a random integer betweenminandmax.round-to-int @float:num => @int: Roundsnumto the nearest integer.pi => @float: Returns the value of Pi.logbase-e => @float: Returns the value of Euler's number (e).operate @str:op, ! @float:obj => @float: Performs a mathematical operation specified byoponobj.