Recap
Recap Well Done!!!
You made it to the end. Impressive. That was ALOT of concepts and material in not a whole lot of space.
Here is the quick recap:
- BoxLang is a language which has two syntaxes.
- One is a markup language which looks very similar to HTML with attributes and values. Most of the these tags start with bx:....
- The second is a script syntax which looks similar to JavaScript and other ECMA script languages.
- To make an area that BoxLang should process, wrap that area in bx:output...</bx:output>
- To establish code that BoxLang needs to process wrap it in #s, i.e. #5+3# will evaluate to 8.
- If the code is inside a tag, you don't always need the #s as in <bx:set total=5+3>
- BoxLang is a typeless variable language which means you don't need to declare a variable type before using a variable. A variable can have an underlying value but be displayed in a more human friendly way using formatters.
- To determine what type of variable something is, there are many IsValid() functions such as IsValid("date",variable) and IsValid("Numeric",variable).
- Simple variables can include strings, numbers, booleans and dates among others.
- Complex variables include Objects (or Structs in BoxLang) and Arrays.
- The elements of a Struct are referenced by name which are called Keys.
- The elements of an Array are reference by number or "index".
- A useful command is the bx:dump tag which will display a variable visually on the screen including complex data types.
- Variables are saved in several locations called "scopes" which are a "bucket of variables" so to speak.
- One of these are the URL scope which stores variables and values which are passed in the URL of the page. This is in the format ?variable1=value1&variable2=value2..... or "GET" variables
- Another of the scopes is the FORM scope which accepts "POST" variables, usually submitted via a form on a web page.
- We can create our own functions to help organize the code and increase re-usability.
- These functions have names and we can call them and pass in arguments with the format functionName(arg1,arg2,arg3,...)
- Logic code can, and should be, placed in .bx files which can be accessed by View layer pages and other .bxs and .bx files.
- Next week we'll look at actually connecting to a database and getting some data out of it.
Take a break!