Jump to content
Macro Express Forums

Incrementing "t" Variables


marteb

Recommended Posts

Hello,

 

I have been using ME for 1 1/2 years and just love it. We are in the middle of a system/software conversion and ME has saved us considerable time and money. My macros have evolved and have become leaner and more efficent.

 

I would like to know if there is anyway to set sequential string variables with data. I currently use the following to set T1 - T10 with values copied from a spreadsheet. There can be more than 10 values, I just stopped at 10 and added a repeat. This is a subroutine that is called from another macro.

 

Clipboard Copy

Variable Set String %T1% from Clipboard

Delay 250 milliseconds

Text Type: <Home> <Down Arrow>

Clipboard Copy

Variable Set String %T2% from Clipboard

Delay 250 milliseconds

Text Type: <Home> <Down Arrow>

....etc

Clipboard Copy

Variable Set String %T10% from Clipboard

Delay 250 milliseconds

Text Type: <Home> <Down Arrow>

 

Now I return the the main macro and enter the data into a screen.

 

Delay 800 milliseconds

Text Type: %T1% <Enter>

Delay 800 milliseconds

Text Type: %T2% <Enter>

.....etc

Delay 800 milliseconds

Text Type: %T10% <Enter>

 

I would like to do something like this. (Obviously this is not the correct syntax)

 

Clipboard copy

Variable Set String %T1% from clipboard

Delay

Repeat Until something

Clipboard copy

If Clipboard not equal to blank

increment %T_% by 1 (=next T variable)

Variable Set String %T_% from clipboard

End if

Repeat End

 

Now return to main macro and enter data using a similar process.

 

Thank you,

Marteb

Link to comment
Share on other sites

I have a setVar macro made to get numbers etc. from excel by seting up excel first and then starting macro exp macro to goto to excel and tab from cell to cell and copying cell to %T # then tab to next. I have it to load up to 30 %T#s.

I only know it will work with excel 2003

 

I would be glad to email some to you but Im new here to. How can I get your email with out puting my email in this forum open for the public.

 

Maybee this type a thing may help

 

Gene

Link to comment
Share on other sites

You would use a dynamic variable string. The following example loops 10 times and increments the "T" variable once every loop, and copying the clipboard contents to the incemented variable. You will need to insert your code for stuffing the clipboard, of course:

 

Repeat Start (Repeat 10 times)
 Variable Set String %T21% "<TVAR2:%N1%:03:>"
 Run Macro in Variable %T21%
Repeat End


<REP3:01:000001:000001:00010:1:01:><TVAR2:21:01:<TVAR2:%N1%:03:>><RUNMACVAR:21><ENDREP>

Link to comment
Share on other sites

Floyd,

 

Thanks for the help. I started working on this Friday and just could not get it to work (bad case of "brain lock"). Jumped into it this morning and finally got it working.

 

I had to add a "Variable Set Integer %N1% to 1" statement because it kept crashing ME. Not sure what that was all about?? I also had to add "Variable Modify Integer: %N1% = %N1% + 1" to increment the variable. Should it incremented on its own?

 

Since I'm using this as a subroutine, I added "Set Variable T99 from Clipboard" as a control instead of a "Repeat x times". Once the macro hits a blank cell, it will return to the main macro.

 

Looks like this is going to be a work in progress. I just thought of a couple more possible tweaks while composing this message.

 

Thanks again for all the help and I look forward to learning more.

 

Marteb

Link to comment
Share on other sites

I suggest you not plow thru the Excel file as described. I do this A LOT and it always breeds problems. Here’s the trick: Highlight the region in Excel and copy it to your clipboard. When you do so it is now in a tab separated values format! You can simply plow thru it parsing out variables until you get to the CRLF and then move on. No need to figure out how many there are. And all the manipulations can be done in memory without interacting with a program. Even your output can be accumulated in a variable for later use. I have several macros that work in this way and although it takes a bit at first to get your head around it I think you will find it’s way easier and more flexible.

Link to comment
Share on other sites

It's actually very simple. Once on the clipboard move it to a string variable. Then find the position of the tab by setting an integer variable to it's location. Then you decrement it once and use the Variable Modify command of Copy Part of Text using 1 as the start and your integer variable as the end. Then increment the integer variable once and Delete Part of Text 1 thru your integer var. Now do it over again. You can put this in a repeat that will repeat until your string variable equals "" which means empty.

 

If you have multiple rows you need to account for the CRLF at the end of each row. There are various ways of doing this or course and it depends on your workflow which way to do it. EG you might break away at each line to do something with those variables and part of another repeat.

 

Check out my subroutine on CRLF and TAB. I run this at the beginning of each macro so that I have a string var representing CRLF and TAB that I can use, in this case in the Get Position of Text described above.

 

http://bluepointdesign.com/macros/CRLF&TAB.htm

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