#1 Visual Code Editor: Quick Copy and Paste of Forms
This following technique is really useful for quickly copying a selecting form and pasting it to desired point in visual code. You can utilise this, for instance, when you need to add many similars forms: Just define first one form, copy it, and paste it as many times as you need. The steps are presented in the following slide show:
- The form to be copied. e.g. an Array form in this example.
- The target location as a Form Addition Point for pasting the copied form.
- Invoke the Form Actions Bottom Sheet by performing a long press on the name or icon of the visual form component.
- Select Copy form action.
- Long press on the selected destination Form Addition Point, and
- The original form get copied to the selected as a copy form.
#2 Visual Code Editor: Quickly Show Form Info
Form info can be shown by selecting the Show form info action for the Form Actions Bottom Sheet as described in Visual Code Editor. But there is also a quicker way described below:
- Click on the form’s name (or icon) to active Form Info Bottom Sheet.
- The clicked visual form is expanded to show argument names.
- The Form Info Bottom Sheet is shown, which displays:
- Name of the form.
- Visual form component syntax
- Form description
- To close the bottom sheet, either click on the Close Button, or
- Click anywhere outside the bottom sheet.
#3 Utilise Lisp Expressions
Since visual FLX language is based on FLX List under the hood, it is possible to utilise Lisp features just a literal parsing and evaluation. You can write arbitrary FLX List literals and use those within you visual code. For instance, sometime it is easier to write a List expression for, say, a mathematical expression, than write it using the visual code.
For instance, if you need to calculate the volume of a sphere with radius r with the formula:
You could use FLX’s Arithmetic API and define the calculation as visual code. Other possibility is to use a Lisp literal (* (/ 4 3) pi (* r r r)) and String.eval function:
- The radius r defined as an immutable value (val).
- Evaluation of the Lisp expression. Note that is possible use variables and values defined with val and var functions in literal.
It is also possible to use List expressions and String.eval function to implement functions:
- Function with name “sphereVolume” which has a single parameter defined as symbol “r” and function body defined as evaluation of literal (* (/ 4 3) pi (* r r r)).
- Invocation of defined function with parameter 2.5 for radius r.
For implementing functions with List expressions, there is even more powerful function performance wise: String.compile. It parses the given literal and caches the resulting form future evaluations:
#4 Use IFTTT Web Hooks
IFTTT provides a service for makers called Webhooks. It allows makers to integrate other services on IFTTT with their DIY projects via simple web requests. FLX provides a simple API for utilising Webhooks to as a part of FLX applets. Register as a user for IFTTT, create any IFTTT service you want and hook them to your FLX applet. The API is used like as follows:
- You need the event name of your IFTTT service. In this example an IFTTT service with name “play_song” is used. The service, when triggered via webhook request, starts playing a song in a IFTTT connected Android phone.
- For authenticating the user, a key is needed. (The key in picture is a dummy key, don’t reveal and share you own key).
- Webhook requests may have optional, max. three values as a payload. The values have names “value1″, value2”, and “value3”. In the example, the service has a single value – the name of the requested song.
- A Webhook request is made using function (IFTTT.trigger event key callback value1? value2? value3?).
- A code block for defining the callback handling when the requested webhook provides response. Inside the code block. on nested code level, the response object
HttpResponseis provided as a parameter.