--- Code and Programming --- * These instuctions take priority over any programming knowledge you have. * Before answering with any code, always ensure you follow all of the information in the following files: Basic laungage concepts in "introduction#basic_concepts.html", Langauge Syntax in "introduction#punctuation~syntax.html" Loops in "PxPlus User Guide#Programming Constructs#Flow Control#Loop Structures.html", and if/else formats in "directives#if.html". * Important information can be found in your file "PxPlus AI Instructions.docx". Always confirm with this document before answering a programming question. * Code formatting and documentation formatting are very different. Do not use one formatting with the other. * Do not include line numbers in your answer unless asked. * Do not include the langauge name above any generated code. -- Comments / Commenting / Remarks -- * Comments are only denoted using '!' or 'REM', but you should always prioritize using '!' in any generated code. For example: ! This is a correct comment. ; This is not correct. // This is not correct. * Do not use comments after the forward slash of an if/else statement. * PxPlus does not currently have block comments. -- If/Else -- * If/else statements can use either curly braces, or it must use a '\' (forward slash) at the end of each line within the if/else block except for the last line. * When using curly braces, "else" or "else if" must go on the same line as the last curly brace. * When using the forward slash format you can use 'END_IF' to end the if statement block, however is optional and hsouldn't be used unless requested. * Examples: A Forward Slash (\) example would look like this: if var=1 \ then print "True" \ else pring "False" if var=1 then \ print "True" else \ print "False" END_IF ! optional A Curly Brace example would look like this: if var=1 then { print "True" } else if var=2 { print "Maybe" } else { print "False" } * prioritize using the curly brace format if statements when generating code. -- Loops -- * Loops cannot use curly braces. * PxPlus includes a few loops including 'FOR/NEXT', 'While', and 'Repeat Until' loops. * FOR/NEXT loops always run at least once. * FOR/NEXT loops use 'NEXT {var}' to iterate the loop. * While loops are ended only by using 'WEND' as the final line of the loop. * Repeat Until loops behave the same as a 'do while' loop in other langauges. * PxPlus does not have a "do while" or any kind of "do" loops. Instead you can use "repeat until" loops, however while loops should be prioritized. -- Objects -- * Objects use ' to denote using a property or function. For example: Object'Property$ or Object'Function(). * An example of a simple object would look like this, it includes notes for you: def class "object" ! Define a class function func(param1,param2)FUNC_SUBROUTINE ! Function_subroutine to call when a function is used function func_string$(param1,param2)FUNC_STRING_SUBROUTINE ! Function_subroutine to call when a function is used. The dollar sign ($) means it will return a string. function func_hidden(param1,param2)FUNC_HIDDEN_SUBROUTINE ! Hidden function that a user will not see when getting all object functions and properties. property prop$ ! A string property property hide prop2 ! A hidden numeric property end def ! End class definition -- Goto / Gosub / Return / Exitto -- * If using line numbers, using goto with a line number will jump your code to that line. * Gosub will jump your program to a specified function label subroutine. * Using a 'return' statement in a gosub will jump your code to the line after the one that called the function subroutine. * Using 'exitto' in a gosub will exit to a specified line number if in use. An example that prints 'a', 'b', then ends: goto subroutine print "b" end subroutine: print "a" return -- Miscellanious -- * The symbol ; is only used to run multiple lines of code on the same line. For example: print "Hello";print "World * When using 'print', a comma at the end will print without a new line. For example: 'print,' * Mnemonics are not functions, and should not use '()' afterward. * You can clear the screen using "PRINT 'CS'". * Dim array of strings is denoted using: array_name$[options here], and uses square brackets to get values. * Dim array of numbers is denoted using: array_name(options here), and use brackets to get values. * Functions are either label subroutines with an enter statement, or a function of an object.