cyberchief Posted May 16, 2005 Report Share Posted May 16, 2005 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? Quote Link to comment Share on other sites More sharing options...
floyd Posted May 16, 2005 Report Share Posted May 16, 2005 Cyberchief The {String - Occurs} macro in the PGM Functions Library returns a count of the number of times that one string occurs within another. Quote Link to comment Share on other sites More sharing options...
cyberchief Posted May 16, 2005 Author Report Share Posted May 16, 2005 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. Quote Link to comment Share on other sites More sharing options...
kevin Posted May 16, 2005 Report Share Posted May 16, 2005 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. Quote Link to comment Share on other sites More sharing options...
joe Posted May 16, 2005 Report Share Posted May 16, 2005 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. Quote Link to comment Share on other sites More sharing options...
cyberchief Posted May 17, 2005 Author Report Share Posted May 17, 2005 Kevin, Thank you very much! That was brilliant. Worked just fine. I am going to work this in and see if this will solve the problems. Joe, don't worry... we will still be purchasing the PGM Libraries... Can't get around those "Date Time" issues. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.