There are ten libraries for general computing tasks in the 'std' module. Jump here to browse through the libraries and their functions: https://docs.tweakstreet.io/docs/modules/reference/std/#core
- core: contains utility functions to process values at a basic level
- data: contains functions for manipulation of lists and dictionaries
- strings: contains basic functions for text processing
- time: provides functions for processing datetime values
- math: contains basic mathematical functions
- fun: provides utility functions to call functions using certain patterns or conditions. Functions in this library provide functionality similar to control-flow features in other languages
- locale: provides information about available localization conventions. Localization conventions are relevant in the context of number and date formatting as well as string sorting
- regex: provides functions to work with regular expressions. Pattern syntax is that of the Java regular expression language
- bin: provides functions that operate on binary data
- decimals: contains utility functions for working with decimal numbers
And then there are various other modules available:
- tweakstreet/json: helps with encoding and decoding data from and to JSON strings
- tweakstreet/modules: provides runtime information about modules. Its primary use is to allow external modules to detect their own path
- tweakstreet/soup: helps extracting information from HTML and XML documents
- tweakstreet/spec: contains libraries useful for creating test suites involving tweakstreet flows
- tweakstreet/system: provides information about the operating system and runtime environment
- tweakstreet/xml: module helps working with XML documents
If you want to use one of these in your data or control flow or in a module you have defined, then you must explicitly import them. In the 'Import' section of the the modules, data flows or control flows properties you can specify what you want to import. See this example of a control flows properties page:
Everywhere where you can supply a value in Tweakstreet, you could also supply a function/formula instead. The 'value field' can contain a string, a number, a date or another data type. Or it can contain a formula. To change the type simply right-click the field and select "Morph To" or "Morph..." and select the type of your choice - e.g. 'formula'.
Let's define a formula now, using also the math library. If you remember your math classes then you know this formula: c = 2 * pi * r. It says that the circumference 'c' of a circle is the double of the product out of pi and the radius 'r' of the circle. Notice that pi comes from the math library that we imported before. So we can define this as a function in Tweakstreet like this:
So formulas are a great way of defining logic and reusing it. It can get much more complex than what I showed today: single line functions. But that is discussion for another blog post.
Have a look at the modules and libraries which are available and I would recommend to play around a bit to understand how to use them. The 'data' library e.g. has a lot of functions to work with lists and dictionaries - very handy. And you can define you own modules with your functionality and reuse it across multiple projects or different customers. I will write a separate post for that.
Carpe Diem