Diesel表达式-在分隔符后选择正确的值-
我想取选项卡后的最后一个数字 -示例I序列号,即文件名。
1.dwg |2.dwg |...|985.dwg
在本例中,审阅为 0(零)必须具有此值
当项目具有审阅 adiociono 分隔符 -
1-1.dwg此项目具有 1 个审阅。
2-5.dwg该项目有5个评论。
985-15.dwg此项目有 15 个修订版 - kkkkk 哦,
我的上帝,我试图搜索 Diesel 表达式 SPLIT 方法,但没有。
如何获取自定义字段
,我正在等待
谢谢
**** Hidden Message ***** 也许这会有所帮助。
我使用类似的表达式来解析图形名称并删除/包含破折号或其他文本。 您可能需要修改此 ..但拿走你需要的东西。
$(substr,$(getvar,dwgname),1,3)
将返回绘图名称的前三个字母。
我想这取决于您的绘图命名约定的完整图案化。在评论计数之前,您是否有固定的字符数?
这可能也会有所帮助。
http://www.crlf.de/Dokumente/Diesel/Diesel.html
也发现了这个
/* D I E S E L
Dumb Interpretively Evaluated String Expression Language
This "Dumb Interpretively Executed String Expression Language" isthe
kernelof amacrolanguageyou 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. Itisusefulprimarilytoprograms whichneed a very
rudimentary macro expansion facility without the complexity of afull
language such as Lisp or FORTH.
DIESELcopiesitsinput directlytotheoutputuntilamacro
character, "$" or quoted string is encountered.Quoted strings may be
usedtosuppress evaluationof sequences of characters which would
otherwise be interpreted as macros.Quote marks maybeincluded in
quoted strings by two adjacent quote marks.For example:
"$(if,1,True,False)="""$(if,1,True,False)""""
Statusretrieval, computation,anddisplay are performed by DIESEL
functions. The availablefunctionsareasfollows. User-defined
functionsarenotimplemented;whatyouseeisall you've got.
Naturally, ifyou embedDIESELinyourapplication,you'lladd
functionsthatprovide access to information and actions within your
own program.DIESEL's arithmeticfunctionsaccepteitherfloating
pointorinteger arguments, and perform all calculations in floating
point.
DIESEL String Functions
-----------------------
$(+,,,...)
Thesumofthenumbers , , ... is returned.
$(-,,,...)
Theresultof subtracting the numbersthroughfrom
is returned.
$(*,,,...)
The result of multiplying the numbers,,... is
returned.
$(/,,,...)
Theresult of dividing the numberby ,... is
returned.
$(=,,)
If the numbers and areequal1isreturned,
otherwise 0 is returned.
$(,)
Ifthe numberis less than1 is returned, otherwise
0 is returned.
$(>,,)
If the number isgreaterthan 1isreturned,
otherwise 0 is returned.
$(!=,,)
Ifthenumbers and are not equal 1 is returned,
otherwise 0 is returned.
$(,)
If the number isless thanorequalto 1 is
returned, otherwise 0 is returned.
$(>=,,)
Ifthenumber isgreaterthan or equal to1 is
returned, otherwise 0 is returned.
$(AND,,,...)
The bitwise logical AND of the integersthrough is
returned.
$(EQ,,)
If the stringsand areidentical1isreturned,
otherwise 0.
$(EVAL,)
Thestringis passed to the DIESEL evaluator and the result
of evaluating it is returned.
$(FIX,)
The real numberis truncated to an integerby discarding
any fractional part.
$(IF,,,)
If is nonzero, is evaluatedand returned.
Otherwise, isevaluatedand returned.Note that the
branch not chosen byis not evaluated.
$(INDEX,,)
is assumed to contain one or more values delimited by the
macro argument separator character, comma. selects one of
these values to be extracted, with the first itemnumberedzero.
$(NTH,,,,)
Evaluatesand returnstheargument selectedby. If
is 0,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 valuefroma
comma-delimited string passed as a single argument.Arguments not
selected byare not evaluated.
$(OR,,,...)
ThebitwiselogicalOR of the integersthroughis
returned.
$(STRFILL,,)
Returns the result of concatenatingof .
$(STRLEN,)
Returns the length ofin characters.
$(SUBSTR,,,)
Returnsthesubstringofstarting at character
and extending forcharacters. Characters inthestring
are numbered from 1.Ifis omitted, the entire remaining
length of the string is returned.
$(UPPER,)
The is returned converted to upper case according to the
rules of the current locale.
$(XOR,,,...)
The bitwise logical XOR of the integersthrough is
returned.
...
*/
我会建议如下,但我相信DIESEL对计算表达式有256个字符的限制,所以这不太可能奏效。
$(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
)
)
这里有一个类似的话题:
https://www.theswamp.org/index.php?topic=48081.0 您最好的选择是对文件名进行标准化。柴油不识别连字符作为分隔符,非常确定它只是CSV样式。
我会从000-00到985-15等。
015-12
将返回12
123-05
将返回05
如果您的修订符号至少始终为 2 位数字(01 到 99),则可以使用数学函数来确定位置开始
字符串 - 5((2 位数字加上“.dwg”),
因此无论您的文件名长度如何,都可以在 “.
喜欢这个。。。。
$(substr,$(getvar,dwgname),$(-,$(strlen,$(getvar,dwgname)),5),2)
无论字符数如何,它都会返回“.”之前的最后两位数字。
页:
[1]