loop41
Junior Member

Posts: 11
|
Post by loop41 on Jan 22, 2021 20:28:53 GMT
I need a little help with a detail that I have.
In short. What I need is to divide a string.
Ex: % STRING1% = BLUE RED
I need % STRING2% = BLUE
and
% STRING3% = RED
Any possible help is welcome. Thanks a lot
|
|
|
Post by Steve on Jan 24, 2021 4:34:30 GMT
|
|
loop41
Junior Member

Posts: 11
|
Post by loop41 on Jan 29, 2021 22:50:15 GMT
Hi Steve
I am very grateful for all your effort, I will see what I can do with those 2 options that you mentioned ,,,, however I already found another way of solution., which does not involve Split a string I'm very excited about the new update, especially with the arrays.
Thank you very much
|
|
|
Post by philranger on Jan 30, 2021 13:36:44 GMT
One way to do it is to paste the string in a notepad, do ctrl+home to be sure you’re at the beginning, hit ctrl+shift+right to select a whole word, cut it and store wherever you want., then repeat as needed.
|
|
loop41
Junior Member

Posts: 11
|
Post by loop41 on Jan 31, 2021 15:03:57 GMT
exactly, but that's the ugly and annoying part, I know I can solve it by opening the txt file, but I don't like it suggestion Steve : Create function divide string 1 | RUN ACTION | Split_String | "%txt%", "%STRINGX%", etc | Character to locate to make the cut | part before cutting %STRINGY% | part after cut % STRINGZ% or instead of locating the character in the string to perform the cut, it could be by position. If we had a string with a length of 80 characters, we could do a function that cuts for example in the character 50 and in the 1st string we would have the first 50 characters and in the 2nd string the other 30 ...... thanks for reading this .... bye
|
|
|
Post by philranger on Feb 2, 2021 12:38:15 GMT
Where is your original string located? Maybe you could split it from there as if it were in a notepad instead of copying it all at once? This would work for MS Word, Excel, any input box, etc.
|
|
|
Post by zeak on Feb 3, 2021 6:20:11 GMT
Where is your original string located? Maybe you could split it from there as if it were in a notepad instead of copying it all at once? This would work for MS Word, Excel, any input box, etc. Hi Phil, I've tried doing something like this before, The issue I ran into was telling MMM where to make the cut. Can I ask how you have coded MMM to decide where to make the cut depending on what text it is looking at?
|
|
|
Post by philranger on Feb 3, 2021 12:10:21 GMT
Hi Zeak,
Firstly I’d like to thank you for all of the help you provide on this forum, always nice respectful and helpful, even on very basic repetitive questions.
I use 3 ways:
1- The simple one. - Alt-Tab to the window where my text source is - Ctrl-home to be at the beginning of the text - Ctrl-shift-right to select one word (or shift-down if I need the full line) - Ctrl-x to cut it so my text is ready for next pass. Sometimes I need to add a “delete” to remove a space or a line feed. - Decide in MMM what to do with the content of the clipboard - Repeat
2- same thing but if the delimiter is not a space I first replace all delimiters by a space (or a line feed if I want to use the full line selection method. I then replace all double delimiters by a single one a couple tomes just to be sure. If my sources are in text files, I use Notepad++ to pretreat them as it has the ability to do a replace for all of the files in a folder at once, as well as doing complex searches (special characters, regex, variable length search, etc. ) as well as its own macro system (limited to Notepad++ though)
3- I used to use MS-Excel and formulas or macros for the tokenization, but didn’t need it for quite a while now as I am getting better with MMM and Notepad++. Excel is a bit of a bummer as you cannot easily copy from it and expect just text as an output depending on where you paste. I often needed to first paste in a notepad, then re-copy from there. That’s just one of the reasons why being able to do alt-tab-tab would be nice ;-)
|
|
loop41
Junior Member

Posts: 11
|
Post by loop41 on Feb 3, 2021 16:35:47 GMT
The string emerges as the code flows ,,,, let's say it is an http address ,,, example: http: // xxxxxxxx / xxxx / 5248759532 What I need is the number ,,,,,,, solution that I use: 1- pass the http address to a STRING 2- Open .txt and copy it there 3- I know the exact position of the number 4- with a LEFT CLICK DOWN from the initial position of the number, I move to the end, then LEFT CLICK RELEASE, with this I select the number 5- With a PRESSKEY CTRL + C, I copy the number 6- Then I designate a STRINGX what is in the CLIPBOARD 7- Done Haha ,,,, this works for me, but it is not what I want ... the idea would be not to have to interact with the txt file .... The program should only do it with a function .... That is where we should arrive ,,,, with steve's wit my sincere thanks to all of you guys, for making this community have this level of dynamism I really like it when I enter this forum and I see how many responses my comment has ... 
|
|
|
Post by zeak on Feb 4, 2021 23:37:47 GMT
Thank you Phil.
Both of those look to be good methods, unfortunately the string I am working with is mixed numbers and letters with no spaces.
eg. 2014SKU20220312, 908SKU20211130 or 20210325SKU992, 20220904SKU5001.
I need to pull the numbers on each side of the SKU text and then determined if its the item number or the date. I couldn't work out how to do this via MMM.
|
|
|
Post by philranger on Feb 5, 2021 3:14:11 GMT
Sorry if I say dumb stuff as I don’t know all of your variables...
In a notepad or something else: find “SKU”, escape, ctrl-shift-left, cut into an int variable, compare to plausible year span, find sku again (same one), ctrl-shift-right, cut into another numeric variable?
|
|
|
Post by Steve on Feb 5, 2021 5:55:40 GMT
I've got this.... Its going to look like this at variable declaration: In the STRING example we have CAT DOG FISH and we want them to be split by the delimiter of ' ' (a space) and assigned in sequence to string vars. In the CUSTOM VAR (%ANIMALS%) we have the same example, with edition of cow and goat. 1 | RUN ACTION | DEFINE STRING VARIABLE | %STRING%::test 2 | RUN ACTION | DEFINE STRING VARIABLE | %STRING1%:: 3 | RUN ACTION | DEFINE STRING VARIABLE | %STRING2%:: 4 | RUN ACTION | DEFINE STRING VARIABLE | %STRING3%:: 5 | RUN ACTION | DEFINE STRING VARIABLE | %STRING4%:: 6 | RUN ACTION | DEFINE STRING VARIABLE | %STRING1%::CAT DOG FISH::DELIM= ::LIMIT=0 7 | RUN ACTION | MESSAGE PROMPT | %string% %string1% %string2% %string3% %string4% * | Custom Vars *********************** 8 | RUN ACTION | DEFINE STRING VARIABLE | %STRING%::CAT DOG FISH COW GOAT 9 | RUN ACTION | DEFINE STRING VARIABLE | %ANIMALS%::%STRING%::DELIM= ::LIMIT=0 10 | RUN ACTION | MESSAGE PROMPT | %ANIMALS% %ANIMALS1% %ANIMALS2% %ANIMALS3% %ANIMALS4% At line 1 we define string to test At line 2 through 5 we define string1/2/3/4 to be empty. This is so we can clear the vars for the test. At line 6 we define our string list. It reads like this: - Starting from STRING1 - Apply 'CAT DOG FISH', split by the delim of ' ' (a space) - Do not limit the variable assignment. At line 7 we output the result. Notice that the variable assignment started at string1 and went up to string3. STRING4 was still the empty variable. At line 8 we do the same thing using a custom variable name (custom variables are coming in the next version upgrade). Now, this is just a quick implementation at this stage. I hope to add a little more to this. For now, so I can get this update out, Im going to keep it simple. Think it will work? 
|
|
loop41
Junior Member

Posts: 11
|
Post by loop41 on Feb 5, 2021 14:48:21 GMT
NICEEEEE
|
|