OK, so using an abbreviated set (4 groups, limited rows) of data from your last Source Data, I have a revised Macro that will produce this:
Example Output
I have changed most KM Variables from Local to Global variables (meaning that they were persist permanently until deleted).
All of these Global Variables have a prefix of:
DND_ETC__
which means "Do Not Delete" and then "Extract Time Codes".
Hopefully this will allow you to create/keep these variables without accidental interaction with other Macros. Meanwhile, they are available to other Macros that you want to use the data.
However, do note that these Variables are cleared/overwritten whenever this Macro is run:
DND_ETC__GroupTimes
DND_ETC__List1
DND_ETC__List2
DND_ETC__List3
DND_ETC__List4
. . .
DND_ETC__Listn (where n is the number of lists)
DND_ETC__OuputFolder
DND_ETC__OutputToFile
DND_ETC__SourceList
DND_ETC__VarList
You can view all of these DND_ETC
variables at any time using the KM Editor > Preferences > Variables Tab:
Please test this macro and let me know if it works for you and/or if you have questions.
MACRO: Extract TimeCodes in Group Lists [Example] @BillyTheHick
#### DOWNLOAD:
<a class="attachment" href="/uploads/default/original/3X/1/3/13dd49fb11d2203e67599c64b56f418f2ae8bb47.kmmacros">Extract TimeCodes in Group Lists [Example] @BillyTheHick.kmmacros</a> (67 KB)
**Note: This Macro was uploaded in a DISABLED state. You must enable before it can be triggered.**
---
### ReleaseNotes
Author.@JMichaelTX
**PURPOSE:**
* **Separate a List into Variables Based on String at Beginning of Line**
* Provide option to Output to Files
* Create Variable for Group Times of Even-Numbered Groups
* Group Name (A1),TimeCode In (B1),TimeCode Out (Cn)
(where n is the number of Rows in the Group)
**REQUIRES:**
1. **KM 8.2+**
* But it can be written in KM 7.3.1+
* It is KM8 specific just because some of the Actions have changed to make things simpler, but equivalent Actions are available in KM 7.3.1.
.
2. **macOS 10.11.6 (El Capitan)**
* KM 8 Requires Yosemite or later, so this macro will probably run on Yosemite, but I make no guarantees. :wink:
**NOTICE: This macro/script is just an _Example_**
* It has had very limited testing.
* You need to test further before using in a production environment.
* It does not have extensive error checking/handling.
* It may not be complete. It is provided as an example to show you one approach to solving a problem.
**How To Use**
1. Enable the Action you wish to use to set the Source Data:
* Set Variable (default, and enabled)
* Copy (disabled)
* If you use this, then first select the text to be used as Source
* Read file (disabled)
2. Trigger this macro.
* It will then sort the data so that lines that begin with the same string are grouped to together.
* A RegEx is performed to extract the Groups into separate Variables, named as follows: `Local_List<N>`
* where `<N>` is the sequential integer based on Group position in the sorted Source List.
**MACRO SETUP**
* **Carefully review the Release Notes and the Macro Actions**
* Make sure you understand what the Macro will do.
* You are responsible for running the Macro, not me. ??
.
1. Assign a Trigger to this maro..
2. Move this macro to a Macro Group that is only Active when you need this Macro.
3. ENABLE this Macro.
.
* **REVIEW/CHANGE THE FOLLOWING MACRO ACTIONS:**
(all shown in the magenta color)
* Enable ONE of the first 3 Actions to choose your method of setting the Source Data.
* Be sure to DISABLE the other two Actions.
* IF you choose Read File, enter full POSIX path to file
* IF you choose Set SourceList to Text, Enter the list in the Action's text box
* Prompt User for Output Options
* Change defaults as desired
TAGS: @List @Variables @RegEx
USER SETTINGS:
* Any Action in _magenta color_ is designed to be changed by end-user
ACTION COLOR CODES
* To facilitate the reading, customizing, and maintenance of this macro,
key Actions are colored as follows:
* GREEN -- Key Comments designed to highlight main sections of macro
* MAGENTA -- Actions designed to be customized by user
* YELLOW -- Primary Actions (usually the main purpose of the macro)
* ORANGE -- Actions that permanently destroy Variables or Clipboards,
OR IF/THEN and PAUSE Actions
**USE AT YOUR OWN RISK**
* While I have given this limited testing, and to the best of my knowledge will do no harm, I cannot guarantee it.
* If you have any doubts or questions:
* **Ask first**
* Turn on the KM Debugger from the KM Status Menu, and step through the macro, making sure you understand what it is doing with each Action.
---
![image|333x2000](upload://kVDnNy6UzWHBuvSUMKtPnxSj5vw.png)