cyberchief Posted May 9, 2005 Report Share Posted May 9, 2005 In my macro, I am copying a 13 digit account number. I currently copy it into text format. I need to use the last 3 digits of the account number for a specific field. So, I ammend that to another variable, but I also need to modify it by incrementing it up by 1 number. So, I save it to an integer variable. My problem is that sometimes, those last 3 digits begin with a 0. I am forced to use the interger variable because I have to increment it up by 1. But when pasting the interger variable, it is dropping off the 0. Say the 3 digit is 023, I need to increment that up by 1 to 024 and I need the 0 to show. Am I doing something wrong? Is there a better way to do this? Quote Link to comment Share on other sites More sharing options...
floyd Posted May 9, 2005 Report Share Posted May 9, 2005 Leading zeros are a common problem with any language. Here is one solution using Macro Express: // Original string Variable Set String %T1% "002" // Convert to an integer Variable Modify String: Convert %T1% to integer %N1% // Add 1001 to it Variable Modify Integer: %N1% = %N1% + 1001 // Convert it back to a string Variable Modify Integer: Convert %N1% to text string %T1% // Delete the first character. Result = "003" Variable Modify String: Delete Part of %T1% <REM2:Original string><TVAR2:01:01:002><REM2:><REM2:Convert to an integer><TMVAR2:05:01:01:000:000:><REM2:><REM2:Add 1001 to it><NMVAR:01:01:1:0000001:2:0001001><REM2:><REM2:Convert it back to a string><NMVAR:05:01:0:0000001:0:0000000><REM2:><REM2:Delete the first character. Result = "003"><TMVAR2:11:01:00:001:001:> Quote Link to comment Share on other sites More sharing options...
cyberchief Posted May 9, 2005 Author Report Share Posted May 9, 2005 Awesome suggestion! Thanks Floyd!!! Quote Link to comment Share on other sites More sharing options...
Nicolas Posted May 12, 2005 Report Share Posted May 12, 2005 // Add 1001 to it Variable Modify Integer: %N1% = %N1% + 1001 nice idea ! i'll keep it in mind Quote Link to comment Share on other sites More sharing options...
floyd Posted May 13, 2005 Report Share Posted May 13, 2005 Thanks Nicolas. Good to hear from you. 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.