Separate

Anything Really. Just keep it clean!

Moderators: Dorian (MJT support), JRL

Post Reply
User avatar
PepsiHog
Automation Wizard
Posts: 430
Joined: Wed Apr 08, 2009 4:19 pm
Location: Florida

Separate

Post by PepsiHog » Mon Dec 30, 2019 9:43 pm

We all know that when you use the command Separate> that you are done using that string, so there is no reason to keep the original string.

You would have to be NUTS, to separate a string and then STILL use the original string!

Like some of you might use LabelToVar to get a DataBlock and then separate the data with the command Separate but then still need to use the original string of the datablock to count what position a piece of data is in. Just as an example.

If you are that person, I am here to tell you, "You are NUTS!" Who ever heard of using a string more than once? I mean really, people!

If you do need to use the same string, then you are just going to have to redefine it again and again and again. That makes the script easy to read. Constantly changing the string name also helps the readability. You can NOT expect to use the same string name throughout your ENTIRE macro. That is also NUTS!

Once you perform any process on a string, i.e. Separate, RegEx, you naturally loose that string.

This also helps to lengthen your macro by adding line after line of redundant string assignments. Or it keeps the other guy guessing as to the name of the new string you had to create to replace the one you lost after performing a process on the string.

It makes no difference that the first name was a perfect name for that string. You're just gonna have to make new names. Hopefully you'll be able to keep track of what name a string currently is. Good luck with sifting through all the name assignments and figuring out what the last name was.

PepsiHog
MS v14 Windows 7

PepsiHog. Yep! I drink LOTS of Pepsi (still..in 2020) AND enjoy programming. (That's my little piece of heaven!)

The immensity of the scope of possibilities within Macro Scheduler pushes the user beyond just macros!

User avatar
JRL
Automation Wizard
Posts: 3298
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Re: Separate

Post by JRL » Thu Jan 02, 2020 6:30 pm

????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
What??? are you talking about?
????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????

Separate> does absolutely nothing to the separated variable unless you tell it to do so by using the same variable name for the input and the output.

Here's an example where the input and output variables are different and the string assigned to the original variable "vData" is still intact and available for use after Separate> has been used on it.

Code: Select all

LabelToVar>DataList,vData
Separate>vData,crlf,vItem

Let>kk=0
Repeat>kk
  Add>kk,1
  Let>value=vItem_%kk%
  MDL>value
Until>kk={%vItem_Count%-1}

MDL>vData

/*
DataList:
Line1
Line2
Line3
*/





On the other hand...
If you use the same variable name for input and output to the Separate> function, you'll lose the string assigned to the original variable "vItem" because you reassigned the value of the variable "vItem".

Code: Select all

LabelToVar>DataList,vItem
Separate>vItem,crlf,vItem

Let>kk=0
Repeat>kk
  Add>kk,1
  Let>value=vItem_%kk%
  MDL>value
Until>kk={%vItem_Count%-1}

MDL>vItem

/*
DataList:
Line1
Line2
Line3
*/

User avatar
PepsiHog
Automation Wizard
Posts: 430
Joined: Wed Apr 08, 2009 4:19 pm
Location: Florida

Re: Separate

Post by PepsiHog » Fri Jan 03, 2020 2:31 am

@JRL,
Interesting. Thanks. I am working on a script. At the start it reads a few datablocks. The names being separated are different. Marcus pointed that out and I changed them. Your macro works as you said. As far as what is going on, I clearly have no idea.

Some how, some way, the original string is being cleared. I added an exit below the problem area and have been trying to figure out why. The even stranger element is the string doesn't do this in v12. It works as intended. As a resolution, I attempted to replace the separate with a regex, and the original also was cleared. It seems awfully strange I have this problem.

The section is at the start, so I can't even imagine what the problem is. Maybe it's haunted.

Ok, thanks for the reality check. I have to go now. I have an appointment with the wall. Going to try to bang a few things out.

Pepsihog
MS v14 Windows 7

PepsiHog. Yep! I drink LOTS of Pepsi (still..in 2020) AND enjoy programming. (That's my little piece of heaven!)

The immensity of the scope of possibilities within Macro Scheduler pushes the user beyond just macros!

User avatar
Dorian (MJT support)
Automation Wizard
Posts: 540
Joined: Sun Nov 03, 2002 3:19 am
Contact:

Re: Separate

Post by Dorian (MJT support) » Fri Jan 03, 2020 11:01 am

Hi Pepsi,

I think you may find your answers to what's happening and to the v12/v14 issue in an old support ticket.

To quote Marcus :
Separate creates an array. It takes a string and creates an array. So if you set the result var the same as the input var you will be replacing the input string with an array.

If you use a different output var then the input var will remain intact.
in v14 the result is an array. And you have the result variable the same as the input variable. So you are overwriting your input variable (which was a string) with the array.

v12 didn't have proper arrays so this didn't happen.
Yes, we have a Custom Scripting Service. Message me or go here

User avatar
JRL
Automation Wizard
Posts: 3298
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Re: Separate

Post by JRL » Fri Jan 03, 2020 2:06 pm

Thanks for that Dorian. Good information!

@PepsiHog.
Can you post a section of code that is failing?

User avatar
PepsiHog
Automation Wizard
Posts: 430
Joined: Wed Apr 08, 2009 4:19 pm
Location: Florida

Re: Separate

Post by PepsiHog » Fri Jan 03, 2020 4:24 pm

@Dorian,
I suspect those quotes are from the conversation Marcus and I had. I do understand that. My vars are different. And I am still having the problem. But as JRL's script proved, something else is going on.

@JRL,
Working on it. Give me a couple of days and check back here, please. As they say, "perception is everything". And now you have changed my perception. Maybe, that's all I needed someone to do. Thanks for that.

Thanks. Drink water.
PepsiHog
MS v14 Windows 7

PepsiHog. Yep! I drink LOTS of Pepsi (still..in 2020) AND enjoy programming. (That's my little piece of heaven!)

The immensity of the scope of possibilities within Macro Scheduler pushes the user beyond just macros!

User avatar
PepsiHog
Automation Wizard
Posts: 430
Joined: Wed Apr 08, 2009 4:19 pm
Location: Florida

Re: Separate

Post by PepsiHog » Fri Jan 03, 2020 4:36 pm

@All,

I just realized.......HAPPY NEW YEAR!

Am I the first to post this?

PepsiHog
MS v14 Windows 7

PepsiHog. Yep! I drink LOTS of Pepsi (still..in 2020) AND enjoy programming. (That's my little piece of heaven!)

The immensity of the scope of possibilities within Macro Scheduler pushes the user beyond just macros!

Post Reply