跳转到内容

Pro Engineer/重复区域关系示例:替换参数中的字符

来自 Wikibooks,开放世界中的开放书籍

为便于阅读而简化,基于来自 http://communities.ptc.com/message/240198#240198(外部链接)的内容,如下所示。

/***************************************************************************************************
NAME = FILE_NAME
OLD = "_"
NEW = " "

/* This does three substitutions of NEW for OLD. Relations don't loop, so manual loop unrolling is required. 

if Search(NAME, OLD)!=0

NAME=extract(NAME,1,Search(NAME, OLD)-1)+NEW+extract(NAME,Search(NAME, OLD)+1,String_length(NAME)-Search(NAME, OLD))

if Search(NAME, OLD)!=0

NAME=extract(NAME,1,Search(NAME, OLD)-1)+NEW+extract(NAME,Search(NAME, OLD)+1,String_length(NAME)-Search(NAME, OLD))

if Search(NAME, OLD)!=0

NAME=extract(NAME,1,Search(NAME, OLD)-1)+NEW+extract(NAME,Search(NAME, OLD)+1,String_length(NAME)-Search(NAME, OLD))

endif
endif
endif

来自 http://communities.ptc.com/message/240198#240198(外部链接)

EXAMPLE:

/***************************************************************************************************
if Search(FILE_NAME, "_")!=0

NAME=extract(FILE_NAME,1,Search(FILE_NAME, "_")-1)+" "+extract(FILE_NAME,Search(FILE_NAME, "_")+1,
    String_length(FILE_NAME)-Search(FILE_NAME, "_"))

if Search(NAME, "_")!=0

NAME=extract(NAME,1,Search(NAME, "_")-1)+" "+extract(NAME,Search(NAME, "_")+1,String_length(NAME)-Search(NAME, "_"))

if Search(NAME, "_")!=0

NAME=extract(NAME,1,Search(NAME, "_")-1)+" "+extract(NAME,Search(NAME, "_")+1,String_length(NAME)-Search(NAME, "_"))

endif
endif
endif

/****************************************************************************************************

If value of your FILE_NAME parameter contains more than 3 "_" - add additional line that will replace "_" to " "

/****************************************************************************************************

if Search(NAME, "_")!=0

NAME=extract(NAME,1,Search(NAME, "_")-1)+" "+extract(NAME,Search(NAME, "_")+1,String_length(NAME)-Search(NAME, "_"))

endif

/*****************************************************************************************************
华夏公益教科书