@@ -65,17 +65,7 @@ Please see [this](#examples) example with most of the simpleflow script features
6565<let statements>*
6666(<rule statements> or <emitters> or <functions> or <set>)*
6767```
68- ##### Script Instructions
69- * All ` let ` statements (declare and initialize variables) must be declared in the beginning of the script.
70- * Each statement must end with a new line and each statement can be written in single line only.
71- * ` set ` statement can be used to modify the value of variable that has been declared using let statement.
72- * All keywords should be small (case sensitive) (` let, set, message, error, output, rule, when, then, exit, end rule, partial ` )
73- * variable names and function names are not case sensitive.
74- * ` end rule ` can be used to terminate the rule scope.
75- * ` exit ` can be used to terminate the script execution.
76- * Function parameters need not be ordered as it defined. And function must prefix with $.
77-
78-
68+
7969
8070## Simpleflow Reference
8171<a name =" simpleflow-reference " ></a >
@@ -91,72 +81,86 @@ Please see [this](#examples) example with most of the simpleflow script features
91811 . [ Comment] ( #comment )
9282
9383
94- #### Variables <a name =" variables " ></a >
95- $\color{skyblue}{Syntax}$
84+ ### Variables <a name =" variables " ></a >
9685``` fsharp
9786let <variablename> = expression
9887```
9988> <small > Expressions can be used with only variable. Anywhere else you need expression then declare variable, assign expression and use it.</small >
10089
101- ** Modify value of a variable**
102- $\color{skyblue}{Syntax}$
90+ ** Modify value of a variable** <br >
10391``` csharp
10492[partial ] set < variablename > = expression
10593```
10694
107- #### Data Types
108- ** Simple Types : **
109- ###### Number
110- ```csharp
111- let x = 1
112- let y = 2 . 3
113- let z = - 442 . 33
114- ```
115- ###### String
116- ```csharp
117- let name = " test"
118- ```
119- ###### Boolean
120- ```csharp
121- let hasValue = true
122- let allow = false
123- ```
124- ###### Date
125- Use date function to declare a variable as date type .
126- ```csharp
127- let birthday = $date (y :1980 , m : 1 , d : 1 )
128- ```
129- ** Complex Types : **
130-
131- Object type can be defined using JSON format . It does not support nested object syntax , but in order to set nested object , you can set to a variable and use it .
132- ```csharp
133- let address = {city : 'ny' }
134- let member = {name : 'alex' , address : address }
135- ```
136-
137- #### Operators
138-
139- Arithmetic Operators : `+ ,- ,* ,/ ` < br >
140- Logical Operators : `and , or , not ` < br >
141- Relational Operators : `< , <= , > , >= , == , != `
142-
143- #### Expressions
95+ ### Data Types
96+
97+ < table >
98+ < tr >
99+ < th > Data Type < / th >
100+ < th > Description / Examples < / th >
101+ < / tr >
102+ < tr >
103+ < td > Number < / td >
104+ < td >
105+ < code > let x = 1 < / code >< br >
106+ < code > let y = 2 . 3 < / code >< br >
107+ < code > let z = - 442 . 33 < / code >< br >
108+ < / div >
109+ < / td >
110+ < / tr >
111+ < tr >
112+ < td > String < / td >
113+ < td >
114+ let name = " test"
115+ < / td >
116+ < / tr >
117+ < tr >
118+ < td > Boolean < / td >
119+ < td >
120+ < code > let hasValue = true < / code >< br >
121+ < code > let allow = false < / code >< br >
122+ < / td >
123+ < / tr >
124+ < tr >
125+ < td > Date < / td >
126+ < td >
127+ Use date function to declare a variable as date type . < br >
128+ < code > let birthday = $date (y :1980 , m : 1 , d : 1 )< / code >
129+ < / td >
130+ < / tr >
131+ < tr >
132+ < td > Object Type < / td >
133+ < td >
134+ Object type can be defined using JSON format . It does not support nested object syntax , but in order to set
135+ nested object , you can set to a variable and use it . < br >< br >
136+ < code > let address = {city : 'ny' } < / code >< br >
137+ < code > let member = {name : 'alex' , address : address }< / code >
138+ < / td >
139+ < / tr >
140+ < / table >
141+
142+
143+
144+ ### Operators
145+
146+ | Operator Type | Operators |
147+ | -------------- - | ---------------------- - |
148+ | Arithmetic | + ,- ,* ,/ |
149+ | Logical | and , or , not |
150+ | Relational | < , <= , > , >= , == , != |
151+
152+ ### Expressions
144153```csharp
145154let v = 2 + 3 * (3 * arg .value );
146155```
147156
148- #### Script Parameters
157+ ### Script Parameters
149158` arg ` and ` context `
150159` arg ` represents the input to the script.
151160
152- Context Properties:
153- * context.HasErrors
154- * context.HasMessages
155- * context.HasOutput
161+ ** Context Properties:** context.HasErrors, context.HasMessages context.HasOutput
156162
157-
158- #### Rule Control Flow
159- $\color{skyblue}{Syntax}$
163+ ### Rule Control Flow
160164``` csharp
161165rule when < predicate > then
162166 < statement .. 1 >
@@ -168,63 +172,118 @@ rule when <predicate> then
168172> <small > condition does not allow expression. If you need to write expression
169173 declare variable and write expression and use that variable in predicate. This does not support nested rules to avoid code complexity</small>
170174
175+ ### Emitters
171176
172- #### Emitters
177+ | Emitter Type | Syntax |
178+ | --------------| -----------------------------|
179+ | message | message <string/identifier> |
180+ | error | error <string/identifier> |
181+ | output | output <identifier > |
182+ | exit | exit |
173183
174- $\color{skyblue}{Syntax}$
175- ```
176- message <string/identifer>
177- error <string/identifer>
178- output <identifer>
179- exit /*exit will terminate the execution*/
180- ```
181-
182-
183- #### Functions
184- $\color{skyblue}{Syntax}$
184+ ### Functions
185185``` csharp
186186$< function_name > (param_name1 : value1 , param_name2 : value2 , .. .)
187187```
188- Function parameters can be written in any order. and if you omit a parameter it takes a default value of that type.
189- Function cannot be an argument to another function. Store output of a function in a variable and use it.
190-
191- ###### Date Functions
192-
193- * $\color{#4686f2}{\$ Date(y: int, m: int, d: int, [ h: int , mn: int, s: int] )}$
194- ``` csharp
195- // Examples
196- let d1 = $Date (y : 2022 , m : 7 , d :11 )
197- let d2 = $Date (m : 10 , d :25 , y : 2022 )
198- let t1 = $Date (m : 10 , d :25 , y : 2022 , h :13 , mn :30 )
199- ```
200-
201- * $\color {#4686f2 }{\$GetCurrentDate ()}$
202- * $\color {#4686f2 }{\$GetCurrentTime ()}$
203- * $\color {#4686f2 }{\$GetCurrentDateTime (timeZone : " " )}$
204-
205- Check available list of time zones here : < br >
206- Windows : https : // docs.microsoft.com/en-us/windows-hardware/manufacture/desktop/default-time-zones?view=windows-11#time-zones <br>
207- Ubuntu : https : // manpages.ubuntu.com/manpages/bionic/man3/DateTime::TimeZone::Catalog.3pm.html <br>
208-
209- ```csharp
210- let today = $GetCurrentDateTime ()
211- let todayEst = $GetCurrentDateTime ( timezone : " Eastern Standard Time" )
212- ```
213-
214- ###### String Functions
215- * $\color {#4686f2 }{\$Substring (input : string , startIndex :int , length : int )}$
216- * $\color {#4686f2 }{\$IndexOf (input : string , value :string , startIndex : int ) }$
217- * $\color {#4686f2 }{\$Length (input : string ) }$
218- * $\color {#4686f2 }{\$Contains (input : string , value :string ) }$
219- * $\color {#4686f2 }{\$StartsWith (input : string , value :string ) }$
220- * $\color {#4686f2 }{\$EndsWith (input : string , value :string ) }$
221- * $\color {#4686f2 }{\$Trim (input : string , value :string ) }$
222- * $\color {#4686f2 }{\$Match (input : string , pattern :string ) }$
223- * $\color {#4686f2 }{\$Concat (value1 : string , value2 :string , value3 :string , value4 :string , value5 :string )}$
224- ```csharp
225- let value = $Concat ( value1 : " I " , value2 : " got it" )
226- ```
227- #### Comment
188+ Function parameters can be written in any order. and if you omit a parameter it takes a default value of that type.
189+ Function cannot be an argument to another function. Store output of a function in a variable and use it.
190+
191+ <table >
192+ <tr>
193+ <th> Function </th>
194+ <th> Syntax/Examples</th>
195+ </tr>
196+ <tr>
197+ <td>Date</td>
198+ <td>
199+ <div>
200+ $\color{#4686f2}{\$Date(y: int, m: int, d: int, [h:int, mn: int, s: int])}$ <br>
201+ <code>let d1 = $Date(y: 2022, m: 7, d:11) </code><br>
202+ <code>let d2 = $Date(m: 10, d:25, y: 2022 ) </code><br>
203+ <code>let t1 = $Date(m: 10, d:25, y: 2022, h:13, mn:30 ) </code>
204+ </div>
205+ </td>
206+ </tr>
207+ <tr>
208+ <td>GetCurrentDate</td>
209+ <td>
210+ $\color{#4686f2}{\$GetCurrentDate()}$
211+ </td>
212+ </tr>
213+ <tr>
214+ <td>GetCurrentTime</td>
215+ <td>
216+ $\color{#4686f2}{\$GetCurrentTime()}$
217+ </td>
218+ </tr>
219+ <tr>
220+ <td>GetCurrentDateTime</td>
221+ <td>
222+ $\color{#4686f2}{\$GetCurrentDateTime(timeZone: "")}$ <br>
223+ <a href="https://docs.microsoft.com/en-us/windows-hardware/manufacture/desktop/default-time-zones?view=windows-11#time-zones">Windows Timezones List</a><br>
224+ <a href="https://manpages.ubuntu.com/manpages/bionic/man3/DateTime::TimeZone::Catalog.3pm.html">Ubuntu Timezones List</a><br>
225+ <code>let today = $GetCurrentDateTime() </code> <br>
226+ <code>let todayEst = $GetCurrentDateTime ( timezone: "Eastern Standard Time" )</code>
227+ </td>
228+ </tr>
229+ <tr>
230+ <td>Substring</td>
231+ <td>
232+ $\color{#4686f2}{\$Substring(input: string, startIndex:int, length: int)}$
233+ </td>
234+ </tr>
235+ <tr>
236+ <td>IndexOf</td>
237+ <td>
238+ $\color{#4686f2}{\$IndexOf(input: string, value:string, startIndex: int) }$
239+ </td>
240+ </tr>
241+ <tr>
242+ <td>Length</td>
243+ <td>
244+ $\color{#4686f2}{\$Length(input: string) }$
245+ </td>
246+ </tr>
247+ <tr>
248+ <td>Contains</td>
249+ <td>
250+ $\color{#4686f2}{\$Contains(input: string, value:string) }$
251+ </td>
252+ </tr>
253+ <tr>
254+ <td>StartsWith</td>
255+ <td>
256+ $\color{#4686f2}{\$StartsWith(input: string, value:string) }$
257+ </td>
258+ </tr>
259+ <tr>
260+ <td>EndsWith</td>
261+ <td>
262+ $\color{#4686f2}{\$EndsWith(input: string, value:string) }$
263+ </td>
264+ </tr>
265+ <tr>
266+ <td>Trim</td>
267+ <td>
268+ $\color{#4686f2}{\$Trim(input: string, value:string) }$
269+ </td>
270+ </tr>
271+ <tr>
272+ <td>Match</td>
273+ <td>
274+ $\color{#4686f2}{\$Match(input: string, pattern:string) }$
275+ </td>
276+ </tr>
277+ <tr>
278+ <td>Concat</td>
279+ <td>
280+ $\color{#4686f2}{\$Concat(value1: string, value2:string, value3:string, value4:string, value5:string)}$ <br>
281+ <code>let value = $Concat ( value1: "I ", value2: "got it" )</code>
282+ </td>
283+ </tr>
284+ </table >
285+
286+ ### Comment
228287It supports only one style of comment can be used for single or multiline using /* .. * /
229288``` csharp
230289/* Write your comment here */
@@ -238,7 +297,7 @@ It supports only one style of comment can be used for single or multiline using
2382971 . [ Extensibility] ( #extensibility )
2392981 . [ Compile Script] ( #compile-script )
240299
241- #### Simpleflow Execution
300+ ### Simpleflow Execution
242301<a name =" simpleflow-pipeline " ></a >
243302
244303![ Simpleflow Pipeline] ( http://www.plantuml.com/plantuml/proxy?cache=no&src=https://raw.githubusercontent.com/navtech-io/Simpleflow/main/SimpleflowDiagram.puml )
@@ -271,13 +330,11 @@ ISimpleflow flow = engine.Build();
271330FlowOutput result = flow .Run (script , new Member { Id = id });
272331
273332```
274- #### FlowOutput
333+ ### FlowOutput
275334
276335Emitters (` message, error, output ` ) produce output from script that will be available in FlowOutput object.
277336
278-
279-
280- #### Register Custom Functions
337+ ### Register Custom Functions
281338
282339``` csharp
283340FunctionRegister .Default
@@ -288,10 +345,7 @@ static int CalcDerivativeOfXPowN(int x, int n)
288345 return n * Math .Pow (x , n - 1 ); //
289346 }
290347```
291-
292-
293-
294- #### Extensibility
348+ ### Extensibility
295349
296350Create middleware and add it to pipeline.
297351
@@ -306,7 +360,7 @@ public class LoggingService : IFlowPipelineService
306360}
307361```
308362
309- #### Compile Script
363+ ### Compile Script
310364By adding only CompilerService to build pipeline, script can be compiled and reported if there are any errors.
311365``` csharp
312366
@@ -397,6 +451,16 @@ var userId = result.Output["userId"];
397451```
398452
399453
454+ ### Script Guidelines
455+ * All ` let ` statements (declare and initialize variables) must be declared in the beginning of the script.
456+ * Each statement must end with a new line and each statement can be written in single line only.
457+ * ` set ` statement can be used to modify the value of variable that has been declared using let statement.
458+ * All keywords should be small (case sensitive) (` let, set, message, error, output, rule, when, then, exit, end rule, partial ` )
459+ * variable names and function names are not case sensitive.
460+ * ` end rule ` can be used to terminate the rule scope.
461+ * ` exit ` can be used to terminate the script execution.
462+ * Function parameters need not be ordered as it defined. And function must prefix with $.
463+
400464
401465## Limitations
402466* Each statement can only be written in singleline. Currently It does not support multiline statement.
0 commit comments