11-20-2015 07:17 AM - edited 11-20-2015 07:25 AM
Good Afternoon guys,
I am new to PB and TCL so without having to write loads of logic is there a quick way to format a numer to AT LEAST 4 whole number places?
So, 41.87654 would become 0041
23768.009 would become 23768
etc etc
Thanks in advance.
Craig.
11-20-2015 07:32 AM
Would like to add that I know I can get rid of the trailing values with
format %.0f
This part is good!
I could also take it to 4 integer places with
format %4.0f
but this is no good for integers with only 3 places as it does not apply the preceeding zeros.
It would also shorten 5 place numbers??
11-20-2015 08:30 AM - edited 11-20-2015 08:33 AM
Ive just done it like this -
if {$newval < 100} {
set newval "00$newval"
}
if {$newval < 1000 && $newval >99} {
set newval "0$newval"
}
Couldnt wait!
11-20-2015 09:26 AM
perhaps...
set newvalue [format %04d [expr int($old_value * 1000)]]
In any case - note that tcl treats numbers that start with "0" as octal numbers, so be careful if you do something more than just MOM_output_text or MOM_output_literal with "newvalue"
Ken
Production: NX10.0.3.5 MP16/TC11.2
I'd rather be e-steamed than e-diseaseled
11-20-2015 10:13 AM
Thanks Ken,
Yeah, they are all output literals.
It is for jumping lines in an Okuma program based on which machine in teh cell is running the program.
GOTO on Okuma looks for your specified marker from the program start. We had problems with programs jumping backwards based on logic.
I am taking the sequence numbers and adding sequence increment calculations to make sure the jump goes forwards.
The code ultimately looks like this -
N0070 G15 H200
N0075 TPOT=VTLCN
N0080 IF[VC199 EQ 154668]N0090
N0085 IF[VC199 EQ 154667]N0100
N0090 G149 E=VC2-90 (TURNCUT MODE ON MC1)
N0095 GOTO N0105
N0100 G149 E=VC2-90 (TURNCUT MODE ON MC2)
N0105 G00 X0.000 Y0.000
Thanks again for your help!
11-20-2015 11:14 AM
If you specify a new block for the goto using the sequence number word you will not have to do any Tcl magic.
The block would be something like this:
Text[GOTO] N[$my_jump_destination]
Production: NX10.0.3, VERICUT 8.2, FBM, MRL 3.1.7 | TcUA 10.1 MP7 Patch 0 (10.1.7.0) | TcVis 11.4
Development: C (ITK), .NET, Tcl/Tk Testing: NX12.0 | AWC 3.4 Preparing: NX12.0
Employees of the customers, together we are strong
How to Get the Most from Your Signature in the Community
NX Customization - Best Practice Guide