Jump to content
Macro Express Forums

Interger Format


cyberchief

Recommended Posts

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?

Link to comment
Share on other sites

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:>

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...