FLoWS Basics
The syntax error will be raised before the RENAME error. Fix the syntax errors in the upper code, and try again: The RENAME runtime error should be caught, and the script returns empty GTS.
FLoWS precedence errors
Does 42°C equals to 133°F? No… It should be 107.6.
FLoWS implements a simple left to right precedence, there is no operator priority.
As you may have done in the C language in the past, the best practice is to explicit the priority with parentheses (remember MISRA C R.12.1). Moreover, the GTS type is LONG. The operations will be integer, not floating point ones: 9 divided by 8 equals 1 instead of 1.8. You must write 9.0 to force type conversion. The correct code is:
Objects
In FLoWS, there are a few primitives (number, strings, boolean) and lots of object: object types are the same as in WarpScript.
Type | Use Case |
---|---|
BITSET | Used for binary operation (decode a CAN bus frame for example) |
BOOLEAN | |
BYTES | Bytes array, raw binary data storage |
COUNTER | Atomic long. |
DOUBLE | |
GEOSHAPE | Polygon drawing on earth |
GTS | |
LIST | |
LONG | |
MACRO | |
MAP | |
MAPPER | Piece of custom Warpscript |
MATRIX | Math matrix |
NULL | |
PFONT | Font object. Linked to Pgraphics. |
PGRAPHICS | Pgraphics Image object. Could be rendered to png. |
PIMAGE | Pgraphics layer object. |
PSHAPE | Pgraphics shape object |
REDUCER | Piece of custom Warpscript |
SET | A collection of unique values |
STRING | |
VECTOR | Math vector |
VLIST | Vector, used for example to produce data bags in Pig |
The bold ones can be represented in the JSON stack output.
The other objects types cannot be serialized in JSON: it means if you try to return them at the end of your FLoWS script, you will get null
in the JSON object.
For example, run this code, and check the JSON tab output:
The PGRAPHICS objects cannot be serialized. They need to be converted into a PNG image, like in the code below. You can see the image in the image tab.
The conversion table is the same.
FLoWS make function arguments and results far more explicit than WarpScript. But as WarpLib is the same behind, some objects are mutable. For example, renaming a GTS does not change the GTS object:
In this example, g and h refer to the same object. Lots of functions in WarpLib return the input object reference. FLoWS won't bother if you ignore the return value:
Next Step
FLoWS is a WarpScript extension, so you now need to undestand the link between FLoWS and WarpScript with the next tutorial.
Explore FLoWS tutorials and blog posts on the blog
Found an issue on this page or something missing?
Tell us onThe Lounge, the Warp 10 Community Slack.