Jump to content
Macro Express Forums

Recommended Posts

I have this line that I copy into T6

 

20120 Malmö

 

I have to use only the city name malmö

 

Sometimes the city name is the only thing that is been copyed.

 

How do I do so, that only city name/or text is back in T6?

 

can i tell the macro to look for text and only copy text and not copy space and numbers?

Link to post
Share on other sites

Could you do a Modify String, with "Delete part of text"?

 

At least that would work if the number of digits was consistent.

 

Otherwise you'd need to search the string for the space. That brings me to a question, can ME do something like that? Most program languages have a simple function that can return the first instance of a substring/char within a string (or, the first instance after a specified starting point), but come to think of it I don't recall such a function in ME.

 

Much as I love how useful ME is sometimes I'm a little annoyed at it's lack of quite basic programming abilities (hopefully to be amended in later versions.)

Link to post
Share on other sites

another1one:

The command to find the position of a space in the text is:

Variable Set Integer %N1% from Position of Text in Variable %T1%

koden:

If the suggestion that another1one made does not work you could try this:

Replace "0" with "" in %T1%
Replace "1" with "" in %T1%
Replace "2" with "" in %T1%
Replace "3" with "" in %T1%
Replace "4" with "" in %T1%
Replace "5" with "" in %T1%
Replace "6" with "" in %T1%
Replace "7" with "" in %T1%
Replace "8" with "" in %T1%
Replace "9" with "" in %T1%

You may want to explore the various features built into the Variable commands. Most of these functions are built into the 6 basic commands:

Variable Set String            Variable Modify String

Variable Set Integer          Variable Modify Integer

Variable Set Decimal        Variable Modify Decimal

Combined, these 6 macro commands contain 81 separate functions (including the ones suggested above).
Link to post
Share on other sites
  • 2 weeks later...

CODE

Replace "0" with "" in %T1%

Replace "1" with "" in %T1%

Replace "2" with "" in %T1%

Replace "3" with "" in %T1%

Replace "4" with "" in %T1%

Replace "5" with "" in %T1%

Replace "6" with "" in %T1%

Replace "7" with "" in %T1%

Replace "8" with "" in %T1%

Replace "9" with "" in %T1%

 

 

I'm not quit sure what you mean.

 

do you mean that I copy the first number and text into T1

Then i replace 0-9 with "" and I have only text left.

But what if there have been only text, and no numbers??

What will macro then do?

What about the space between number and text?

Space also have not to be copyed...

Link to post
Share on other sites

If the city name is preceded by a space character:

 

//for testing

Variable Set String %T1% "20120 Malmö "

 

 

// Get position of space character in T1

Variable Set Integer %N1% from Position of Text in Variable %T1%

// Get position of character after the space

Variable Modify Integer: Inc (%N1%)

// Copy from T1 to T1: Starting Position: Variable N1, Characters to Copy 100000

// that will also work for shorter variables

Variable Modify String: Copy Part of %T1% to %T1%

 

 

//for testing

Text Box Display: %T1%

Link to post
Share on other sites
do you mean that I copy the first number and text into T1 Then i replace 0-9 with "" and I have only text left.
Yes. All numbers will be removed from T1.
But what if there have been only text, and no numbers?? What will macro then do?
Then only the text will be left.
What about the space between number and text?

Space also have not to be copyed...

Then you can remove the space. There are several ways to do this, including wbeldman's suggestion. If you use wbeldman's method, you may not need to do use the Replace with commands because you could copy from the space to the end of the name.

 

However, you could use the Variable Modify String: Trim %T1% command to remove leading and trailing spaces. Like this:

Replace "0" with "" in %T1%
Replace "1" with "" in %T1%
Replace "2" with "" in %T1%
Replace "3" with "" in %T1%
Replace "4" with "" in %T1%
Replace "5" with "" in %T1%
Replace "6" with "" in %T1%
Replace "7" with "" in %T1%
Replace "8" with "" in %T1%
Replace "9" with "" in %T1%
Variable Modify String: Trim %T1%

This would remove all numbers and then remove spaces at the beginning and end of T1.

Link to post
Share on other sites
  • 1 month later...

I use this

 

Replace "0" with "" in %T1%

Replace "1" with "" in %T1%

Replace "2" with "" in %T1%

Replace "3" with "" in %T1%

Replace "4" with "" in %T1%

Replace "5" with "" in %T1%

Replace "6" with "" in %T1%

Replace "7" with "" in %T1%

Replace "8" with "" in %T1%

Replace "9" with "" in %T1%

 

And it works...

 

But today I have this line: 20120 city

he macro remove 201 but 20 is back....

 

So when T1 is typed there is standing 20city :-)

 

It looks like the macro only remove 1,2,3 a.s.o. one time???

How do i get it to replace ALL numbers, also thoose that are there twice?

 

If i put in one more

Replace "2" with "" in %T1%

and

Replace "0" with "" in %T1%

 

Then it works... :-) But it would be bether if it deleted all numbers...

Link to post
Share on other sites

Kevin: You can replace with "nothing" and avoid the trim.

 

another1one: Isn't this a European postal code? I think you all do it opposite (and more sensibly if you ask me) from the way we plosition it in the US. If it is it's a fixed number of digits and you can simple delete the appropriate number of characters.

 

Also when dealing with different text issues I've found Variable Set to ASCII Value" useful. This way I can do a mathematical comparison. So instead of having a line for each numeric character I can see if a character's ASCII integer value is within a range.

Link to post
Share on other sites
You can replace with "nothing" and avoid the trim.

Note that in my example all the Replace "x" with "" commands do replace with nothing. However, since the original string given as an example was "20120 Malmö ", after removing the numbers you are left with " Malmö ". This has both a leading and trailing space. The Trim command is a quick and easy way to remove them.

 

I intentionally did not recommend replacing spaces (Replace " " with "") since that would also remove desired embedded spaces if the city name included more than one word.

Link to post
Share on other sites

Join the conversation

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

Guest
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.

Loading...
×
×
  • Create New...