Jump to content
Macro Express Forums

Help with setting up variables.


fjslan

Recommended Posts

<_< As you can see I am a NEW member. I have been using ME for about a year now and have had some luck with trial and error. I'm trying out a new macro and I KNOW it can be simplified. here is goes...using Macro express 3.7

 

I created a macro using mouse clicks and keystrokes. I start off in excel and copy a line of info and then go to macro express to create a "shortkey" macro. A fairly simple copy and paste. In my current macro Ihave a pause set up when the time comes to put in a "shortkey" name. After I enter a name (ie. frank001)I then hit "resume" and the macro finishes.

 

Problem...I would like the macro to enter my shortkey name for me with a number 1 then go up sequentially to 2 then 3 then 4 etc. so my short key names will look like this frank001, frank002, frank 003.

 

I have set up the text box to ask how many shortkey macros i will be creating, and i have given that number to variable N1

at this point i am lost. I just don;t know enough about variables - strin - integers - etc. my presumption is that there will be a "N1+1" some where. I am also presuming that I can equate N1 = # of shortkey macros to also = the number of times the macro will reun / repeat.?.?.?

 

any help or direction will be appreciated...

 

Frank

<_<

Link to comment
Share on other sites

To increment an integer variable use the Variable Modify Integer. You can either add 1 to it or use the 'increment' option.

 

This sample macro might help you get started with what you want. It does not, however, use Variable Modify Integer to increment the counter integer variable. This is because the 'Repeat Start' command has an option to keep track of the number of times through the loop.

// Intialize variable
Variable Set Integer %N3% to 0

// Get the number of times to repeat
Variable Set Integer %N1% from Prompt
// Repeat N1 times. Keep a counter in N2.
Repeat Start (Repeat %N1% times)
 // Copy the counter to string variable T1
 Variable Modify Integer: Convert %N2% to text string %T1%
 // Pad T1 to be 3 characters in length
 Variable Modify String: Pad Left %T1%
 // Replace the leading spaces with leading 0's
 Replace " " with "0" in %T1%
 // Create T2 with 'frank' followed by a number
 Variable Set String %T2% "frank%T1%"

 // Create T2 with 'frank' followed by a number
 Text Type: %T2%<ENTER>
Repeat End

Here it is in a format that you can copy and paste into your macro:

<REM2:Intialize variable><IVAR2:03:01:0><REM2:><REM2:Get the number of times to repeat><IVAR2:01:02:FEnter the number of times to repeatFFCenter:Center><REM2:Repeat N1 times. Keep a counter in N2.><REP3:01:000001:000001:%N1%:1:02:><REM2:Copy the counter to string variable T1><NMVAR:05:02:0:0000001:0:0000000><REM2:Pad T1 to be 3 characters in length><TMVAR2:14:01:00:003:000:><REM2:Replace the leading spaces with leading 0's><TMVAR2:21:01:01:000:000: 0><REM2:Create T2 with 'frank' followed by a number><TVAR2:02:01:frank%T1%><REM2:><REM2:Create T2 with 'frank' followed by a number><TEXTTYPE:%T2%<ENTER>><ENDREP>

Link to comment
Share on other sites

Oops! frank1968 contacted me privately to ask about this line in my macro:

Variable Set Integer %N3% to 0

This line is unneeded. It is a remnant of a different sample macro. You could also do something like this:

// Intialize variable
Variable Set Integer %N3% to 0

// Get the number of times to repeat
Variable Set Integer %N1% from Prompt
Repeat Start (Repeat %N1% times)

 // Increment the counter
 Variable Modify Integer: Inc (%N3%)

 // Copy the counter to string variable T1
 Variable Modify Integer: Convert %N3% to text string %T1%
 // Pad T1 to be 3 characters in length
 Variable Modify String: Pad Left %T1%
 // Replace the leading spaces with leading 0's
 Replace " " with "0" in %T1%
 // Create T2 with 'frank' followed by a number
 Variable Set String %T2% "frank%T1%"

 // Create T2 with 'frank' followed by a number
 Text Type: %T2%<ENTER>
Repeat End

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