Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

TCL string operations

Status
Not open for further replies.

i0wa

Industrial
Oct 4, 2009
51
0
0
EE
Is it possible to make the postprocessor to analyze the symbols in string and change them if needed? For example:
source string: "THIS_IS_AN_EXAMPLE"
produced string: "THIS IS AN EXAMPLE"
As you see, the underscore is changed to space.

BTW. How to output in the end of the program the very first tool which was used there in the program? MOM_first_tool puts only the last operation's tool.

 
Replies continue below

Recommended for you

Text string is the variable of the string you are trying to change and the last is the name of the string var that you want to put the changed string in. In this example it is the same var. That should work.

regsub -all {_} $text_string " " text_string
 
Hi
To get 1st tool at the end I would do something like this
In MOM_start_of_program
global i0wa_first_tool_change

set i0wa_first_tool_change 0

In MOM_first_tool
global i0wa_first_tool_change
global i0wa_first_tool
global mom_tool_number

if {i0wa_first_tool_change == 0} {
set i0wa_first_tool $mom_tool_number
set i0wa_first_tool_change 1
}

You could also use mom_tool_name
Then just declare and output i0wa_first_tool where required.
Be careful that any custom variables are unique. I add AED_ in front of all my variables to ensure they are.
Hope That Helps

Cheers
Steve Griffiths :)

If you want to make apple pie from scratch, first you must create the universe!
 
I just checked and it worked on my post. I just put a tool change block in the end of program that has the T defined as next tool and it will see the next as the first in the program.
 
MOM_first_tool is a process not a variable.
Question to <b>shags72</b>:
Your solution works perfect, thank You very much!
But could You also say what code of symbol "-" (minus) because if I try to change underscore to minus then I get an error in
regsub -all {_} $text_string " " text_string bla-bla-bla, that "-" is used incorrectly.

BTW (as always, offtop) it seems that there is no problem to get the machining time in the end of the program, but what about getting the machining time in the very beginning? is it possible?

PS I am very sorry for my bad English.
 
Put a \ in front of the _ like this \_. \ is an escape character. To put times at the start of output you must write them to another file and then close your output file and rewrite to a temp file, first writing your times to it and then your output to it. Then you close both and delete your original output file and rename your temp to your original name. There are examples of this in the gtac forum. If you have a license for NX you can use your sold to id to get a login at this site and then gtac site is next link.


 
To create temp file, then final is the common way. There is custom command like "initialize tool list" used for tool list generation in before than any tool is used - another words in the program start. what about this?
 
Sorry, it's impossible to get machine time as I suggested.. I read comments and.. temp file then re-posting again is the only possible way.
 
I think if you just open your temp file for writing at the end and then write your output to it, then delete original output and rename your time file to output name that this will work.
 
Status
Not open for further replies.
Back
Top