dlegate Posted June 10, 2008 Report Share Posted June 10, 2008 Here's what I'm trying to do: in a loop I want to increment a number by 1, starting with 1, but I'd like it to output with leading zeros. For the first nine numbers, I'd want: 0000000001 0000000002 0000000003 etc. with 9 leading zeros Once it trips 10, I'd want 8 leading zeros: 0000000010 0000000011 and 100: 0000000100 0000000101 and so on. How can I do this in ME3? Any help is greatly appreciated. Dan Quote Link to comment Share on other sites More sharing options...
alexlimbert Posted June 10, 2008 Report Share Posted June 10, 2008 I think using Excel might be quicker. Just use A1=1, A2=A1+1, A3=A2+1 and copy the formula all the way down the page in column A. Next, highlight the entire column, click Ctrl+1, click the number tab, click custom in the Category section and type 10 zeros in the "Type" box, then copy column A where you need it. Using ME, the only way I coul think of is copying a formula like "if counting integer greater than 0 and less than 10, add 9 zeros in front of the counting integer, next if counting integer greater than 9 and less than 100, add 8 zeros in front of the counting integer, next if number greater than 99 and less than 1000, add seven numbers in front of the counting integer, and so on.... Alex Quote Link to comment Share on other sites More sharing options...
rberq Posted June 10, 2008 Report Share Posted June 10, 2008 I haven't written the code, but something like this should work: Variable Set Integer N1 = 0 REPEAT UNTIL N1 greater than x (x is however many numbers you want to output) Variable Modify Integer N1 (add 1 to N1) Variable Modify Integer | Convert Text to String (N1 into string T1) Variable Modify String | Pad Left T1 width of 9 (pads T1 with leading spaces, total length of resulting string will be 9 characters) Variable Modify String | Replace Substring in T1, replace all instances of space with zero Output string wherever you want it to go REPEAT END Quote Link to comment Share on other sites More sharing options...
alexlimbert Posted June 10, 2008 Report Share Posted June 10, 2008 That's a good one. Quote Link to comment Share on other sites More sharing options...
dlegate Posted June 11, 2008 Author Report Share Posted June 11, 2008 rberq's suggestion works great!!! Thanks!! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.