Logical

Logical is an esoteric programming language created by user:David.werecat which doesn't do what you think it should.
== Instructions ==
All source code must be UPPERCASE, otherwise the interpreter returns an error; even though all code is interpreted in lowercase form. If the interpreter encounters a ~ character, it has a nervous breakdown. To run a program, you must type LOGICAL.EXE DELETE <FILE>, where FILE is the uppercase path of the file. By default, every line of the program is commented, and must be uncommented by using the COMET statement at the start of the line to mark the line as a comment. All variables are typed as either an integer or a string. The type of the variable is the opposite of the type of the value that you first assign to it (the value is not assigned to the variable when it is first typed). All variables names change after definition to the name of the last defined variable (or 'LOGICAL' if no variable has been defined before) with the ROT13 cipher applied to it (therefore the first variable's true name will be YBTVPNY). When a label is defined, it must be defined with a numeric shifted name. The numeric shift of a number is equal to the number's value when typed with the shift key pressed (eg. 1=!, 2=@ etc...). To call the label, the negative numeric value must be referenced (eg. a label defined as !@# will be called using the number -123). When a label is called, execution jumps to three lines before the label was defined.
For each parameter of a function, the possible values differ based on the type of parameter. If the parameter is written to, it must be a variable name. If the parameter is read from, it can either be a variable name, integer or string. Integers are specified by typing in the negative value of the integer surrounded by quotes (eg. 123 would become "-123"). Strings are specified by typing in the reverse of the string value in all uppercase, with spaces replaced by underscores (eg. "Hello, world!" would become !DLROW_,OLLEH). When functions are called with differently typed variables or variables of types not suited for the specified function, the behavior is unknown. It should also be noted that if an integer operation overflows or underflows, an error will occur.
Any errors that occur while interpreting cause the interpretation to stop and the message "ERROR: THE OPERATION COMPLETED SUCCESSFULY" to be displayed to the screen. Any errors that occur, even if unfounded, are somehow part of the specification.
In all function descriptions, any parameter enclosed in *s is a parameter that is wrote to and any parameter enclosed in &s is a parameter that is read from. Any parameter enclosed in $s is the name of a variable or label.
Function 	Description
GOTO *var* &val& 	Sets *var* to &val&
SET *var* &val1& &val2& 	Sets *var* to &val& + &val2&
ADD $name$ 	Defines a label
SUB $name$ 	Defines a variable
MUL *var* &val1& &val2& 	Sets *var* to &val1& - &val2&
DIV 	Exits the program
EXIT *var* 	Sets *var* to the character read from the console
DEFN &val& 	Writes &val& to the console
UNDF *var* &val1& &val2& 	Sets *var* to &val1& * &val2&
LABL &val1& $condition$ &val2&	Executes the next statement only if the condition is NOT met
INPT $name$ 	Jumps to a label
OUTP &id& &val& 	Opens file at path &val& and assigns to identifier &id&
CONV 	Returns from a function call
FUNC *var* &val& 	Converts integer &val& into character *val* using ASCII character codes
RETN &id& *var* 	Read a line from file &id& to *var*
DOIF *var* &val1& &val2& 	Sets *var* to &val1& / &val2&
OPEN $name$ 	Jumps to a label, allowing returning (function call)
READ &id& 	Closes file &id&
WRIT $name$ 	Undefines variable $name$
CLOS &id& &val& 	Writes a line &val& to file &id&
ERROR 	Throws an error only if no error has occured (NOP)
Possible conditions for the LABL statement include ==, <=, >=, <<, >> and !=.
== Examples ==
=== Cat Program ===
 THIS IS THE CAT PROGRAM IN LOGICAL
 COMET SUB RAVALIN
 COMET GOTO YBTVPNY "-0"
 COMET EXIT YBTVPNY
 COMET DEFN YBTVPNY
 COMET INPT -123
 COMET ADD !@#
=== Hello, World! ===
 COMET DEFN !DLROW_,OLLEH
=== Fibonacci Numbers ===
Prints the first few Fibonacci numbers.
 COMET SUB FIRST
 COMET SUB SECOND
 COMET SUB THIRD
 COMET GOTO YBTVPNY A
 COMET GOTO SVEFG A
 COMET GOTO FRPBAQ A
 COMET GOTO SVEFG "-1"
 COMET SET FRPBAQ YBTVPNY SVEFG
 COMET GOTO YBTVPNY SVEFG
 COMET GOTO SVEFG FRPBAQ
 COMET ADD !
 COMET DEFN YBTVPNY
 COMET DEFN _,
 COMET LABL FRPBAQ >> "-1000000"
 COMET INPT -1
== External resources ==
* Open Source C# Interpreter
* Visual Basic .NET interpreter and sample programs
Category:Languages
Category:2012
Category:Implemented