axio

Copy Until

4 posts in this topic

Hy guys i'm getting mad about how can i let work my macro,

Example:  "Text a - example b"

i need the copy of "Text a" and after other tasks i need the copy of "example b"

Is this possible?it should understand that when he find the "-" stops copying and starts to a clipboard fo the next paste

Ps:sorry for my bad english

thanks in advance

Share this post


Link to post
Share on other sites

Variable Set Integer %N1% from Position of Text in Variable %T1%  [search for the "-"]
Variable Modify String: Copy Part of %T1% to %T2% [copy from position 1 to position %N1%]
Variable Modify String: Save %T2% to Clipboard

 

Share this post


Link to post
Share on other sites

Yes it can be done -- using string manipulation. There are actually several ways to do it, and Rberq has eloquently outlined one approach.

I would do it somewhat the same way:

1. Copy the text to the clipboard.

2. Copy the clipboard to a string variable, say, T1.

3. Identify the position of the hyphen with T1, which is an integer, so let's call it N1.

4. Get the length of T1, an integer, so let's call it N2.

5. To obtain the first part, copy from position 1 to N1, and place it in variable T2.

6. To obtain the second part, copy from position N1 to N2, and place it in variable T3.

 

You may need to adjust N1 and N2 to make the script do exactly what you want, e.g., N1 = N1 + 1  or N1 = N1 - 1.

Share this post


Link to post
Share on other sites

This will get you close, although this version is written in Macro Express Pro instead of Macro Express. So you will need to recreate the code from scratch.

Clipboard Copy
Variable Set String %T1% from the clipboard contents
 
Variable Set Integer %N1% to the position of "-" in %T1%
Variable Set Integer %N2% to the length of variable %T1%
 
Variable Modify String: Copy a substring in %T1%, starting at 1 and %N1% characters long to %T2%
Variable Modify String: Copy a substring in %T1%, starting at %N1% and %N2% characters long to %T3%

The code works, but it may not be quite what you want. The results, T2 and T3, each contain a hyphen and an extra space. If you want to strip out the hyphen and/or the spaces around it, you will need to add extra lines. There are several ways to do it, but I would likely use a "fudge factor" of 1 or 2, depending on whether there are spaces surrounding the hyphen in the input, and/or whether you are OK with leading or trailing spaces in the output. But let's assume 1. The extra lines will do this:

N3 = N1 - 1, and

N4 = N1 + 1.

Then calculate T2 using N3 instead of N1, and T3 using N4 instead of N1.

I hope you enjoy learning about string manipulation! The best way to learn is through trial and error experimentation.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now