Jump to content
Macro Express Forums

Parse data from Text File


Recommended Posts

Good Afternoon Macro Gods,


I appeal to you for help in resolving an issue I've been having for quite some time. In my macros I often have to scrape data from a webpage that isn't formatted for easy macro searching, as such I usually have a macro search through the source code for the webpage I'm trying to scrape data from for what I need. The webpage is written with tags that always surround the data I need, the tags are specific to each value that needs to be parsed. Currently I use notepad and the find function to select the text I need, then set it to variables for later use from there. Is there a better way to do this that can scrape this data out in the background without using Notepad? I'd imagine there is, however I can't find any macro commands that let me set text between two expected text strings.


Here's a sample of the source code I'm trying to scrape data from so you can get an idea:


InitData("MV_MOVEMODEM", "False", "L");


InitData("MV_EMAIL", "", "C");


InitData("MV_MOVEFAX", "False", "L");


InitData("MV_MOVEREASON", "NH", "C");



I need to capture the data between InitData("MV_MOVEREASON", " and ", "C"); for example.

Link to comment
Share on other sites

This may all be common knowledge to you, but if so perhaps it will help someone else.


There is an ability to reduce a text variable by text strings, as a combination of several steps.

1) Put this text into a text variable

2) Set an integer variable (N1) based on the text string length.

3) Set another integer variable (N2) based on "Get position of text in a text variable", and set the text to find to be "MOVEREASON"

4) Select a third integer variable (N3) using Variable Modify Integer to be N1-N2 (the length of everything after your starting point)

5) Use Variable Modify String and select "Copy part of text" to modify the string. Use N2 as the starting position and N3 as the length.


Then modify these steps so that it also removes everything after the piece you want. You will be left with just a text string that contains your data.


Please note that these steps are the general steps to get your result, but not necessarily exactly what you need. For example, I believe that the result for N2 will actually give the character number for the M in MOVEREASON, so you may have to add a step to add a 13 to get to the actual starting character you want.

Link to comment
Share on other sites

  • 3 weeks later...
  • 1 year later...
  • 2 weeks later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

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.

  • Create New...