konstantin Posted October 21, 2006 Report Share Posted October 21, 2006 Is there any way to break up a string into three seperate variables? ie: 1) The Macro asks you for a name: 2) you type in "John Adams Micheals" 3) The macro spits out a text template where John goes under "First name", adams under Middle name, and micheals under last name. Is this possible? Quote Link to comment Share on other sites More sharing options...
kevin Posted October 23, 2006 Report Share Posted October 23, 2006 Try something like this: // Input string is in T1 // // Copy string to T4 Variable Modify String: Copy %T1% to %T4% // // Put the position of the first space in T4 into N1 Variable Set Integer %N1% from Position of Text in Variable %T4% // Decrement to skip the space Variable Modify Integer: Dec (%N1%) // Copy everything to T2 Variable Modify String: Copy Part of %T4% to %T2% // Increment to include the space Variable Modify Integer: Inc (%N1%) // Delete the first word, including the space Variable Modify String: Delete Part of %T4% // REPEAT to get the second word, except place result into T3 // Put the position of the first space in T4 into N1 Variable Set Integer %N1% from Position of Text in Variable %T4% // Decrement to skip the space Variable Modify Integer: Dec (%N1%) // Copy everything to T3 Variable Modify String: Copy Part of %T4% to %T3% // Increment to include the space Variable Modify Integer: Inc (%N1%) // Delete the first word, including the space Variable Modify String: Delete Part of %T4% // Here: // T1 contains the original string // T3 contains the first word // T4 contains the second word // T2 contains the third word Make sure that you put a space in the Search Text field inside the Variable Set Integer %N1% from Position of Text in Variable %T4% commands. Quote Link to comment Share on other sites More sharing options...
konstantin Posted October 26, 2006 Author Report Share Posted October 26, 2006 would anybody be able to make a quick example of that code? ^^ Quote Link to comment Share on other sites More sharing options...
blopib Posted March 14, 2007 Report Share Posted March 14, 2007 Try something like this:CODE // Input string is in T1 // // Copy string to T4 Variable Modify String: Copy %T1% to %T4% // // Put the position of the first space in T4 into N1 Variable Set Integer %N1% from Position of Text in Variable %T4% // Decrement to skip the space Variable Modify Integer: Dec (%N1%) // Copy everything to T2 Variable Modify String: Copy Part of %T4% to %T2% // Increment to include the space Variable Modify Integer: Inc (%N1%) // Delete the first word, including the space Variable Modify String: Delete Part of %T4% // REPEAT to get the second word, except place result into T3 // Put the position of the first space in T4 into N1 Variable Set Integer %N1% from Position of Text in Variable %T4% // Decrement to skip the space Variable Modify Integer: Dec (%N1%) // Copy everything to T3 Variable Modify String: Copy Part of %T4% to %T3% // Increment to include the space Variable Modify Integer: Inc (%N1%) // Delete the first word, including the space Variable Modify String: Delete Part of %T4% // Here: // T1 contains the original string // T3 contains the first word // T4 contains the second word // T2 contains the third word Make sure that you put a space in the Search Text field inside the Variable Set Integer %N1% from Position of Text in Variable %T4% commands. -------------------- Kevin Heaton Insight Software Solutions, Inc. I've tried this and i can get it to work with the "John Adams Micheals" example, but what if i have a list of different names with different length. As i understand you have to define stating position and characters to delete in for instance Variable Modify String: Delete Part of %T4% and thats the trouble when it varys. Is there something that i've missed? It could be very useful if this would work regardless of the length of the names. Thanx in advance. Quote Link to comment Share on other sites More sharing options...
kevin Posted March 14, 2007 Report Share Posted March 14, 2007 It could be very useful if this would work regardless of the length of the names.The example works with names of 1, 2 and 3 words. Each word, separated by a space, can be any length. If you need to parse names with 4 or more words then you can use the example as a pattern and extend it. Use the Variable Set Integer %N1% from Position of Text in Variable %T4% command to find where the space is in the string (the position is in N1). Then use that value (N1) in the Variable Modify String: Copy Part of %T4% to %T2% command. Quote Link to comment Share on other sites More sharing options...
kevin Posted March 14, 2007 Report Share Posted March 14, 2007 would anybody be able to make a quick example of that code? ^^The example macro shown was tested before it was posted. It works for 1, 2 and 3 word names. Quote Link to comment Share on other sites More sharing options...
blopib Posted March 15, 2007 Report Share Posted March 15, 2007 Thanks for you're quick answer Kevin. I'm sorry to say that we still don't understand how it works. We're getting the bit were you define %N1% to space then we're lost at the bit were you define the number of character to copy and delete becuse the length of the names are different every time. We're stuck on this and we would really get this to work since it would be very useful in handling information from another prog. that we use. Perhaps you could make the script and post it as a Direct Editor script. We then could implement this in the macro to better understand how it work. Thanks in advance. Quote Link to comment Share on other sites More sharing options...
kevin Posted March 15, 2007 Report Share Posted March 15, 2007 The macro is in the attached file ParseWords.zip. ParseWords.zip Quote Link to comment Share on other sites More sharing options...
blopib Posted March 15, 2007 Report Share Posted March 15, 2007 Tanks Kevin. Perfect. We'll take a look and learn from this. Quote Link to comment Share on other sites More sharing options...
blopib Posted March 15, 2007 Report Share Posted March 15, 2007 Tanks again! Now i see the light......... just hope to remember how it works next time. But i'll save this, thats for sure. Quote Link to comment Share on other sites More sharing options...
konstantin Posted March 16, 2007 Author Report Share Posted March 16, 2007 I cannot get the download to work. Whats going on? Quote Link to comment Share on other sites More sharing options...
blopib Posted March 16, 2007 Report Share Posted March 16, 2007 Konstantin: Save Target As and choose File format as WinZip File, change the file name to ParseWords and save it to you're desktop. Then unzip and you got you're self a beautiful mex-file.. :-) Quote Link to comment Share on other sites More sharing options...
Deo85 Posted November 10, 2009 Report Share Posted November 10, 2009 I am trying to do this but am having some difficulty with one part of the code. First when you say "Variable modify string copy part of %T4% to %T2%" Well the box says start position: and Character to Copy. I am guessing that this would be Variable T4 but you cant do this. It would not be Variable N1 because this was set to get rid of a space position after the first name. I am using Kelly Alexander for mine for instance. If I can get it to output the first name I am sure I can copy the 2nd name with no problem. What I am hoeing is if I can get macro express to notes the first space in the names string then copy all the info in from there to the start of the string aka "Kelly" then look for the end of the text and colly to the next closes space aka "Alexander" The reason I am going this cout is because some people tickets are put in with a first middle last name and others are only first and last name. All I want is there first name and there last name thought to move to the next part of the ticket system so I need to find a way to copy there WHOLE name then pars out there first and last names then save those as separate interagers to use later on. Love any help ppl can provide. I tried take the mxl file on this but that is just a executing of a macro but dose not let me look at the source code. Quote Link to comment Share on other sites More sharing options...
stevecasper Posted November 11, 2009 Report Share Posted November 11, 2009 Well the box says start position: and Character to Copy. If you download the actual macro file, you'll be able to open that command and see where the start position actually is (could be a comma, a space, or a specific series of characters). Quote Link to comment Share on other sites More sharing options...
Deo85 Posted November 11, 2009 Report Share Posted November 11, 2009 If you download the actual macro file, you'll be able to open that command and see where the start position actually is (could be a comma, a space, or a specific series of characters). I downloaded the macro in this but it simply executes instead of allowing me to see the code that's available. I guess I can see how you would tell it to start but the question is how do you get it to start at the beging of the name. I would guess the 2nd box you put the variable %N1% sense you all ready set this as the first space in the name. Quote Link to comment Share on other sites More sharing options...
kevin Posted November 11, 2009 Report Share Posted November 11, 2009 I downloaded the macro in this but it simply executes instead of allowing me to see the code that's available. If you click on the downloaded file then it will execute. Instead, from within the Macro Express Editor, click File, Import, Import Macros, Import a Playable Macro. This will import the macro into your existing macro file so you can view it. Quote Link to comment Share on other sites More sharing options...
Deo85 Posted November 11, 2009 Report Share Posted November 11, 2009 If you click on the downloaded file then it will execute. Instead, from within the Macro Express Editor, click File, Import, Import Macros, Import a Playable Macro. This will import the macro into your existing macro file so you can view it. Thank you for this! I was able to import the code and am now re processing it down this is perfect ^.^ 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.