1 //-------------------------------------------------------------------------
3 // This file contains definitions of DataFlex 3.2 Console Mode macro functions
4 // to provide some extended command functionality.
6 // This file is to be included in df32func.mk
8 // Copyright (c) 2006-2009, glyn@8kb.co.uk
11 //-------------------------------------------------------------------------
13 //-------------------------------------------------------------------------
15 //-------------------------------------------------------------------------
19 // ASSERT <true/false evaluation> <assert message> -- provides a similar functionality to c assert.
21 // if enable_dfassert is defined then evaluations are run and errors are raised
22 // if enable_dfassert is undefined then assertions are effectively removed at compile time
24 // A failed assertion will raise an error
28 // Define enable_dfassert
29 // ASSERT (1=2) "TEST ASSERT"
32 #IFDEF enable_dfassert
36 error 999999 ("RAISED ASSERTION: '"+string(!2)+"'")
44 // Used to produce multiline error messages as the error command is
45 // limited to 40 chars (the original length of ERROR_DESCR in FLEXERRS.DAT)
47 // Will replace "??" in any message with a variable
51 // custom_error <error_code> <error_message>
52 // custom_error <error_code> <error_message> <error_message replacement>
53 // custom_error <error_code> <error_message> <error_detail> <error_detail replacement>
55 #COMMAND CUSTOM_ERROR R
63 error !1 (replace("??", !2, string(!3)))
68 error !1 ("Detail: "+(replace("??", !3, string(!4))))
78 // Ternary command (an operator would be nice)
79 // Behaves similar to perl/c ternary operators E.g. "(evaluation) ? true_var : false_var"
83 // ternary mytable.myboolean "YES" "NO" my_string
84 // ternary (1=1) "YES" "NO" my_string
86 // Note that this command form functions just like perl/c and if something like:
87 // "(evaluation) ? true_evaluation : false_evaluation" is written then only the
88 // secondary OR tertiary evaluation will execute dependant on the result of
89 // the primary evaluation.
91 // There is also a "ternary" function (math.inc) which can be used in place of an operator,
92 // however beware that the function works differently; both the secondary AND tertiary
93 // evaluations happen before primary evaluation is tested, rather than being exclusive
94 // (as they should really be) this is a limitation of passing via the function. Thus
95 // the function is only really useful for variables.
100 if (!1 = 1) move !2 to !4
104 if ((lowercase(!1) eq 't') or (lowercase(!1) eq 'true')) move !2 to !4