0 Members and 1 Guest are viewing this topic.
/* D I E S E L Dumb Interpretively Evaluated String Expression Language This "Dumb Interpretively Executed String Expression Language" is the kernel of a macro language you can customise by adding C code and embedding it into your program. It is short, written in portable C, and is readily integrated into any program. It is useful primarily to programs which need a very rudimentary macro expansion facility without the complexity of a full language such as Lisp or FORTH. DIESEL copies its input directly to the output until a macro character, "$" or quoted string is encountered. Quoted strings may be used to suppress evaluation of sequences of characters which would otherwise be interpreted as macros. Quote marks may be included in quoted strings by two adjacent quote marks. For example: "$(if,1,True,False)="""$(if,1,True,False)"""" Status retrieval, computation, and display are performed by DIESEL functions. The available functions are as follows. User-defined functions are not implemented; what you see is all you've got. Naturally, if you embed DIESEL in your application, you'll add functions that provide access to information and actions within your own program. DIESEL's arithmetic functions accept either floating point or integer arguments, and perform all calculations in floating point. DIESEL String Functions ----------------------- $(+,<val1>,<val2>,...<valn>) The sum of the numbers <val1>, <val2>, ...<valn> is returned. $(-,<val1>,<val2>,...<valn>) The result of subtracting the numbers <val2> through <valn> from <val1> is returned. $(*,<val1>,<val2>,...<valn>) The result of multiplying the numbers <val1>,<val2>,...<valn> is returned. $(/,<val1>,<val2>,...<valn>) The result of dividing the number <val1> by <val2>,... <valn> is returned. $(=,<val1>,<val2>) If the numbers <val1> and <val2> are equal 1 is returned, otherwise 0 is returned. $(<,<val1>,<val2>) If the number <val1> is less than <val2> 1 is returned, otherwise 0 is returned. $(>,<val1>,<val2>) If the number <val1> is greater than <val2> 1 is returned, otherwise 0 is returned. $(!=,<val1>,<val2>) If the numbers <val1> and <val2> are not equal 1 is returned, otherwise 0 is returned. $(<=,<val1>,<val2>) If the number <val1> is less than or equal to <val2> 1 is returned, otherwise 0 is returned. $(>=,<val1>,<val2>) If the number <val1> is greater than or equal to <val2> 1 is returned, otherwise 0 is returned. $(AND,<val1>,<val2>,...<valn>) The bitwise logical AND of the integers <val1> through <valn> is returned. $(EQ,<val1>,<val2>) If the strings <val1> and <val2> are identical 1 is returned, otherwise 0. $(EVAL,<str>) The string <str> is passed to the DIESEL evaluator and the result of evaluating it is returned. $(FIX,<value>) The real number <value> is truncated to an integer by discarding any fractional part. $(IF,<expr>,<dotrue>,<dofalse>) If <expr> is nonzero, <dotrue> is evaluated and returned. Otherwise, <dofalse> is evaluated and returned. Note that the branch not chosen by <expr> is not evaluated. $(INDEX,<which>,<string>) <string> is assumed to contain one or more values delimited by the macro argument separator character, comma. <which> selects one of these values to be extracted, with the first item numbered zero. $(NTH,<which>,<arg0>,<arg1>,<argN>) Evaluates and returns the argument selected by <which>. If <which> is 0, <arg0> is returned, and so on. Note the difference between $(NTH) and $(INDEX); $(NTH) returns one of a series of arguments to the function while $(INDEX) extracts a value from a comma-delimited string passed as a single argument. Arguments not selected by <which> are not evaluated. $(OR,<val1>,<val2>,...<valn>) The bitwise logical OR of the integers <val1> through <valn> is returned. $(STRFILL,<string>,<ncopies>) Returns the result of concatenating <ncopies> of <string>. $(STRLEN,<string>) Returns the length of <string> in characters. $(SUBSTR,<string>,<start>,<length>) Returns the substring of <string> starting at character <start> and extending for <length> characters. Characters in the string are numbered from 1. If <length> is omitted, the entire remaining length of the string is returned. $(UPPER,<string>) The <string> is returned converted to upper case according to the rules of the current locale. $(XOR,<val1>,<val2>,...<valn>) The bitwise logical XOR of the integers <val1> through <valn> is returned....*/
$(if,$(eq,-,$(substr,$(getvar,dwgname),$(-,$(strlen,$(getvar,dwgname)),6),1)), $(substr,$(getvar,dwgname),$(-,$(strlen,$(getvar,dwgname)),5),2), $(if,$(eq,-,$(substr,$(getvar,dwgname),$(-,$(strlen,$(getvar,dwgname)),5),1)), $(substr,$(getvar,dwgname),$(-,$(strlen,$(getvar,dwgname)),4),1), 0 ) )
$(substr,$(getvar,dwgname"),5,2)
$(substr,$(getvar,dwgname),$(-,$(strlen,$(getvar,dwgname)),5),2)