cancel
Showing results for 
Search instead for 
Did you mean: 
feickholt
Level 10

Formated output using rules?

Jump to solution

Is there any way to format the output in loglines or something else like fprint?

We have to convert numbers in a fixed length format. (5 should be be 00005 and 10 has to be 00010). Any ideas?

We use Mwg 7.2?

Thanks

Frank

0 Kudos
1 Solution

Accepted Solutions
eelsasser
Level 15

Re: Formated output using rules?

Jump to solution

Here's a trick that should do what you want.

' This is whatever number you are starting with

Set User-Defined.value = 123

' The prepends a bunch of zeros to the beging of a the string "000000123"

Set User-Defined.strValue = "000000"
+ Number.ToString (User-Defined.value)

' This pulls the last 6 digits off the end of the string "000123"
Set User-Defined.strValue = String.ReplaceFirstMatch (User-Defined.strValue, (\d{6})$, "\1")

Message was edited by: eelsasser on 6/14/13 9:09:28 AM EDT
0 Kudos
3 Replies
eelsasser
Level 15

Re: Formated output using rules?

Jump to solution

Here's a trick that should do what you want.

' This is whatever number you are starting with

Set User-Defined.value = 123

' The prepends a bunch of zeros to the beging of a the string "000000123"

Set User-Defined.strValue = "000000"
+ Number.ToString (User-Defined.value)

' This pulls the last 6 digits off the end of the string "000123"
Set User-Defined.strValue = String.ReplaceFirstMatch (User-Defined.strValue, (\d{6})$, "\1")

Message was edited by: eelsasser on 6/14/13 9:09:28 AM EDT
0 Kudos
feickholt
Level 10

Re: Formated output using rules?

Jump to solution

Cool! perfekt. Thanks!

0 Kudos
eelsasser
Level 15

Re: Formated output using rules?

Jump to solution

It's pretty old school, but i'm old.

Just don't ask me how to put localized digit-grouping symbols into the number every 3 digits, and log negative values in the color red 

0 Kudos