Skip to main content

  | मौसम…

411 समाचार
Public archive edition · Attributed source reporting with original dates · AI drafts are excluded

411 REFERENCE · Wikibooks

Pro Engineer/Repeat Region Relation Example: Replacing characters in parameters

Reference material by Wikibooks contributors. This retains its source identity and is not 411 news reporting.

see ../Relation Operators and Functions for Strings/ for syntax on extract() and search() Simplified for readability, base on from http://communities.ptc.com/message/240198#240198 (external link), which follows this. /*************************************************************************************************** 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 from http://communities.ptc.com/message/240198#240198 (external link) 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 /*****************************************************************************************************