Jump to content
Macro Express Forums

Parsing this...


Recommended Posts

OK. Sorry it took so long to get back with you.

 

Sometimes the number part could be 4 digits, but the letter part seems to be always 3 digits. So I want to split it between the letters and numbers.

 

So what it boils down to is, I want the macro to detect when the letters end and the numbers begin no matter the number of numbers or letters after the first number.

 

Pat

Link to comment
Share on other sites

OK. Sorry it took so long to get back with you.

 

Sometimes the number part could be 4 digits, but the letter part seems to be always 3 digits. So I want to split it between the letters and numbers.

 

So what it boils down to is, I want the macro to detect when the letters end and the numbers begin no matter the number of numbers or letters after the first number.

 

Pat

 

Well, if I understand correctly "2bc" is the letter part and "250" is the number part.

 

If so what is "2" doing in the letters part? Is there always one digit in the front of the letter part?

If thats the case would it be reasonable to assume that the pattern looks like this:

<number><letters><numbers> ?

Link to comment
Share on other sites

I need to split the string in the middle and if the first character is a number, do not split it after this character rather go to the next possible "split" where letter ends and number begins.

 

I believe that's what you're looking for:

<VARIABLE SET STRING Option="\x00" Destination="%T[1]%" Value="1ac657" NoEmbeddedVars="FALSE" _COMMENT="string to be split"/>
<VARIABLE SET INTEGER Option="\x0D" Destination="%N[2]%" Text_Variable="%T[1]%"/>
<REPEAT START Start="1" Step="1" Count="%N[2]%" Save="TRUE" Variable="%N[1]%"/>
<VARIABLE MODIFY STRING Option="\x09" Destination="%T[2]%" Variable="%T[1]%" Start="%N[1]%" Count="1"/>
<IF VARIABLE Variable="%T[2]%" Condition="\x04" Value="a" IgnoreCase="FALSE"/>
<OR/>
<IF VARIABLE Variable="%N[1]%" Condition="\x00" Value="1" IgnoreCase="FALSE"/>
<VARIABLE MODIFY STRING Option="\x06" Destination="%T[3]%" Value="%T[2]%"/>
<ELSE/>
<VARIABLE MODIFY STRING Option="\x06" Destination="%T[4]%" Value="%T[2]%"/>
<END IF/>
<END REPEAT/>
<TEXT BOX DISPLAY Title="RESULT" Content="{\\rtf1\\ansi\\ansicpg1250\\deff0\\deflang1045{\\fonttbl{\\f0\\fnil\\fcharset0 Tahoma;}{\\f1\\fnil\\fcharset238 Tahoma;}{\\f2\\fnil Tahoma;}}\r\n\\viewkind4\\uc1\\pard\\f0\\fs16 %\\f1 T[3]%\r\n\\par \\f0 %\\f1 T[4]%\\f2 \r\n\\par }\r\n" Left="Center" Top="Center" Width="278" Height="200" Monitor="0" OnTop="FALSE" Keep_Focus="TRUE" Mode="\x00" Delay="0"/>

The macro copies one character at a time from the input string, if it is a letter or if it's the first character it appends it to string#1. If it's a digit it appends it to the string #2.

 

Am I close?

Link to comment
Share on other sites

Thanks Arek,

 

The string you used 1ac657 needs to be split between the c and 6 into 2 different variables.

 

The "1" needs to be disregarded if the first character is a number so it will not split it between the 1 and a.

 

Pat

Did you run the macro?

 

It should return:

1ac

657

Right?

 

It does when I run it. Does it not when you run it.... somehow...?

Link to comment
Share on other sites

I would go thru each character and record when it changes to a number. And I find concerting to the ASCII decimal value makes the logic easier.

That was my first idea Cory, but I figured this would be faster. Going thru the chars cannot be avoided (well, half of the chars). So, since we are already going through the chars, why not sort them at that time? Isn't it easier to write? It doesn't require remembering how many chars are going into one string, and how many chars go into the other. But that's just my point of view ;)

Link to comment
Share on other sites

Hello,

 

Arek, I had to wait until I got home from work to try the scipt again. It still splits it at the 1 not beteen the c and 6. Plus, you declared the variable to be a 1 in the scrpt. What happens if I get something other than 1? There would have to be 9 other variables declared.

 

For some reason when I copied the script, it did not copy all of it to my scrpt editor.

 

Nevertheless, Cory, Arek et. all, I would like to learn how ASCII decimals work with this script.

 

Can you show me how to do that?

 

Thanks!

 

Pat

Link to comment
Share on other sites

It still splits it at the 1 not beteen the c and 6.

For some reason when I copied the script, it did not copy all of it to my scrpt editor.

But now, when you copied the the rest of it it still doesn't return

1ac

657

?

I'm having really hard time understanding this, there's no way this macro is machine dependent. Can anyone confirm, please?

 

Plus, you declared the variable to be a 1 in the scrpt.

No such thing. You are apparently reffering to line #7 in the script. "1" is not a character there, it stands for the character position - first from the left.

 

Nevertheless, Cory, Arek et. all, I would like to learn how ASCII decimals work with this script.

Can you show me how to do that?

Cory has much more knowledge in this topic, and he surely can explain it better if he makes time.

Link to comment
Share on other sites

It works now. For some reason, there is a ton of blank "text types" that fill the script as it's copied. It happened at work and it happened at home when I copied your script and pasted it into the script editor.

 

I apologize. It works.

 

Should I submit this as a website bug?

Hahaha....

 

Pat

I can't reproduce this Pat. It hasn't ever happend to me. When I copy and paste this script (any script) into a macro it never adds any empty text type commands.

Does it happen to all the time, with every script, consistently? I can't think of a reason for it to happen... I wouldn't mind seeing a screenshot of the script with the extra commands.

Link to comment
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...