Bkelevate Posted March 9, 2016 Report Share Posted March 9, 2016 This is an example of the Order ID format we use - "615900205-10-1". The first part of the number is what I need to keep and I need to delete everything else. The problem is, none of the sections are a consistent number of digits so I am unsure how to use the "Delete part of text" variable where it asks for a Starting Position. I looked into Split String and choosing "-" for Split string on, however it just returned this "615900205101". So how can I delete everything to the right, starting with the first dash, if the starting position is not constant? Thanks. Quote Link to comment Share on other sites More sharing options...
rberq Posted March 9, 2016 Report Share Posted March 9, 2016 Variable Set String %T1% "abcdef-ghi" sample text for testingVariable Set Integer %N1% from Position of Text in Variable %T1% locate position of first hyphen within the textVariable Modify Integer: Dec (%N1%) set position back by one so hyphen won't be copiedVariable Modify String: Copy Part of %T1% to %T2% copy desired text to another variable, length N1 Quote Link to comment Share on other sites More sharing options...
Cory Posted March 10, 2016 Report Share Posted March 10, 2016 Split should work. Variable Set String %Sample% to "615900205-10-1" Split String "%Sample%" on "-" into %Part%, starting at 1 Text Box Display: Result You can copy this one into a macro. You need to define %Part% as an string with 3 elements. <VARIABLE SET STRING Option="\x00" Destination="%Sample%" Value="615900205-10-1" NoEmbeddedVars="FALSE"/> <SPLIT STRING Source="%Sample%" SplitChar="-" Dest="%Part%" Index="1"/> <TEXT BOX DISPLAY Title="Result" Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fnil Tahoma;}}\r\n\\viewkind4\\uc1\\pard\\f0\\fs16 %Part[1]%\r\n\\par }\r\n" Left="Center" Top="Center" Width="278" Height="200" Monitor="1" OnTop="FALSE" Keep_Focus="TRUE" Mode="\x00" Delay="0"/> Quote Link to comment Share on other sites More sharing options...
Bkelevate Posted March 10, 2016 Author Report Share Posted March 10, 2016 Variable Set String %T1% "abcdef-ghi" sample text for testing Variable Set Integer %N1% from Position of Text in Variable %T1% locate position of first hyphen within the text Variable Modify Integer: Dec (%N1%) set position back by one so hyphen won't be copied Variable Modify String: Copy Part of %T1% to %T2% copy desired text to another variable, length N1 I used Notepad to type the variable before and after your steps and it worked perfectly. Thanks! <WINDOW ACTIVATE Title="Untitled - Notepad" Exact_Match="FALSE" Wildcards="FALSE" _IGNORE="0x0006"/> <VARIABLE SET STRING Option="\x00" Destination="%T[1]%" Value="615900205-10-1" NoEmbeddedVars="FALSE"/> <TEXT TYPE Action="0" Text="%T[1]%<ENTER>"/> <VARIABLE SET INTEGER Option="\x0E" Destination="%N[1]%" Text_Variable="%T[1]%" Text="-" Ignore_Case="FALSE"/> <VARIABLE MODIFY INTEGER Option="\x01" Destination="%N[1]%" Value1="%N[1]%" Value2="1"/> <VARIABLE MODIFY STRING Option="\x09" Destination="%T[1]%" Variable="%T[1]%" Start="1" Count="%N[1]%" NoEmbeddedVars="FALSE"/> <WINDOW ACTIVATE Title="Untitled - Notepad" Exact_Match="FALSE" Wildcards="FALSE" _IGNORE="0x0006"/> <TEXT TYPE Action="0" Text="%T[1]%"/> Quote Link to comment Share on other sites More sharing options...
Bkelevate Posted March 10, 2016 Author Report Share Posted March 10, 2016 Split should work. Variable Set String %Sample% to "615900205-10-1" Split String "%Sample%" on "-" into %Part%, starting at 1 Text Box Display: Result You can copy this one into a macro. You need to define %Part% as an string with 3 elements. <VARIABLE SET STRING Option="\x00" Destination="%Sample%" Value="615900205-10-1" NoEmbeddedVars="FALSE"/> <SPLIT STRING Source="%Sample%" SplitChar="-" Dest="%Part%" Index="1"/> <TEXT BOX DISPLAY Title="Result" Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fnil Tahoma;}}\r\n\\viewkind4\\uc1\\pard\\f0\\fs16 %Part[1]%\r\n\\par }\r\n" Left="Center" Top="Center" Width="278" Height="200" Monitor="1" OnTop="FALSE" Keep_Focus="TRUE" Mode="\x00" Delay="0"/> Thank you, this worked as well. I've never used variables that weren't the standard %T[1]%, %N[1]%, etc so thank you for that new information. Quote Link to comment Share on other sites More sharing options...
Cory Posted March 11, 2016 Report Share Posted March 11, 2016 I highly recommend ditching the old ME3 variables unless you're dealing with legacy macros. When I start a new macro the first thing I do is to delete the vestigial 4. Quote Link to comment Share on other sites More sharing options...
Bkelevate Posted March 11, 2016 Author Report Share Posted March 11, 2016 I highly recommend ditching the old ME3 variables unless you're dealing with legacy macros. When I start a new macro the first thing I do is to delete the vestigial 4. I will definitely look into that. It would make the macros much easier to read being able to name them instead of relying on %T% and so on. Thanks again! Quote Link to comment Share on other sites More sharing options...
Cory Posted March 12, 2016 Report Share Posted March 12, 2016 And arrays are nicer. Since they have to be dimensioned in advance and one doesn't always know how many elements one will have it's nice to have a big chunk set aside and not have to worry about managing the elements of the one T array. And you always get to start at 1. Quote Link to comment Share on other sites More sharing options...
Dego Posted December 27, 2018 Report Share Posted December 27, 2018 On 3/10/2016 at 1:06 AM, Cory said: Split should work. Variable Set String %Sample% to "615900205-10-1" Split String "%Sample%" on "-" into %Part%, starting at 1 Text Box Display: Result You can copy this one into a macro. You need to define %Part% as an string with 3 elements. <VARIABLE SET STRING Option="\x00" Destination="%Sample%" Value="615900205-10-1" NoEmbeddedVars="FALSE"/> <SPLIT STRING Source="%Sample%" SplitChar="-" Dest="%Part%" Index="1"/> <TEXT BOX DISPLAY Title="Result" Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fnil Tahoma;}}\r\n\\viewkind4\\uc1\\pard\\f0\\fs16 %Part[1]%\r\n\\par }\r\n" Left="Center" Top="Center" Width="278" Height="200" Monitor="1" OnTop="FALSE" Keep_Focus="TRUE" Mode="\x00" Delay="0"/> Hi Cory I have tried using you code to try and solve an issue a problem similar to the one above. I am trying to extract the file name form the full path name i.e. C:\Users\desmo\Desktop\Holder\07. Fistful Of Tears.mp3 File need in a test variable 07. Fistful Of Tears.mp3 The error that I am getting is that the variable is not defined or wrong type Can you point me in the right direction Regards Desmond Quote Link to comment Share on other sites More sharing options...
Cory Posted January 4, 2019 Report Share Posted January 4, 2019 This is just the string of the commands in the Scripting editor. You need to define all the variables I use in here in order to make it work. Usually you can simply open and close the command dialog and it will ask you when you close it it will prompt you to create the variable. But make sure you choose the correct data type. Some commands support multiple data types and MEP doesn't always guess the correct one as it can't understand the context as you do. You can also search for the last "\" character and extract the sub-string instead of using split. 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.