All Product ->
Home
Part 1 - Working With Data
1 - Hello World
2 - Booleans
3 - Numbers And Strings

Booleans in FTD

We created a simple hello world message the last exercise. We could have done this in HTML as well. Where we differ from HTML is, if you wanted to add a variable or define data, you would have to switch to JavaScript. But we can do everything in FTD itself.

Unlike JavaScript and Python and other dynamically typed languages, FTD is statically typed language. All variables in FTD have a type, which must be specified when the variable is constructed.

This is how a boolean variable is created
-- boolean foo: true
We have created a boolean variable named foo, with an initial value of true. A boolean variable can have only two values, true or false, and it must be initialised with a value.

Conditional UI
We can use the if condition on a node to conditionally show a UI node:

We get the value of a variable using $open syntax
-- ftd.text: open is true
if: $open
Only if the variable open is true only then text “open is true” would be visible.
Done
Task 1: Fix the index.ftd file
We wanted to create a link in the index.ftd file, but for some reason the link is not working, can you find the problem and fix it?
Done
Task 2: Fix the boolean.ftd
If you open /boolean/ you will see an error. This is because we have not yet defined a variable that we are trying to use. boolean.ftd is buggy! View the boolean.ftd and follow the instructions there to create a new variable.

You Are Done

You have learnt how to define a boolean variable and use to control the UI.

Move to learning about numbers and stringsor back to the workshop.

Need Help?

Please join our Discord to ask any questions related to this workshop!

Or just meet the others who are learning FTD like you :-)

ℹ️
Github Repo
The code for this workshop can be found on Github: ftd-lang/ftd-workshop.
Join The Next Session
The next remote workshop would be happening on 4th Nov 2022. Learn more here.