Jump to content
Macro Express Forums

If Contains With Multiple Instances


cyberchief

Recommended Posts

I have numerous Macro's that copy a screen of text and "If Contains" specific text... then perform a certain function. Is there a way to find multiple instances of a certain text? I am looking for a code labled ZCN and there may be times where it is on a page twice... I need to have the macro perform a certain function if it is on the screen twice. Can this be done?

Link to comment
Share on other sites

Hmm... You sure got some good selling points for that PGM Library. So no other ways just in ME to do that?

 

Just an update... I advised the Ops Mgr that we needed this. We are waiting to see where the VP wants to go with out little project. So far, it has turned into a big project. If we can create a new project desk here... I think we will be purchasing that software for each terminal.

Link to comment
Share on other sites

Cyberchief,

 

Yes you can accomplish this with "just Macro Express." The PGM Functions Library is just a collection of useful routines written using existing macro commands. The value of the PGM Functions Library is that you don't have to figure out how to accomplish something you need. Someone has already written it and you save time.

 

Here is what I would to do count the number of times a substring occurs in a string.

1. Copy the string

2. Working with the copy, use the Variable Set Integer %N1% from Position of Text in Variable %T1% command to find out if the substring appears in the string (N1 will be non-zero).

3. Increment a counter (perhaps N2).

4. Delete from the beginning of the string to the end of the substring in the string.

- a. Increment N1 by the length of the substring, in this case 3

- b. Delete N1 characters from the beginning of T1.

5. Repeat steps 2 through 4 until the macro determines that there are no more occurences of the substring (N1 will be 0).

 

N2 will contain the count.

 

I don't know if this is how the PGM Functions Library does this. It may use another technique.

 

As you can see, you can accomplish this with existing macro commands. But, you would save time, and your employer's money, using something that has already been written.

Link to comment
Share on other sites

The macros inside the PGM Functions Library are in fact written using generic out-of-the-box Macro Express commands by design. We figured this to be important for those who were interested in the source code.

 

A little history: When working with clients over the years, we found ourselves repeating certain program structures and decided to put them in separate functions and use the Macro Run command like a subroutine call in VB or VFP. Then we just figured that other users and developers are probably experiencing what we did and so decided to package them and place them in the market. And it all actually began with Macro Express 2000.

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